Ask Your Question

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


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?


edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

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_b;
edit flag offensive delete link more


beat me by 20 seconds ;-)

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

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

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

agreed :-D

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

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_volatile_unsigned_int;
edit flag offensive delete link more


thanks gab

gab27 gravatar imagegab27 ( 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 imagemgruhler ( 2018-12-11 03:28:35 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


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

Seen: 56 times

Last updated: Dec 11 '18