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

std_msgs types and 'normal' type

asked 2018-12-11 02:41:46 -0500

gab27 gravatar image

updated 2018-12-11 02:42:17 -0500

Hi

I want to display a variable on a topic. Therefore I need to transform my variable from an volatile unsigned long to an std_msgs type (for example UInt64). This gives following error:

no match for 'operator=' (operand types are 'std_msgs::UInt64' and 'volatile long unsigned int')

How can i convert this long to a std_msgs?

Thanks

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2018-12-11 02:58:51 -0500

Delb gravatar image

Your code probably looks like :

std_msgs::UInt64 int_a;
volatile long unsigned int_b;
int_a = int_b;

But if you look at the message definition you'll see that there is a field data, so you have to use it to set the message value :

std_msgs::UInt64 int_a;
volatile long unsigned int int_b;
int_a.data = int_b;
edit flag offensive delete link more

Comments

beat me by 20 seconds ;-)

mgruhler gravatar image mgruhler  ( 2018-12-11 02:59:55 -0500 )edit

We really need the "someone is typing.." feature ;)

Delb gravatar image Delb  ( 2018-12-11 03:01:31 -0500 )edit

agreed :-D

mgruhler gravatar image mgruhler  ( 2018-12-11 03:02:05 -0500 )edit
0

answered 2018-12-11 02:59:11 -0500

mgruhler gravatar image

updated 2018-12-11 03:01:23 -0500

Check the definition of std_msgs::UInt64. You are trying to write the value to the message, which is of type std_msgs::UInt64 and contains a field data of type uint64.

Thus, correct would be

std_msgs::UInt64 your_msg;
your_msg.data = your_volatile_unsigned_int;
edit flag offensive delete link more

Comments

thanks gab

gab27 gravatar image gab27  ( 2018-12-11 03:02:23 -0500 )edit

if this solved your problem, please mark the answer from @Delb below as correct (he was faster ;-) ) by clicking on the check mark next to it.

mgruhler gravatar image mgruhler  ( 2018-12-11 03:28:35 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2018-12-11 02:41:46 -0500

Seen: 751 times

Last updated: Dec 11 '18