Lab 3 - Robots

Laboratory Instructions 2015
Prescription Number(s): ENGR121
Laboratory Number:
3
Laboratory Title:
Robot Locomotion
2
3.1
Introduction
In this lab you characterise the motion of a minion: a yellow, semi-autonomous, two-wheeled
robot. You will use a variety of mathematical techniques to calculate how fast your minion can
run. You will use this information to then plan a successful strategy when engaging in a game
of robot tag.
The motivation for this lab is to demonstrate the usefulness of mathematics when performing
complex tasks where a trial and error approach is not feasible. The example of two robots
playing tag may be readily extrapolated to a Dragon X spacecraft docking with the International
Space Station (ISS), or a lion hunting an antelope. In these situations there is no scope for trial
and error, either the course is correct, in which case the spacecraft docks and the lion gets
fed, or a catastrophic failure ensues that is not easy to recover form. Although the lion has an
intuitive understanding of the mathematics involved with chasing an antelope, for the examples
of our robots and space station docking the mathematics needs to be explicitly laid out and
manipulated to ensure a successful result.
3.2
Programming Your Robot
Most of you will have come across Arduino programming in ENGR101. If not, don’t worry!
It’s very easy to learn. Before you begin, you will need to add some libraries that are required
by the robot. Download libraries.zip from the ENGR121 Lab Resources wiki page and
extract it into ∼/sketchbook/libraries.
Now you are ready to start the Arduino development environment: from the terminal, type
arduino and hit enter. The window shown in Fig. 3.1 should appear. Before you load any
code, check that you have the right board type selected from the Tools > Board menu. “Arduino
Mega 2560 or Mega ADK” should be checked. Next, download the file
ENGR121_Robots_2015.ino from the Lab Resources page. Open this file in the Arduino
editor.
The code in ENGR121_Robots_2015.ino will be used to control the behaviour of the
robot. To change the speed of the robot look for the line of code that begins baseSpeed = .
A value of 0 for baseSpeed corresponds to zero power, while maximum power is achieved
with a value of 255. By default the value is 20 so that the robot does not take off when you first
connect it to the PC.
Once you have made these modifications to your code you are ready to load it onto your robot.
Make sure that the robot is connected via USB to the computer, and click the arrow button in
the top left corner of the Arduino editor. This will verify your code and, if no errors are found,
will load it onto your robot.
3
Figure 3.1: Arduino development environment.
3.3
Robot Characterisation
Your first challenge is to characterise the linear performance of your robot. You need to find
its maximum velocity and acceleration. The simplest approach to finding these properties is
to use the kinematic equations, which relate distance, velocity and time assuming constant
acceleration.
3.3.1
Kinematic Equations
Kinematic equations provide a framework for us to describe the motion of objects. They allow
us to connect acceleration, velocity, distance and time in a convenient, easy-to-remember way.
The four kinematic equations required for this project are:
1
d = v1 t + a · t2
2
v2 + v1
d =
·t
2
v2 = v1 + a · t
v22 = v12 + 2a · d
(3.1)
(3.2)
(3.3)
(3.4)
where d is distance (m);
t is time (s);
v1 is initial velocity (ms−1 );
v2 is final velocity (ms−1 );
And a is acceleration (ms−2 ), which we always assume to be constant when using Eqns. 3.1-
4
3.4.
The robot’s velocity when ENGR121_Robots_2015.ino is run can be approximated by
the graph shown in Fig. 3.2. At the start of the run, the robot’s initial velocity is 0 ms−1 and
it is accelerating at a constant rate. This corresponds to the first half of Fig. 3.2. The second
half of Fig. 3.2 describes the case where the robot has reached full speed and is no longer
accelerating.
12
Velocity (ms 1)
10
8
6
4
2
0
0
5
10
Time (s)
15
20
Figure 3.2: Velocity vs. time of a robot running ENGR121_Robots_2015.ino.
Tasks
Core Load the file ENGR121_Robot_2015.ino onto your robot and run it. Using a large
(1 m) ruler and a stop watch, calculate the distance, d1 , covered by the robot in a given
time, t1 , near the start of the robot’s run, when the robot is accelerating.
Core Similarly, calculate a second distance, d2 , covered by the robot in a time, t2 , when the
robot’s speed is approximately constant.
Completion From your time and distance measurements, use the kinematic equations to calculate the acceleration, aa , and maximum velocity, vmax , of your robot using Eqns. 3.1-3.2.
3.4
Measurement Uncertainty
When taking physical measurements, it is impossible for us to know the true value of the
quantity being measured. Instead, the measured value, which we read from a stop watch,
motor encoder, or other meter, is fundamentally only an approximation of the true value. It is
important for us to have an understanding of the difference between these two values, and how
5
this difference affects subsequent calculations that we base on our measurements. Hence we
attach an uncertainty to each measurement we take.
We have two ways of finding the uncertainty of a measurement:
3.4.1
Find the Average Deviation
Here we repeat the measurement several times, and record the average of all of the measurements as our measured value. We also calculate the average deviation, where the deviation of
each measurement is the absolute difference between that measurement and the average of all
measurements. We say that the uncertainty of the measurement is equal to the average deviation.
For example, we might measure the time it takes for a computer to reboot. Performing the same
measurement 5 times, we get:
Measurement no. 1
Time (s) 40.7
2
43.0
3
4
52.7 50.3
5
38.0
The average of the measurements is
(40.7 + 43.0 + 52.7 + 50.3 + 38.0)/5 = 44.9 s,
(3.5)
and the average absolute deviation is
(|40.7 − 44.9| + |43.0 − 44.9| + |52.7 − 44.9| +
|50.3 − 44.9| + |38.0 − 44.9|)/5 =
(4.2 + 1.9 + 7.8 + 5.4 + 6.9)/5 =
26.2/5 = 5.2 s.
(3.6)
(3.7)
(3.8)
Hence our measured value is 44.9 ± 5.2 s.
3.4.2
Estimate Uncertainty
We may not always be able to take several measurements in order to find the average deviation.
In such cases, we estimate the uncertainty in a single measurement. Typically, we might estimate that the uncertainty is equal to ±the smallest unit on our measuring device. For example,
we might measure a piece of string to be 10 cm long. Assuming that the ruler we used cannot
measure lengths smaller than 1 cm, we would estimate the uncertainty of our measurement to
be ±0.5 cm at each end of the string, or ±1 cm in total, since any string with an end between
9.5 cm and 10.4 cm would be measured as 10 cm by the ruler.
3.4.3
Combining Uncertainties
Regardless of how we find the uncertainty of our measurement, it is important to know how that
uncertainty affects calculations based on the measurement. When we are adding or subtracting
6
measurements, calculating the uncertainty is relatively simple: the uncertainty of the calculation
is simply the sum of the absolute uncertainties of the measurements. For example,
5 ± 0.5 cm − 3 ± 0.2 cm = 2 ± 0.7 cm.
(3.9)
However, when we multiply or divide measurements, we need to take extra care with the uncertainties, because the uncertainty of a product is the sum of the relative uncertainties of the
measurements:
10 ± 0.5 cm = 10 cm ± 5%
5 ± 0.5 cm = 5 cm ± 10%
(3.10)
(3.11)
(3.12)
10 ± 0.5 cm ÷ 5 ± 0.5 cm =
10 cm ± 5% ÷ 5 cm ± 10% = 2 cm ± (5% + 10%)
= 2 cm ± 15%.
(3.13)
(3.14)
(3.15)
Tasks
Core Find the uncertainty in your previous distance measurements by estimation.
Completion Find the uncertainty in your time measurements by finding the average deviation.
You will need to re-start the robot and repeat the measurement a few times to get a reliable
number.
Completion Calculate the uncertainties in the values you found for aa and vmax .
3.5
Robot Tag
NB: Complete either this section or section 3.6.
Now that you have characterised your robot, you are ready to play Robot Tag. The goal is to
intercept a second robot that is travelling at a known (constant) speed and heading, within a
given time. The game is illustrated in Fig. 3.3.
Tasks
Completion Write an equation that determines the angle, θ, required to intercept the target
robot, given the heading of the target robot, r~1 , and the initial distance between the robots,
d~1 . Assume that your robot is starting from rest (v1 = 0 ms−1 ).
Hint: As before, you should break the motion of your robot up into two distinct regions:
the constant acceleration region at the start of motion, and the constant velocity region
that kicks in when the robot is up to speed.
7
θ
target robot
r1
interception
point
d1
θ
your robot
Figure 3.3: Schematic of the Robot Tag game.
Challenge Find the minimum time required to intercept the target robot. As before, assume
the robot is travelling at a constant velocity on a known heading. Your robot is starting
from rest and is a known distance from the target robot when it starts moving.
Challenge Test the equations you derive (and the angle you calculated) by plugging the values
you found for θ, d~1 , r~1 , and the maximum velocity and acceleration of your robot into
the python file tag.py, in the section marked # Problem Variables. Use the
terminal command python tag.py to run a simulation of your robot (in blue) chasing
an escapee robot (in red). The simulation stops either when the two robots collide, or after
a length of time if there is no collision. Take a screen shot of any successful interceptions
and note down the parameters you used to achieve them.
3.6
Circular Motion
NB: Complete either this section or section 3.5.
Load the file ENGR121_Robots_circular_motion_2015.ino onto your robot. This
file will cause one wheel to rotate faster than another. This means that if we leave the robot
running this code for long enough, it will travel in a circle and return to its original position!
Provided we know the width of the robot’s wheelbase, we can find the radius of its path by
comparing the distances travelled by the left and right wheels, as shown in Fig. 3.4.
To get this data connect a Wi-Fi dongle with the same name as your minion robot to your PC
and change to the appropriate serial port in the Arduino IDE. Next, open the serial monitor
and check that the baud rate for the connection is set to 9600. Assuming the minion connects
correctly to the Wi-Fi dongle (a green LED should be blinking slowly on the dongle), the screen
should start to fill with telemetry data sent back by the minion.
8
do
di
w
r
Figure 3.4: Distances travelled by the inner and outer wheels of a robot on a circular path.
Tasks
Completion Use your knowledge of the diameter of the minion’s wheels (60 mm) and pulse
rate of its motion sensors (2000 pulses/revolution) to convert the telemetry data (# pulses)
sent back by the robot to distance values.
Completion Write an equation that relates the distance travelled by the robot’s inner wheel, di ,
to the angle, θ, traversed on a circle of radius, r.
Hint: What is the distance and angle covered in a single, full rotation? How does the
distance scale for different angles?
Completion Next, consider the distance, do , travelled by the outer wheel. The outer wheel
should cover the same angular distance as the inner wheel, but at a slightly larger radius,
as shown in Fig. 3.4. This difference in radii between the inner and outer wheels will be
equal to the width of the robot’s wheelbase, w. Use this information to write an equation
relating do to r, w, and θ.
Challenge Finally, use captured telemetry data and rearrange your equations for di and do to
find values for r and θ. What is the radius of the circle traversed by your robot?
Challenge Working with at least one other person, set your robot in motion and (temporarily)
mark at least three points that the robot traverses on its arced journey.1 Next, use a large
(1 m) ruler and a protractor to find the distances and angles between each neighbouring
pair of points. Make a scale sketch of your measurements in a lab book, and construct the
following lines:
– Draw a line between any pair of points. Repeat for another pair.
– Use a compass and ruler to construct the perpendicular bisectors between your two
pairs of points, as shown in Fig. 3.5.
1
You may like to mark these points by placing items from your pencil case on the floor.
9
Figure 3.5: Method for finding the perpendicular bisector of a line. Screenshot from www.
mathopenref.com/const3pointcircle.html.
– Find the intersection of the perpendicular bisectors and calculate the distance between this point and any of your three original points. This distance is the radius of
the circle traversed by your robot.
How does the radius you calculated based on your manual three point measurement compare to the value you found by analysing your telemetry data?
END OF LAB