Having just built my first 2WD robot kit (DFRobot), I've been playing around with some basic object avoidance which went ok but I quickly discovered that without motor encoders, its going to be very difficult to get accurate heading changes.
So I came up with an idea and thought I'd ask on here whether it sounded feasible before buying the rest of the bits.
I was thinking that if I had 4 distance sensors facing in each direction, N,S,E,W, I could read record the outputs on all 4 and rotate slowly until the exact same readings were seen again (offset by 90 degrees), so I knew when I'd made the desired turn. Granted, most of the time three sensors would be at infinity with the sensor in the direction of travel triggering the turn, but in more complex situations where we're in a corner we'd have readings from 2 sensors to use.
Another idea I had was to use a couple of sensors mounted on two servos, as the turn of a servo can be more accurately controlled, one could move the servo 90 degrees then rotate the vehicle until the same reading was reached. If this is done incrementally it'll reduce the chances of the sensor/servo combination "locking" on to something else which gives an identical distance.
Failing that is there any other way of doing this without encoders? If not then can anyone point me in the direction of encoders which will work with the DFRobot geared motors.
how about a digital compass ?
I didn’t think they were that accurate?
with some averaging of readings they are quite good.
The advantage of a compass is that you can detect also errors like different wheel or track sizes, or if your robots glides on a slope it can reorientate.
It can even determine its (absolute) orientation at start, before any movements.
Add a GPS and you're quite complete
Thanks, any recommendations on a digital compass? With the GPS are they only any good outdoors over large distances? I'd imagine GPS in a small room would be next to useless.
Only been doing this a couple of weeks but since I got my 2wd robot kit Friday I've been addicted to tweaking and I've very quickly realised I need "more input". Loving this hobby.
I've got a load of servos knocking about as I fly model planes, think I'll stick my IR and/or ultrasonic sensor on that for some radar sweeping.
I'd imagine GPS in a small room would be next to useless.
And, you'd be right. GPSs need to be able to see satellites, which are typically outside. The resolution of a GPS is typically +/- 1o meters, which on a 10 mile/kilometer trip is good enough, but in a 5 meter/yard room is next to useless.
OP, you can try the 4 distance sensor idea, however, all of these schemes will be off by a few degrees
at the very least. Sonars have wide beams, even the "narrow" beam ones like Maxsonar EZ4, and Sharp
IR rangers have a limited distance range and poor accuracy at longer distances. OTOH, even encoders
won't always work well, due to wheel slippage,etc, on different surfaces [carpet vs hard floor], or where
the 2 wheels are each on a different surface.
You might try a 2-stage scheme, of first turning at a set speed for a specific time-period [determined
experimentally], and which will by off by 10-20 degrees in general [I've tried this], and then adjusting
the angle using one of the sensor schemes.
Thanks for the replies, I'm going to have a play with the sensor and timing methods out of curiosity / learning potential but I've ordered the 6352 compass module as I can see that being useful in this and future projects.
Will post some code and schematics once I have a few versions working, I might make one robot switchable so I can benchmark the relative performance.
I and a few others I talk with have found the 6352 to be difficult to calibrate, maybe we're just thick
I like and have used the Honeywell 5883 and the LSM303 (whatever the latest is I guess LSM303DLHC now)
You might consider adding a gyro. I am fond of the L3G4200D (there's a new version since I bought it).
Compass is going to be sensitive to ferromagnetic objects the robot drives near. Gyro is going to drift. The common approach is to do some kind of fusion. A complimentary filter is simplest where you effectively low pass filter the compass and high pass filter the gyro in software. Kalman Filter is unsimple. But it can work well.
I believe compasses give poor readings when the motors are turning, so you might have
to run the motors, stop, wait, read the compass, repeat over and over.