Finding the position of a differential drive robot

Click For Summary
The discussion focuses on calculating the position and orientation of a differential drive robot after 6 seconds, given specific wheel speeds and distances. The angular velocity of the robot is determined to be approximately 0.089 rad/s, leading to a counter-clockwise rotation of about 30.6° from its original position. The participants discuss issues with MATLAB code implementation, particularly regarding the calculations of x, y coordinates, and angular orientation. There is an emphasis on ensuring correct conversions from RPM to rad/s and clarifying the direction of angle measurement. The conversation concludes with a resolution of coding errors, leading to accurate results.
PainterGuy
Messages
938
Reaction score
73
Data:
The speed of right wheel is considered to be 25 RPM.
The speed of left wheel is considered to be 20 RPM.
The distance, L, between wheels is 30 cm.
Also the radius, r, of each wheel is 6 cm.

Question:
Using the data above for a differential robot, find the following:

i: angular velocity of robot

ii: linear velocity of robot

iii: find location of the ICC/ICR

iv: Suppose the robot's original configuration is given by the coordinates
(55 cm, 60 cm, 0°). Find the position and orientation after 6 s.

I need help with part iv.

I tried to use Euler's approximation for part iv.

$$x(k+1)=\left[ \frac{v_{L}+v_{R}}{2}\cos \left\{ \theta (k\right\} \right] \Delta T+x(k)$$

$$y(k+1)=\left[ \frac{v_{L}+v_{R}}{2}\sin \left\{ \theta (k\right\} \right] \Delta T+y(k)$$

$$\theta (k+1)=\left[ \frac{v_{L}+v_{R}}{L}\right] \Delta T+\theta (k)$$

I tried to solve it here. Please jump to the part iv at the bottom. I tried to implement it in Matlab but it looks like something is wrong. I understand that there would be far better ways to write the code but I wanted to know if my method is okay. Could you please help me with it? The way I did it x(k+1) and y(k+1) give total distance moved but aren't x(k+1) and y(k+1) supposed to give coordinates of the point the robot is at after 6 seconds?

Matlab:
clear all; close all; clc;

k=linspace(0,6,200);
theta(1)=0;
deltaT=(6-0)/200;
x(1)=55;
y(1)=60;
L=30;
vL=2;
vR=2.5;

for k=1:200
    
    theta(k+1)=(((vL-vR)/L)).*deltaT+theta(k);
    x(k+1)=(((vL+vR)./2).*cos(theta(k)))*deltaT+x(k);
    y(k+1)=(((vL+vR)./2).*sin(theta(k)))*deltaT+y(k);
    
end

sum(x)
sum(y)
sum(theta)
 

Attachments

  • diff_drive_euler.jpg
    diff_drive_euler.jpg
    42.9 KB · Views: 380
Physics news on Phys.org
Is this a homework problem?

The robot will take a circular path. Knowing the separation and RPM of the two wheels you can linearly extrapolate to the centre of the circular path.
 
  • Like
Likes PainterGuy
Thank you!

I'd say you can call it homework.

You are correct that the robot will take circular path around ICR point assuming same angular velocity along the circular path.

The angular velocity I found is:
ω=1. 6668×10⁻² rad/s ; or, in degress 1. 6668×10⁻²×57.3= 0.95508°

So, in 6 seconds angular distance traveled is almost 3.4×10⁻² rad/s or 6°. I hope I have it correct.

I think that the following code is better. There is clearly something wrong. I'm not sure about the values of "x" and y but the value of theta cannot be " -0.1000" as given in the output. Could you please helpe?

Matlab:
clear all; close all; clc;

k=linspace(0,6,3000);
theta(1)=0;
deltaT=(6-0)/3000;
x(1)=55;
y(1)=60;
L=30;
vL=2;
vR=2.5;

for k=1:3000
   
    theta(k+1)=(((vL-vR)/L)).*deltaT+theta(k);
    x(k+1)=(((vL+vR)./2).*cos(theta(k)))*deltaT+x(k);
    y(k+1)=(((vL+vR)./2).*sin(theta(k)))*deltaT+y(k);
   
end

x(3000)
y(3000)
theta(3000)

Output:
Matlab:
ans =

   68.4730ans =

   59.3262ans =

  -0.1000
 
The Minus sign is easy. Look at vL & vR in lines 9, 10; then look at how they are used in line 14.

Cheers,
Tom
 
Thanks!

But it looks wrong.

The original statement is follows:
iv: Suppose the robot's original configuration is given by the coordinates
(55 cm, 60 cm, 0°). Find the position and orientation after 6 s.

The right wheel has greater speed than the left wheel therefore the robot rotates clockwise. It would mean that the value of "x" should decrease and value of "y" should increase. But the output shows the value of "x" going up and value of "y" going down.
 
First, the convention for angles needs to be defined. Are you defining angle of robot orientation to increase in the clockwise or counter-clockwise direction?

See if you can find a tapered bottle, or anything that approaches a cone. Roll up and tape a sheet of paper if you can't find anything else. Lay it on its side on a flat surface in front of you with the large end to the right. Now roll it away from you (forward direction).

The different diameters of the cone are equivalent to the different wheel speeds, i.e. the big end, on the right, travels more distance in unit time than the small end travels.

Which output and lines-of-code represent which things asked for in the problem?

Cheers,
Tom
 
  • Like
Likes Lnewqban and PainterGuy
Thanks.

Tom.G said:
First, the convention for angles needs to be defined. Are you defining angle of robot orientation to increase in the clockwise or counter-clockwise direction?

Counterclockwise.

Tom.G said:
The different diameters of the cone are equivalent to the different wheel speeds, i.e. the big end, on the right, travels more distance in unit time than the small end travels.

Agreed. The right wheel would travel more distance as its speed is greater.

Tom.G said:
Which output and lines-of-code represent which things asked for in the problem?

Matlab:
clear all; close all; clc;

k=linspace(0,6,3000); % dividing 6s time interval into 3000 steps
deltaT=(6-0)/3000;

% the following three lines give original robot position coordinates
x(1)=55;
y(1)=60;
theta(1)=0;

L=30; % distance between the wheels
vL=2; % left wheel speed
vR=2.5; % right wheel speed

for k=1:3000
  
    theta(k+1)=(((vL-vR)/L)).*deltaT+theta(k);
    x(k+1)=(((vL+vR)./2).*cos(theta(k)))*deltaT+x(k);
    y(k+1)=(((vL+vR)./2).*sin(theta(k)))*deltaT+y(k);
  
end

x(3000) % I think x(3000) represent end x-coordinated after 6s
y(3000)
theta(3000)

Matlab:
ans =

   68.4730  % x coordinateans =

   59.3262  % y coordinateans =

  -0.1000  % theta coordinate
 
It seems that there is an error in the calculations of the angular velocity of each wheel, as rpm were converted to rad/s.
According to my calculations:

##\omega_L=2.094~rad/s##
##\omega_R=2.618~rad/s##

Arc described by each wheel should be 12.56 cm/s for left wheel and 15.70 cm/s for right one.

Radius of rotation around a common vertical axis should be 142.73 cm for left wheel and 172.73 cm for right one.

If all the above is true, the angular velocity of the robot about that vertical axis should be 0.089 rad/s.
In 6 seconds, it should sweep a counter-clockwise angle of 0.534 rad or 30.6° measured from the original position and orientation.
 
Last edited:
  • Like
Likes PainterGuy
Lnewqban said:
It seems that there is an error in the calculations of the angular velocity of each wheel, as rpm were converted to rad/s.
According to my calculations:

ωL=2.094 rad/s
ωR=2.618 rad/s

Thank you for pointing out this mistake. I have fixed it and got the right answer after making some changes to the code.
 
  • Like
Likes Lnewqban
  • #10
You are welcome :smile:

Happy to help, just noted that error.
Sorry I can’t help you with ii, iii or iv.
 
  • Like
Likes PainterGuy

Similar threads

  • · Replies 2 ·
Replies
2
Views
6K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
42
Views
3K
  • · Replies 10 ·
Replies
10
Views
1K
Replies
10
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K