Robotics StackExchange | Archived questions

ros message type conversion to c++ type

Hi

Simply put my question.

I have a myself defined message locally using the date type uint32

IDMessage.msg

uint32 id

and with the auto-generated c++ code I can have a message object defined in my source code, just like IDMessage msg; Now I want to fetch some value from the parameter server and give it to the id of the msg object, something like

int id_int;

ros::NodeHandle::getParam("ID", id_int);

msg.id = id_int;

The problem is the getParam can only take in parameter types like int, so I can not define a uint32 id_uint32 and get the value from the server.

So is there any way can solve this conversion msg.id = id_int;, which is from int to uint32? Should I do some cast?

Asked by dalishi on 2014-05-29 21:09:48 UTC

Comments

What's wrong with casting to an unsigned int?

Asked by sterlingm on 2014-05-30 08:58:14 UTC

Answers