ROS Q&A | Use different message types

Written by Miguel Angel

16/10/2017

 

Learn how to detect the message type and create multiple input message type functions: https://answers.ros.org/question/60281/how-to-get-massage-type-in-rospy/

Q:How to get massage type in rospy?
A:The cleanest way is to use: `msg._type`

Here I leave an example of two susbcribers in ros using the same callback. The callback called **common_callback** will process the messages differently depending on their type. In this case it processes type LaserScan or Odometry, but this can be used for anything really because the output of the `msg._type` is `sensor_msgs/LaserScan`or `nav_msgs/Odometry`. So its easy too work with that.

example code in this the ROSAnswer: https://answers.ros.org/question/60281/how-to-get-massage-type-in-rospy/

Hope this helps ;).

Topics:
Masterclass 2023 batch2 blog banner

Check Out These Related Posts

129. ros2ai

129. ros2ai

I would like to dedicate this episode to all the ROS Developers who believe that ChatGPT or...

read more

0 Comments

Submit a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Pin It on Pinterest

Share This