Java, RoboJDE

  • Java
  • Thread starter glid02
  • Start date
  • #1
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.
 

Answers and Replies

  • #2
D H
Staff Emeritus
Science Advisor
Insights Author
15,393
686
This is not a very good controller.
  • It is too sensitive to measurement noise. Your measurement of the centroid and size of the patch is inherently noisy. No besmirching of how you are accomplishing this as all measurements are inherently noisy.
  • It is not 'smooth'. Your control algorithm needs to account for velocity in some way to make it smooth.
  • It is rather jerky. Suppose the target is moving forward and to the left simultaneously. Your robot will follow the patch by making a series of ninety degree turns.

Some suggestions:
  • Control forward/backward and left/right motion simultaneously.
  • Use a control mechanism that accounts for velocity and noise such as a phase plane controller with deadbands.
 

Related Threads on Java, RoboJDE

Replies
2
Views
10K
  • Last Post
Replies
4
Views
1K
  • Last Post
Replies
2
Views
2K
  • Last Post
Replies
2
Views
2K
  • Last Post
Replies
4
Views
2K
  • Last Post
Replies
1
Views
2K
  • Last Post
Replies
1
Views
1K
  • Last Post
Replies
8
Views
2K
  • Last Post
Replies
2
Views
10K
  • Last Post
Replies
3
Views
3K
Top