Skip to content

Latest commit

 

History

History
88 lines (68 loc) · 1.29 KB

custom_msg.md

File metadata and controls

88 lines (68 loc) · 1.29 KB

Custom Message Creation

Messages

Create a msg folder inside session3_pubsub folder

mkdir -p ~/ros_workspace/src/session3_pubsub/msg

Open the folder

cd ~/ros_workspace/src/session3_pubsub/msg

Create a .msg file with desired name. (we will select custom.msg as an example)

code custom.msg

Inside the file add following lines, then save and close.

string first_name
string last_name
uint8 age

Open 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 build

or

catkin_make