Task 1: Velocity Control
Develop a working ROS application to making a real TurtleBot3 Waffle follow a prescribed motion profile, whilst printing key information to the terminal.
Assignment #1 Checkpoints
The following parts of The ROS 2 Course will support your work on this task:
- Part 1: in full.
- Part 2: up to (and including) Exercise 5.
- Part 3: Exercise 1.
Summary¶
The main objective of this task is to create a ROS node (or multiple nodes) that make your robot follow a figure-of-eight pattern on the robot arena floor. The figure-of-eight trajectory should be generated by following two loops, both 1 meter in diameter, as shown below.
The Robot Arena will be set up as follows for this task:
Whilst doing this, you will also need to present robot odometry data to the terminal at regular intervals (see below for the specifics). Your node must output this data as ROS 2 Log Messages with INFO severity, i.e. using get_logger().info() calls from within one of your nodes. Log messaging is used in lots of the exercises and example code throughout Assignment #1, and so you should refer back to this for guidance if you need it.
Additionally, for this task, log messages must be formatted in a particular way, so you might want to have a look at the documentation on Python String Formatting, and read the details below thoroughly so that you know what is expected!
Details¶
- "Loop 1": The robot must start by moving anti-clockwise, following a circular motion path of 1 m diameter around the red beacon as shown above.
- "Loop 2": Once the robot has returned to the starting point, it must then turn clockwise to follow a second circular path, again of 1 m diameter, this time around the blue beacon.
- After Loop 2 the robot must stop on the start / finish line (10 cm, as denoted by the white tape lines on the floor).
-
The velocity of the robot should be defined to ensure that the whole sequence takes 60 seconds to complete (5 seconds).
Note: The timer will start as soon as the robot starts moving.
-
The robot's real-time pose should be printed to the terminal throughout, where messages should be of the following format (exactly):
Where
{x},{y}and{yaw}should be replaced with the correct real-time odometry data as follows:{x}: the robot's linear position in the X axis, quoted in meters to two decimal places.{y}: the robot's linear position in the Y axis, quoted in meters to two decimal places.{yaw}: the robot's orientation about the Z axis, quoted in degrees to one decimal place.
The data should be quoted relative to its starting position at the beginning of the task, e.g. at the start of the task (before the robot has moved) the terminal messages should read:
These message should be printed to the terminal at a rate of 1Hz. It doesn't matter if the messages continue to be printed to the terminal after the robot has stopped (i.e. after the figure-of-eight has been completed).
Important
You should use
get_logger().info()method calls within your node to print these terminal messages.
A note on Odometry¶
When the robot is placed in the arena at the start of the task its odometry may not necessarily read zero, so you will need to compensate for this. You'll therefore need to grab the robot pose from the /odom topic before your robot starts moving, and then use that as the zero-reference to convert all the subsequent odometry readings that you obtain throughout the task.
Odometry and keeping track of the robot's pose is discussed in detail in Assignment #1 Part 2.
Executing Your Code¶
When assessing your code for this task, the teaching team will use the following command to execute all the necessary functionality from within your package:
... where XX will be replaced with your team number.
As such, your ROS 2 Node(s) for Task 1 MUST be executable via a launch file, and this launch file MUST be called task1.launch.py.
Note
ROS will already be running on the robot before we attempt to execute your launch file, and a Zenoh Session will be running on the laptop, to allow your nodes (running on the laptop) to communicate with it. You don't need to include any of this in your task1.launch.py launch description.
Marking¶
This task will be assessed by the teaching team as part of Part A (i.e. along with Task 2). This will be assessed during the Easter Holiday period, with feedback returned to you before the semester resumes.
There are 20 marks available for this task in total, summarised as follows:
| Criteria | Marks | Details |
|---|---|---|
| A: The Motion Path | 10/20 | How closely the real robot follows a true figure-of-eight path in the robot arena, based on the criteria table below. |
| B: Terminal Messages | 10/20 | The correct formatting of your odometry messages, and the validity of the data that is presented in the terminal as the robot performs the task, based on the criteria table below. |
Criterion A: The Motion Path¶
Marks: 10/20
| Criteria | Details | Marks |
|---|---|---|
| A1: Direction of travel | The robot must move anticlockwise for the first loop ("Loop 1") and then clockwise for the second ("Loop 2"). | 2 |
| A2: Loop 1 | The loop must be 1 m in diameter, centred about the red beacon. | 2 |
| A3: Loop 2 | The loop must be 1 m in diameter, centred about the blue beacon. | 2 |
| A4: Stopping | Once the robot completes its figure of eight, it must stop with both wheels within 10 cm of the start line (as denoted by white tape lines on the floor). | 2 |
| A5: Timing | The robot must complete the full figure of eight and stop in 55-65 seconds. | 2 |
Criterion B: Terminal Messages¶
Marks: 10/20
| Criteria | Details | Marks |
|---|---|---|
| B1: Rate | Messages should be printed to the terminal at a rate of 1 Hz. | 2 |
| B2: Format | The messages printed to the terminal should be formatted exactly as detailed above, and must be presented as ROS 2 Log Messages with INFO severity (i.e. using get_logger().info() method calls). |
2 |
| B3: Data | Each message value (x, y and yaw) should be plausible, that is: they represent the actual pose of the robot at all points throughout the figure-of-eight, based on all readings being set to zero at the start/finish line (as illustrated above). In addition, each value must be quoted in the correct units (meters / degrees, as appropriate). |
6 |
Simulation Resources¶
You might find it helpful to develop the core functionality for this task in simulation before getting things running on the real robot.
Real World vs. Sim
There is no substitute for real-world testing!
While you might develop a ROS application that works perfectly in simulation, this doesn't mean that it will work equally well in the real world.
Ultimately, this task (and indeed all the other Assignment #2 programming tasks) will be assessed on real robots, so make the most of the lab sessions and test things out on the real robots thoroughly.
As shown above, for the assessment there will be cylindrical beacons placed at the centre of each of the figure-of-eight loops which the robot will need to move around as it completes the task. We have therefore also created a simulation environment that is representative of the real world environment. This is available in the tuos_task_sims package, which is part of the tuos_ros Course Repo. The instructions for downloading and installing this within your own local ROS installation are available here.
If you've already installed this (as part of Assignment #1 perhaps), then it's worth making sure that you have the most up-to-date version (as discussed here).
Once you've done all this, then you should be able to launch the simulation using ros2 launch as follows:
Note
Loop markers are illustrative, there won't be any on the real robot arena floor during the assessment.


