Create a msg folder inside session3_pubsub folder
mkdir -p ~/ros_workshop/src/session3_pubsub/msgOpen the folder
cd ~/ros_workshop/src/session3_pubsub/msgCreate a .msg file with desired name. (we will select custom.msg as an example)
code custom.msgInside the file add following lines, then save and close.
string first_name
string last_name
uint8 ageOpen package.xml and add the following lines in the respective sections
<build_depend>message_generation</build_depend>
<exec_depend>message_runtime</exec_depend>Open the CMakeLists.txt and add following lines to respective section,
message_generation to find_package()
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
message_generation
)message_runtime to catkin_package
catkin_package(
...
CATKIN_DEPENDS message_runtime ...
...)uncomment add_message_files section and add custom.msg file
add_message_files(DIRECTORY
msg
FILES
custom.msg
)uncomment generate_messgae() section. It shoul look like this,
generate_messages(
DEPENDENCIES
std_msgs
)Move to the root of workspace and rebuild
cd ~/ros_workshop/catkin buildor
catkin_make