← Back to search

[ROS Q&A] 042 - Use different message types

The Construct Robotics Institute 17:24

1,428 views · 7 likes Watch on YouTube ↗

More ROS Learning Resources: https://goo.gl/DuTPtK

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 ;).


---------Want to learn ROS really FAST and master the latest Robotics topics?-----------
::Visit Robot Ignite Academy, the online Academy that teaches you ROS really FAST, from beginner to master, using only a web browser: https://goo.gl/LBT7EN
Robot Ignite Academy is an integrated ROS learning platform which contains a series of online ROS tutorials tied to online simulations, giving you the tools and knowledge to understand and create any ROS based robotics development.

——————Are you a ROS expert and want to develop FAST your next ROS project?-----------

:: Then, use the ROS Development Studio (RDS) for your next project: https://goo.gl/EtFqmE
With the ROS Development Studio, you will be able to:
- Develop ROS programs for robots in a faster way, with an already setup IDE environment that includes autocomplete.
- Test the programs in real time on the provided simulated robots. Use the provided simulations or upload your own. Quickly see the results of your programming.
- Debug using graphical ROS tools.
- Test what you have developed on RDS in the real robot (if you have it :wink:
all of these are using ONLY a web browser without any installation and not limited by any operating system. DEVELOP FOR ROS USING WINDOWS, LINUX OR OSX.

Category (YouTube): Science & Technology

Playback is via YouTube's official embedded player. Data from YouTube; Exumo is not affiliated with YouTube.