I'm trying to find the turn angle of my robot, which has 2 DC motors, equipped with encoders.
Edited post, since i am actually aiming to find the turn angle, and not turn speed, as previously stated.
I have these two possibilities:
turnspeed = (pulseright + pulseleft) / 2.0;
Or
turnspeed = (pulseright + pulseleft);
The variables pulseright and pulseleft have polarities, so their respective values show the number of pulses and direction of rotation of each motor/wheel.
If the robot is spinning in one spot, with pulseright + pulseleft = 0, then both of the above equations give a net speed of zero. But i can't figure out which one is correct and why?
I am also using this formula for the average forward and backward speed:
speed = (pulseright + pulseleft) / 2.0;
but i'm wondering if it's the same for turning speed?
Hi,
I would use the first equation with /2 in it, as that will cover ALL possibilities.
You would be using the centre between the two wheels as your position reference.
Both motors in the same direction and the same speed, as in a straight track.
Both motors in the same direction and different speeds, as in a curved track, lower speed than straight.
One motor forward or backward and the other 0, half speed as the vehicle is turning in an arc around one wheel.
One motor forward and the other backward, zero speed as the vehicle is turning on its centre of drive.
TomGeorge:
Hi,
I would use the first equation with /2 in it, as that will cover ALL possibilities.
You would be using the centre between the two wheels as your position reference.
Both motors in the same direction and the same speed, as in a straight track.
Both motors in the same direction and different speeds, as in a curved track, lower speed than straight.
One motor forward or backward and the other 0, half speed as the vehicle is turning in an arc around one wheel.
One motor forward and the other backward, zero speed as the vehicle is turning on its centre of drive.
I hope this makes sense.. Tom...
Thanks for the explanation. I'm also trying to find the angular position of the robot. I think it should be possible to get an approximation of the angle turned by the robot from the encoders only. Would the same formula be valid?
DrDiettrich:
I wonder what you consider to be a "turn speed"? Degrees per second?
I'd try something like pulseleft-pulseright.
Yes, i'm thinking about degrees per second. But i would like to get the rotation speed from the encoders only. I wonder if it's possible... I think that in this case, maybe pulseleft-pulseright should be fine.
jremington: This paper gives the details for a simple model of differential drive steering and robot turn angle.
Wheel rim velocity is calculated from the wheel radius, the number of pulses per revolution, and time per pulse.
Thank you for this link. It has been very enlightening. I spent some time to read the whole paper and tried my best to get a proper understanding of it, although there are some parts which are still a bit confusing.
From what i can understand, the only formula that i need is the second one, as my objective is to find the rotation angle of the robot or its yaw:
But i'm not sure about the value of θ0, so i will just take it to be zero... From further down the article, this is mentioned: "How much of a turn is too much? That depends on the geometry of the particular robot. You can probably use (the equation above) as long as the angle of the turn does not get larger than 10 degrees. If it does, you should apply the approximation in stages. That is, if the robot's transit results in a turn of 20 degrees, treat it as two segments of 10 degrees each."
Now, i'm trying to code it to work on my Arduino UNO R3. I am using two similar DC motors, each equipped with Hall encoders and each connected to a similar-sized wheel.
jremington:
Those would be very large wheels, especially when spaced only 12 cm (about 1/6 of their diameter) apart. Are those numbers correct?
The radius is actually 3.25 cm. My mistake. I fixed it by changing the radius value to 0.0325 in metres.
But now i'm wondering how to adapt this code for a turn angle greater than 10 degrees, so to quote it again from that website: "you should apply the approximation in stages. That is, if the robot's transit results in a turn of 20 degrees, treat it as two segments of 10 degrees each."
But i'm not sure how to implement this in the code... since i do not know how big of a turn the robot will make, so i cannot possibly know if the angle is going to be within 10 degrees or more.
Hi.
The theta-zero is a reference angle if you wanted to get an angle with respect to say North.
Theta-zero would be your starting angle before you turned, or the last angle from the last turn if you want to measure orientation, rather than turn angle.
In your case it would equal zero, as you are only wanting to measure the absolute angle of the turns you make.
TomGeorge:
Hi.
The theta-zero is a reference angle if you wanted to get an angle with respect to say North.
Theta-zero would be your starting angle before you turned, or the last angle from the last turn if you want to measure orientation, rather than turn angle.
In your case it would equal zero, as you are only wanting to measure the absolute angle of the turns you make.
Tom...
That paper was missing a comprehensive explanation on the reference angle. That was very helpful! Thank you.