ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

How to add a Time field in a custom message file

asked 2020-09-28 11:35:38 -0500

I am trying to create a custom message type using a .msg file in ROS2. The message generation works properly for basic fields such as int8, float32, etc.

However I am finding difficulties adding a Time field.

  • Which packages should I import in package.xml?
  • What specific stuff should I do in CMakeLists.txt?

I noticed that the Time message should be located in the builtin_interfaces. I configure CMakeLists.txt and package.xml file to consider that but it does not work.

find_package(ament_cmake REQUIRED)
find_package(std_msgs REQUIRED)
find_package(builtin_interfaces REQUIRED)
find_package(rosidl_default_generators REQUIRED)

DEPENDENCIES builtin_interfaces)




Error: /home/geus/Desktop/ros_ws/build/my_package_msgs/rosidl_generator_cpp/my_package_msgs/msg/detail/my_custom_message__struct.hpp:19:10: fatal error: my_package_msgs/msg/detail/time__struct.hpp: No such file or directory 19 | #include "my_package_msgs/msg/detail/time__struct.hpp" compilation terminated.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2020-09-28 11:39:13 -0500

Found. You have to add the package prefix into the .msg Time field. Below, It is shown an example of .msg file chunk:

builtin_interfaces/Time stamp
int8 value1
edit flag offensive delete link more

Question Tools



Asked: 2020-09-28 11:35:38 -0500

Seen: 1,509 times

Last updated: Sep 28 '20