loading
 
vbs codeing
charlie from United Kingdom  [9 posts]
11 years
ive had a go at makeing a motion tracking turret (and the most dangerous thing that will ever be mounted on it is a soft airgun) but i cant work out how to convert whatever range it is to 0-255(ish)

would it be (image res)/255 ?

an another thing, is there any way of dampening the movement so that my feeble lego construction dosent shake its self to pices?
Anonymous 11 years
That really depends on what you want the final values to be and the current image size that you're using. For example if you want the final values to range from 0 to 10 from mid screen the X equation would be something like:

cogX = GetVariable("COG_X")
image_width = GetVariable("IMAGE_WIDTH")/2

if cogX > image_width then
motor_left = ((cogX - image_width)/image_width)*10.0
else
motor_right = ((image_width - cogX)/image_width)*10.0
end if

Which basically determines how much cogX if from the center of the image. Uses the scale of half the image size and multiplies that by the desired factor. In other words you convert the cogX to a real value from 0.0 to 1.0 and then simply multiply that by the desired scale factor.

Note that image_width is the image width / 2

You can see that at the extremes the values are 10 and at the center of the screen the values are 0.
Anonymous 11 years
the problem is im useing servos and the camera is static

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