View Single Post
  #4   Spotlight this post!  
Unread 04-04-2008, 10:24
mluckham's Avatar
mluckham mluckham is offline
Registered User
FRC #0758 (Sky Robotics)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2006
Location: Ontario, Canada
Posts: 116
mluckham will become famous soon enoughmluckham will become famous soon enough
Re: Programming n3wb needs help

Maybe if you don't have The Programmer and so need a Mechanical solution (unfair, they don't let you touch the walls!) you could just run a rope through your robot and stretch it tightly down the hallway? (Just kidding).

I agree about the Maxbotix ultrasonic sensors. They output various types of signals, but the easiest to use is the analog output which you connect to Analog Inputs on the robot controller. You will have to solder a PWM cable to the Maxbotix sensor board.

One easy thing to start with is a very simple EasyC program, that reads joystick inputs into a variable, and then copies the variable to the PWM outputs for the Victors. You ought to be able to get your robot drivable with the joystick in less than a dozen lines of code.

Next, mount two Maxbotix sensors to the front corners of your robot and aim them outwards towards the wall. Connect the PWM cables (you soldered previously) to two Analog inputs. Change your EasyC program to read the inputs and Print them so you know they are working, and what values you get at various distances from the wall.

Now it's a "simple" matter of trying to have the robot steer to keep the analog input readings fairly equal. You will have to experiment with this, but to start with I suggest subtracting the left sensor value from the right sensor value to get the "error". Use a signed variable, so that the error value can be positive or negative depending on which sensor has the higher value.

Now add this error variable to one PWM output value, and subtract it from the other. This will cause the robot to swerve - if you get the directions right, and steer in a very wiggly path down the hallway.

I recommend using the joystick fwd/rev motion to control speed, and to leave the steering joystick axis alone.

This should get you started.