Professional Documents
Culture Documents
Software
Dr Rob Wortham
#
#
This message also can represent a fixed-distance (binary) ranger. This
sensor will have min_range===max_range===distance of detection.
Compact Message Definition:
# These sensors follow REP 117 and will output -Inf if the object is detected
# and +Inf if the object is outside of the detection range.
uint8 ULTRASOUND=0
uint8 INFRARED=1
Header header # timestamp in the header is the time the ranger
# returned the distance reading
http://wiki.ros.org/msg
An Example
File name, put this file in
{package_directory}/msg Complex.msg
float32 real
float32 imaginary
See: http://wiki.ros.org/msg
1. package.xml - Tell ROS about dependencies for this package, specifically that we are defining our own message types.
• build_depend – dependencies when code is built i.e. what does catkin need to be able to build the package?
• exec_depend – dependencies when code is executed i.e. what must be present in the package, or externally within ROS
• build_export_depend – advanced use, to build libraries (.so) from your ROS code. Not needed for simple ROS nodes.
2. CMakeLists.txt - Tell the catkin build system to generate code to represent, marshal and un-marshal the message.
This requires several changes within CMakeLists.txt – see next slide
O’Reilly Ch3 P41
22/01/2024 EE50237 Robotics Software - Lecture 4b 7
Defining and Using ROS Messages – CMakeLists.txt
Tell catkin to look for message find_package(catkin REQUIRED COMPONENTS
generation files (*.msg) roscpp
rospy
std_msgs
Tell catkin that at runtime we will be message_generation
using our own messages. There will be )
other things in this section catkin_package(
CATKIN_DEPENDS message_runtime
)
Tell catkin which message files to add_message_files(
compile FILES
Complex.msg
)
Tell catkin about the dependency on generate_messages(
std_msgs DEPENDENCIES
std_msgs
)
pub.publish(msg)
rate.sleep()
<launch>
<node name="talker" pkg="basics" type="message_publisher.py" />
<node name="listener" pkg="basics" type="message_subscriber.py"
output="screen"/>
</launch>
• Your assessment must include a launch file to launch all the ROS components needed
• You must start your robot with a single command -> launch from a launch file
Questions?
Moodle!