-
Notifications
You must be signed in to change notification settings - Fork 29
CMP3103 Week 3
Make sure you keep all your code you develop in the workshops and also note down any commands you used (create a README.md
file for your notes). You will need this again as you go along in this module.
In the lecture, you have been introduced to ways to conduct image processing in Python using OpenCV. In this workshop, you shall learn how to use it practically.
- retrieve images from ROS topics
- convert images into the OpenCV format
- perform image processing operations on the image
- command the robot based on your image processing output
To get you off the ground quickly, all the source code shown in the lecture is available online. In particular, have a look at
-
opencv_intro.py
which shows you how to load an image in OpenCV without ROS and some processing methods. Also look at the official OpenCV Python tutorials to gain a better understanding. Image processing tutorials, colour slicing, finding contours etc. -
opencv_bridge.py
showing you how to use CvBridge (*note this website is for ROS1 but the OpenCV parts are the same for ROS2) to read image from a ROS topic. -
colour_contours.py
to get an idea about colour slicing as introduced in the lecture. Also read about Changing Colour Spaces.
To make sure you have the latest version of the devcontainer, start by pulling the latest version: docker pull lcas.lincoln.ac.uk/lcas/devcontainer/ros2-teaching:2324-devel
. Hopefully, by now you know how to start the devcontainer in VSCode. If you have questions on how to do that, manage your git repository, and start the simulation, make sure you get support during the workshop immediately!
Develop Python code with the following abilities:
- Take the example code fragment
opencv_bridge.py
from the lecture and modify it so you can read from the camera of your turtlebot. - Read images from your robot, display them using OpenCV methods, and try out colour slicing as presented in the lecture to segment a coloured object of your choice. When trying this in simulation, put some nice coloured objects in front of the robot (in Gazebo objects can be added in the
insert
tab and under themodels.gazebosim.org
list at the bottom, this may a few minutes to load all the objects). Find suitable parameters to robustly segment that blob. You may takecolour_contours.py
as a starting point for your implementation. - Use the output from above to then publish
std_msgs/String
messages on aPublisher
that contains information about the outcome of the operation (e.g. print the mean value of the pixel intensities of the resulting image). (Hint: You'll need to create a Publisher with typestd_msgs/String
for this:self.publisher = self.create_publisher(String, '/msgs', 1)
and then publish to it.
Try out the colour chasing robot presented in the lecture. Take the code from colour_chaser.py
you will need to find suitable parameters and colour spaces to segment out relevant colours and make the robot move towards the object you want it to follow. Place new objects and move different objects around in the environment and see if the robot will chase the objects. Feel free to change the simulation environment to your liking!
- Work in pairs (find a partner) and get a robot from the delivery team
- Read Using the real Limo Robot to get started
- Develop Python code that subscribes to the image stream from the robot.
- Publish the output of some image processing as a
std_msgs/String
on a topic named/result_topic
. - Run the colour-chasing robot and understand its code.
Copyright by Lincoln Centre for Autonomous Systems