0% found this document useful (0 votes)
4 views4 pages

Lab 2

The document outlines exercises for simulating kinematic models of wheeled robots using MATLAB, focusing on forward and inverse kinematics. It guides users through creating a differential drive robot (DDR) model, validating simulations, and adjusting wheel velocities for desired robot movement. The exercises culminate in a full system model that incorporates angular position into the kinematic calculations.

Uploaded by

fatma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

Lab 2

The document outlines exercises for simulating kinematic models of wheeled robots using MATLAB, focusing on forward and inverse kinematics. It guides users through creating a differential drive robot (DDR) model, validating simulations, and adjusting wheel velocities for desired robot movement. The exercises culminate in a full system model that incorporates angular position into the kinematic calculations.

Uploaded by

fatma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Department of Electrical and Electronic Engineering

Mobile Robots and Autonomous Systems: Wheeled


Kinematics

Objective
The purpose of these exercises is to learn how to simulate kinematic models of wheeled
-

robots using MATLAB

Learning outcomes
At the end of this session you should be able to:

• 1 Generate a kinematic model of a wheeled robot in MATLAB


-

• --Calculate the world-frame robot velocity using Forward Kinematics


-

• Calculate the body-frame wheel velocities using Inverse Kinematics


3
.

-um -

Introduction
These exercises are designed to help develop your simulation skills in MATLAB by
modelling the kinematics of a differential drive robot (DDR). Both forward and inverse
kinematic models will be utilised.

Page 1
Task I: Forward Kinematic Model of a DDR
Using the m-file ‘diff_drive_kin.m’, input the variables and constraint equations for a
-

DDR shown in Figure 1 (complete the ‘Kinematic Model’ section of the m-file).
> (l)
-
The distance between the centre of each wheel and the point P is 0.25 m and the wheel

7&
-

radius is 0.1 m. Set the wheel velocities to be 1 rad/s for each wheel.

[
-

r, rz
= 1 = 0 .

= Q I rad/s al 25m
=
= 0 .

a
a v , =
rz = 0 -
) m
"Okwise-ive
I Oz I rad/s
&
Y
- a =
=

&
Xaxis line
1 Draw whee
&
.

centro of
centre of robot to the
. line from
,

2
X-axis)
3 .

angle from
1 to2 . (reflected m axis of

wheel
if it goes -
>

#
betwen
1 Like centre of no bot
X :
angle
B : .
from
Biso axis of robot
body
to centre .
of wheel axis of the wheel

1
&
wheel 1 draw axis
. ↓ line
2
away from ofthe wheel

#
P to cate
"newy is line from away from P
&: distance between
3 angle from 1702

.
of whel. to matchy . line
2 from
axis) of the
creflected on main Pto centre
wheel
wheel 3 if aligns B : =0

j parallel to the
. ↑

1 line not then find B


: .

if
dotted line
(axis of rot .


2 - But we want all same

ofthe wheel) look at the direction

direction of roler !
whi isOto make it
o

Stolfor <comeback
⑰2
>
-
.
3 from to check

creflected on main axis S


adby -

B : extra rule Figure 1 – DDR Parameters Y

whid2 opp to 3&n


rolling G
> sliding
+

if we
go from
I to 2 (Uftdirection) for rightfor 3991 182 then -
Use the sliding and rolling constraints to form the matrices J1 and J2 (slides 45 and 46 in
the notes). New for radii ithas 0

An example of how to form and easily visualise a matrix in MATLAB is shown for the
rotation matrix, R.

Once this is complete, write the equation to calculate the world-frame robot velocities
(zeta) in the ‘Simulation Outputs’ section of the m-file (slide 43 of the notes).
[invR] inv (51)a524phidot]

Hint: To invert a square matrix, use ‘inv(A)’. To invert a non-square matrix, use
‘pinv(A)’. For more details about how these functions work, please use the MATLAB
-

Help files.

Run the m-file. What is the velocity of the robot in each DOF?
-

r

[0 1g.
=
5 . 131-18 ; 0]

2|Page
Simulink
Y = ddr-kin(Phi-dot)
Task II: SIMULINK Model of a DDR function
Y = zetadof

The model we’ve just developed provides an instantaneous calculation of the robot
velocity. To be of more use, we usually want to observe the robot moving over a period
of time (following a trajectory for example). This can be done in MATLAB, but it is often
easier (for closed-loop control) in SIMULINK.

