-
Notifications
You must be signed in to change notification settings - Fork 30
CMP3103 Week 2
Make sure you have fully understood and completed the CMP3103 Week 1 tasks! All steps to get started with the virtual environment are described in Using the Docker Image, and the steps are also in the Panopto Workshop recording of last week. A quick reminder on how to start the simulation:
- start the simulation with this command:
ros2 launch uol_tidybot tidybot.launch.py - start a simple keyboard teleoperator (in another terminal!):
ros2 run teleop_twist_keyboard teleop_twist_keyboard
-
Start up your simulation
-
Run
ros2 topic listand consider what you see. Also, tryros2 topic echo /odomand move in simulation using the teleop from last week. What do you see? -
Use
ros2 topic pubto make the robot move! Try to develop the following command using the[Tab]key for auto-completion (do not directly copy the text below, as it will not work, make sure you read some of the documentation on ros2 topic commands or search this up yourself!). E.g. typeros2 to [Tab] pub [Tab] /cm [Tab] geo [Tab] "li [Tab]and then use the left and right arrow keys to move the cursor to eventually get to the following:ros2 topic pub /cmd_vel geometry_msgs/Twist "linear: x: 0.0 y: 0.0 z: 0.0 angular: x: 0.0 y: 0.0 z: 0.5"If it works, you may see you robot moving, but you might also see it "stuttering". Figure out why this might be and how you could make it go smoothly. Remember
ros2 topic pub -hshows the command documentation. (You can stop this command by hitting[Ctrl]-Con your keyboard!) -
Watch your Limo robot move. Reflect what is happening when you change some of the vales. What do they mean? What are the unit of theses values you think?
-
(You may try this on a real robot CAREFULLY!)
-
In the end, try to make it go around in a circle (with about 0.5m radius) smoothly by modifying the above command.
-
Read this tutorial on how to create a publisher in python. Remember that we want to publish a
geometry_msgs/Twistto/cmd_vellike we did above! -
Time to code our first Python program using ROS2: The goal is (again) to have the robot first go around in a circle of about 0.5m radius, this time from the Python program!
- You just run the simulation as before, and then run your Python code directly in VS Code or from the command line.
- optional: If you are keen to learn already more about ROS2, you can create a proper ROS2 package, read this tutorial.
IMPORTANT: It is perfectly okay NOT to create a proper ROS package for now and focus on a single Python script and simply executing it. That's the beauty of an interpreted language like Python that you don't need to compile it. Start writing a script somewhere in your workspace's
srcfolder to keep things simple, unless you want to dive into creating a proper Python package at this stage already. -
Now consider how you could implement a behaviour that takes the robot forward if there is more than 50cm space in front of it but makes it turn to the left, if there isn’t enough space. This requires you to interpret the data from, e.g., the laser scanner and modify the Twist you publish depending on the data in the Laser scan.
-
optional: When you have accomplished this, the next challenge for you is to make it go in the shape of a square of
1mlength on each side.
Hopefully you'll create a Subscriber in the previous task. Now extend this code to also create a Subscriber to receive input from the /scan topic and print our the smallest distance found on the screen.
Once that works you are encouraged to put this together to make a simple roaming robot that usues the information from the laser scanner to actively avoid obstacles. Find out how you can structure your code based on the examples given to come up with a practical control strategy that implements an obstacle-avoiding, free roaming robot.
What to send to the robot?*
A Twist message has two parts that are important:
-
Twist.linear: this has x,y,z components for which you can specify the speed in m/s. Please don't go beyond 0.6 -
Twist.angular: this also has x,y,z components and determines how quick the robot should rotate around one of the axes in radians/s. Please don't go beyond PI. To determine which axis you want to move along and turn around, please have a look at the picture below (The "right hand rule of robotics convention"):
Red: x, green: y, blue: z, By convention in a robot, x is always pointing forward, and z upwards.
Copyright by Lincoln Centre for Autonomous Systems
-
CMP3103
- Using the Docker Image
- Week 1
- Week 2
- Week 3
- Week 4
- Week 5: Start working towards Coursework 2425
- Week 6: Enhancement Week, no timetabled sessions
- Week 7 and beyond
- Using the real Limo Robot