Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Java, RoboJDE

  1. Dec 5, 2006 #1
    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


    while(current no. of pixels > original no. of pixels )
    move backwards

    Is this sound? Any ideas are more than welcome.

  2. jcsd
  3. Dec 5, 2006 #2

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    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.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook