loading
 
scale servo arduino object tracking
Pablo Martinez from Panama  [2 posts]
8 year
I have a problem with the tracking object. the servos dont work good. the servos are moving for every side. I think that is problem with the scale and I dont understand how to do that, who can help me? thanks, sorry with my english I'm learning. Im using arduino uno and the code of the page roborealm.
my vbs is

width = GetVariable("IMAGE_WIDTH")
heigth = GetVariable("IMAGE_HEIGHT")

if GetVariable("COG_BOX_SIZE") > 10 then

x = GetVariable("COG_X")
y = GetVariable("COG_Y")

x = CInt((x/width)*2000)
y = CInt((y/heigth)*2000)


SetVariable "servo_position_x",x
SetVariable "servo_position_y", y

end if

program.robo
Steven Gentner from United States  [1446 posts] 8 year
Pablo,

If I'm not mistake I would expect the servo values to range from 500 to 2500? If so, the actual formula should be:

x = CInt((x/width)*2000) + 500
y = CInt((y/heigth)*2000) + 500

because your range above would be 0 to 2000. +500 gets it into the right range.

STeven.

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index