The instructions for creating the custom interface “Age” (Section 3.5, point 2) are inconsistent with the expected result of the command ros2 interface show custom_interfaces/msg/Age (last point before beginning of Section 3.6):
Instructions for creating custom interface “Age”
- The Age.msg file must contain the following:
Age.msg
uint8 years
uint8 months
uint8 days
Expected result:
"If the structure of the age message appears, it means that your message has been created successfully and is ready to be used in your ROS2 programs.
Execute in Shell #1
ros2 interface show custom_interfaces/msg/Age
Shell #1 Output
int32 year
int32 month
int32 day"
Incidentally, the use of uint8 is incompatible with the suggested code for “example36.py”:
def on_shutdown(self):
self.age.year = 2021
self.age.month = 5
self.age.day = 21
self.get_logger().info(‘Date this program was made : %d’ %
self.age.day + ‘/%d’ % self.age.month + ‘/%d’ % self.age.year)
2021 cannot be represented in uint8. Implementing Age.msg with uint8 will result in an error in the shell when running example36:
self.age.years = 2021
[example36-1] File “/home/user/ros2_ws/install/custom_interfaces/lib/python3.8/site-packages/custom_interfaces/msg/_age.py”, line 134, inyears
[example36-1] assert value >= 0 and value < 256,
[example36-1] AssertionError: The ‘years’ field must be an unsigned integer in [0, 255]