Society of Robots - Robot Forum

Software => Software => Topic started by: arrrrgon on February 28, 2011, 03:00:56 PM

Title: IR Rangefinder Problem
Post by: arrrrgon on February 28, 2011, 03:00:56 PM
I'm working on adding the IR Rangefinder to my $50 robot and I'm having an issue.  The rangefinder seems to work after I program it while the programmer is still connected.  After I disconnect the programmer, the server spins to the right and stays in the position.  The robot itself then just spins in a circle and the servo with the rangefinder on it never moves.  Like I said, if I leave the programmer connected, the rangefinder seems to be working in that it is following my hand when I move it past.

Any ideas?
Title: Re: IR Rangefinder Problem
Post by: hopslink on February 28, 2011, 04:09:39 PM
Sounds like the programmed behaviour if you are using the example code.

The 'bot will only react if it detects an object within range, that range is set a couple of seconds after reset. Hold an object in front of the sensor at a distance within it's range for the first few seconds after reset. After this the 'bot should react by chasing the edge of any object in range. There is no IR sensor sweeping behaviour coded.
Title: Re: IR Rangefinder Problem
Post by: arrrrgon on February 28, 2011, 06:21:20 PM
No, it doesn't work at all after I disconnect the programmer.  It just spins in a circle and never detects anything.  The entire robot only works properly when connected to the programmer.
Title: Re: IR Rangefinder Problem
Post by: hopslink on March 01, 2011, 02:53:41 AM
Sorry, my bad.

Just to clarify - the entire robot is working correctly when you have the programmer cable attached - the IR servo moves to track an object and the robot drives toward it? But if you disconnect the programmer, reset the bot and carry out the scanner calibration on startup you just get the spinning behaviour? and if you lift the bot off the ground the servo will no longer track an object (edge) in range?

You say the servo for the IR sensor truns to the right, which way does the robot spin? to the left or the right?
Title: Re: IR Rangefinder Problem
Post by: arrrrgon on March 01, 2011, 07:20:27 AM
It's partially working now, but something is still odd.  The rangefinder will spin far to the right but it just barely goes to the left at all and when it sees the object directly in front, it kind of twitches towards it.  Should it drive straight at the object, or is the only goal to spin around until it detects the object?  I'm assuming I just need to tweak the programming to change how far the servo moves to the left, but I'm not sure about the behavior my robot is displaying.
Title: Re: IR Rangefinder Problem
Post by: hopslink on March 01, 2011, 10:37:38 AM
Try steadily reducing the value of 41 for scan_angle in the scan() function which should allow the servo to swing further to the left. When you reach a value that allows the sensor to point slightly to the left of dead ahead update the value of 41 in the main() loop to match. Hopefully then you should see the proper chase behaviour.

If you have reach the limits of your servo travel adjust the values so that the servo can never turn to it's extents and move the servo horn round to get the sensor pointing in the desired directions.