IVR Practical: Robotics 2 (Week 8)


The purpose of this practical is to:
  1. Construct the Lego robot needed for the second IVR assignment.
  2. Practising the use of a PID controller in simulated system
  3. Maintain a reliable estimate of the position of the robot

1. Constructing the Lego robot

Please refer to the information at the problem sheet for assignment 2. Use the opportunity to discuss any variation of the design of the robot with your tutor. Also discuss with your tutor if you have any problems in the communication with the robot, with finding a good control algorithm for the robot etc.

2. PID control in Matlab

From within Matlab, search for "inverted pendulum". Choose the "Simulink > 3D Animation > Simulink examples". Then choose "Open this Example" (which may take a while). After starting the 3D animation, you click in the area in order to set a new target point. Open the PID controller (double click) in the accompanying scheme in order to change its parameters.
Set all parameters to zero and try using the Ziegler-Nichols method to tune the parameters. This will probably not work. Can you still find "manually" good parameter values for the P, I and D gains?
Try not avoid referring to the original values of this example, but check whether any parameter values you have found are similar to those.
Not that the problem of pole balancing is similar to the posture balancing or keeping a two-wheeled robot upright. There is nevertheless no reason why controller gains should be similar in these cases. Also the parameter range for which the controller is successful may be differently large in either case.
Now after closing this example you may like to move on to another Matlab example such as "Control of an Inverted Pendulum on a Cart".

3. Odometry

In the previous practical you have controlled the robot based on direct movement commands. For an autonomous robot it will be necessary that the robot can maintain an intrinsic estimate of the position.
If you didn't use Webots in the previous practicals, please go back and make yourself familiar with the basics tasks.
Note that if you did not download the IVR software to your own filespace, you will need to do so to be able to communicate with Webots. The Matlab code is available from last week's practical.

In this practical we will just try using a simple script to control the robot and to give it an ability to adjust its parameters.

What ever the robot does, it is effective only if the robot's wheels are turning. The wheel revolutions can be sensed from the wheel encoders. From these readings the robot can update its position where we assume that it started at the point (x=0, y=0, φ=0). The general idea is that the average of the speeds of the two wheels gives a good estimate of the distance travelled whereas the difference between the speeds tells how the bearing angle of the robot changes. Some geometric considerations lead to these formula for the x-coordinate, y-coordinate and bearing angle φ:

x ← x + Δx =x + 0.5*(vleft + vright) cos(φ)
y ← y + Δy =y + 0.5*(vleft + vright) sin(φ)
φ ← φ + Δφ = φ - 0.5*(vleft - vright)/(2R)

The formula contains, in addition to the wheel speeds (taken as counter values) , the parameter R that denotes the radius of the robot (or rather half the distance between its wheels). The parameter (about 4cm) can be determined by measurement, but it may not be sufficiently precise.

In order to calibrate the odometric formula you can make the robot turn (s. first practical) while calculating the angle. If the robot has turned exactly once (or a number of times for better precision) the angle estimate can be checked and the "parameter" can be tuned until the measurement is sufficiently correct.

Some useful functions

can be found in the first robotics practical.
In addition you will need in particular these functions: unless you are using send_command etc. for direct communication with the robot. Sensor readings can be obtained by send_command('N') and read into a matlab structure by sensor=read_command. Note that the first entry in sensor is the robot's response (small letter 'n') which is followed by the eight IR sensor values.

One way of reading the sensor values is:

s2=regexp(sensor, '\,', 'split')
for i=1:8
sr(i)=str2num(s2{1,i+1});
end;

Main IVR Page