- #1
glid02
- 54
- 0
Hey, I'm working on a project with RoboJDE and java and I have a few quick questions.
What I'm supposed to do is write code so that the camera will find the coordinates of a swatch of color and move accordingly as the swatch changes positions. The robot is supposed to move from side to side and forward and backward as smoothly as possible.
I've already been provided with the code necessary to move the robot and find the centroid. Basically when the centroid moves to the left or right the robot moves accordingly and when the swatch occupies more pixels on the camera the robot moves backward and when the swatch occupies less pixels the robot moves forward.
Now I'm just trying to figure out the best way to code the commands so the robot moves as smooth as possible.
The best idea I've come up with so far is a series of while loops.
I'd save the original position of the centroid of the swatch and do:
while (new position > old position)
move to the right
and
while(current no. of pixels > original no. of pixels )
move backwards
Is this sound? Any ideas are more than welcome.
Thanks.
What I'm supposed to do is write code so that the camera will find the coordinates of a swatch of color and move accordingly as the swatch changes positions. The robot is supposed to move from side to side and forward and backward as smoothly as possible.
I've already been provided with the code necessary to move the robot and find the centroid. Basically when the centroid moves to the left or right the robot moves accordingly and when the swatch occupies more pixels on the camera the robot moves backward and when the swatch occupies less pixels the robot moves forward.
Now I'm just trying to figure out the best way to code the commands so the robot moves as smooth as possible.
The best idea I've come up with so far is a series of while loops.
I'd save the original position of the centroid of the swatch and do:
while (new position > old position)
move to the right
and
while(current no. of pixels > original no. of pixels )
move backwards
Is this sound? Any ideas are more than welcome.
Thanks.