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

How do you extract multiple variables from a message

asked 2019-05-10 03:52:23 -0600

RobotsInDisguise gravatar image

Hey Everyone, I am completely new to ROS. I have a topic called Y that has a message named X containing several variables coming from an external source. The message file looks like:

Header header 
float64 a
uint8 b

How do I read/subscribe to this topic and store both a and b in separate variables? I don't mind a pythonic or a C++ solution to this issue

edit retag flag offensive close merge delete

Comments

1

Just making sure: have you completed the introductory tutorials?

gvdhoorn gravatar image gvdhoorn  ( 2019-05-10 08:52:30 -0600 )edit

I am halfway through the tutorials, Almost done with the beginner ones. I have reached this tutorial

RobotsInDisguise gravatar image RobotsInDisguise  ( 2019-05-12 22:53:00 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-05-13 04:33:40 -0600

Veera Ragav gravatar image

updated 2019-05-13 14:24:38 -0600

jayess gravatar image
  1. Create an object of the ROS Msg/Srv.
  2. Use the dot operator.

Example:

#include "std_msgs/String.h"
std_msgs::String msg;
msg.data = "Hello World";
edit flag offensive delete link more

Question Tools

Stats

Asked: 2019-05-10 03:52:23 -0600

Seen: 862 times

Last updated: May 13 '19