SIMULINK models can contain embedded MATLAB code. We are going to use this
approach, as it allows us to more easily observe and understand what is happening in
the simulation.

Create a new blank model in SIMULINK. Place a MATLAB Function block from the
Library Browser into the workspace. Double click the block and you should be taken to
a new MATLAB function entitled ‘fcn’.

I
Change the name of the function to ‘ddr_kin’ and change the input to ‘phi_dot’ and the
output to ‘zeta_dot’. Copy your DDR kinematic model from the Task I m-file to the
ddr_kin function. Delete the rotational velocity variable ‘phi’ from the model as this is
now your input.

In the SIMULINK workspace, add a ‘constant block as the input to the function with the
value [1 1] and add a scope to the output. Run the simulation. If you open the scope,
you should see that the robot has the same velocities as calculated in Task I.

The output is a set of velocities, however we’re often also interested in the position of
the robot. Add an integrator block to the output of the MATLAB function block and a
second scope. Run the simulation again and you can see that the robot is moving at a
constant rate in the x-direction. After 10 seconds, it has travelled a distance of 1 m.

Task III: Simulation Validation


Now that you have a simulation, you have to be able to answer the question “Is the
simulation correct?” Methods of confirming if a simulation is correct or not are known 3
& as validation.
m

Validation of simulations is very important as if you don’t check to see if it’s correct, you
could miss errors that mean your results are invalid. ·
-

&
There are several ways you could validate a simulation. Often the most important way is
① to -
run experiments to confirm the simulation results. Whilst this is the preferred way in
many case, it can often be impractical
-
due to cost (experiments could be expensive to
run), time (it could take a long time to run an experiment) or complexity (it may not be
~

feasible to run experiments).


-

?
Experiments and simulations rarely align to due to ‘real-world’ factors and the ideal
nature of many simulations (lack of noise, tolerances, etc…). What we are often looking
-

for is general alignment of the two (they’re roughly the same). Often models which are
ok, but not perfect are known as ‘fit for purpose’. -

For this simulation, we’re going to validate mathematically rather than experimentally.
-

This is an alternative approach when experimental equipment isn’t available.

put that
in for
extra-
3|Page
Our simulation ran for 10 s. Both wheels were rotating at the same velocity (1 rad/s), so -

the robot was moving in the x-direction only. We know the radius of the wheels (0.1 m), cirumfo
so we can calculate the total distance it should travel. = rence

d
=
- the m of
radtore

6
wheel

By hand (pen/paper/calculator) or MATLAB, calculate how far the robot should have (2xr)
travelled. rw (x)
or v1 m/s
= = 0 .
= 0
-

d = Sxt = 1my

Hint: You’ll need to convert the wheel velocity from rad/s to revolutions per second.

Task IV: Full System Model = xom = Im



The simulation you’ve just finished works really well if the robot’s body-reference frame
is aligned with the world-reference frame, as the robot’s angular position, theta, is not
fed back into the kinematic model.

The use of scopes to view the outputs is also not ideal for future data manipulation and
presentation.

Open the SIMULINK file ‘ddr_kin_full.sim’ and the corresponding control m-file
‘ddr_run.m’. The m-file allows you to run the simulation from the MATLAB console. It
allows you to set parameters that are passed into the simulation then outputs are passed
out into the workspace where you can save them and use them however you want.

Run the simulation and observe the different plots that are generated. If you look at the
simulation file, you’ll see that the angular position is now fed into the kinematic model.
II mat

- Change the wheel velocities to vary over time. You may wish to use two input blocks;
"I matri - -
one for each wheel, then a ‘mux’ to collate them as the input to the kinematic model.
-

Task V: Inverse Kinematics


So far we’ve only considered forward kinematics, where the wheel velocities have been
set and we are trying to calculate the robot velocity. Inverse kinematics is the process of
specifying the robot velocities and calculating the required wheel velocities.

Using the ‘diff_drive_kin.m’ from Task I, rearrange the kinematic equation in the
‘Simulation Outputs’ section to be with respect to phi_dot (e.g. phi_dot = …).

Hint: You will need to use matrix algebra rather than scalar algebra to rearrange the
-
equation.

What wheel velocities are required to get the robot moving backwards at a velocity of
> rotation
-
0.5 m/s?
-
-
zethedot [-0 .
5; 00]
- Y i.

AWest 5) rad/s
5 ;
% [
-
-

Issue 1.1 -
06/02/2024

[Jjri =
5, (523phi)]

4|Page

You might also like