Notes about an ROS Topic. This will describe a basic publisher and subscriber topic. Where to find the list of topics and the list of possible messages for a topic. How to install a new message for a topic.
|
|
Publisher
Publish messages into a topic
Publish in Code
|
|
Publish on Commandline
Manually publish in command line
|
|
rostopic pub <topic_name> <message_type> <value>
You can use the ‘double tab’ to autofil the value.
Subscriber
Read messages from a topic
Subscribe in Code
|
|
Determine the message type of the topic
|
|
This will return back the data type, publishers and subscribers for the given topic.
Create a Custom Data Type
Create a directory in the package
|
|
Create the Data type
Create a file within the new directory for the new data type Call it Vector.msg. Add the following in to the file
|
|
Edit CMakeLists.txt
Edit CMakeLists.txt in the package to find the new data type. Look for find_package(catkin REQUIRED COMPONENTS …)
|
|
Again within CMakeLists.txt search for catkin_package(…) and uncomment the following line and append it if it contains other things passed CAKTIN_DEPENDS.
|
|
Again within CMakeLists.txt search for add_message_files(…) and uncomment it and add the new messages.
|
|
Again within CMakeLists.txt search for generate_messages(…) and uncomment it.
|
|
Save the CMakeLists.txt file.
Edit package.xml
Edit package.xml in the package to find our new data type. Find build_depend…
|
|
Compile Code
Go to your catkin workspace and run catkin_make
|
|
Verify Data Type Exist
|
|
Stop Topic
|
|
All the details for this can be found in this video.