Custom ROS Message for Line Params¶
All of the following instructions are based on this guide.
First create the message file using the following commands:
cd ~/bwsi-uav/catkin_ws/src/aero_control mkdir msg touch msg/Line.msg gedit msg/Line.msg
In the message file, add:
float64 x float64 y float64 vx float64 vy
This will enable us to transmit a
P = <x, y> + t * <vx, vy> line parameterization. (
t can be any real number and
P is a point on the line)
Each line has the sub-message type followed by the name of the variable.
Building the message with catkin¶
We need to make sure that the msg files are turned into source code for C++, Python, and other languages:
aero_control/package.xml, and make sure these two lines are in it and uncommented:
aero_control/CMakeLists.txt in your favorite text editor (rosed from the previous tutorial is a good option).
Add the message_generation dependency to the find_package call which already exists in your CMakeLists.txt so that you can generate messages. You can do this by simply adding message_generation to the list of COMPONENTS such that it looks like this:
# Do not just add this to your CMakeLists.txt, modify the existing text to add message_generation before the closing parenthesis find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs message_generation )
Also make sure you export the message runtime dependency.
catkin_package( ... CATKIN_DEPENDS message_runtime ... ...)
Find the following block of code:
# add_message_files( # FILES # Message1.msg # Message2.msg # )
Uncomment it by removing the # symbols and then replace the stand in Message*.msg files with your .msg file, such that it looks like this:
add_message_files( FILES Line.msg )
Now we must ensure the generate_messages() function is called.
For ROS Hydro and later, you need to uncomment these lines:
# generate_messages( # DEPENDENCIES # std_msgs # )
so it looks like:
generate_messages( DEPENDENCIES std_msgs )
At the end, run:
cd ~/bwsi-uav/catkin_ws/ catkin_make source devel/setup.bash
To verify that the message was built sucessfully, run
rosmsg show aero_control/Line
listener.py to use custom messages¶
Fill out the
TODO sections in
You will probabally find the following guide/example code helpful: link
Dont worry about making any files exicutable since we will be using launchfiles
To run these two files together, use
roslaunch launch/talk_listen.launch in the
Fill out the TODO sections in
line_tracker/src/detector.py, you should be able to reuse code from
line_tracker/src/talker.py, your line paramaterization notebook, and this example code.
To run your code, use
roslaunch aero_control detect_listen.launch in the