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

Assign geometry_msgs::position in one line

asked 2018-02-15 10:55:38 -0500

fabbro gravatar image

HI,

I am struggling with a really easy problem. I declared :

geometry_msgs::Pose pose_msg;

I am trying to assign x y z coordinates in one line instead of doing:

pose_msg.position.x = 0.0;
pose_msg.position.y = 0.0;
pose_msg.position.z = 0.0;

I would like to do something like:

pose_msg.position = (0.0,0.0,0.0)

Sorry if the question has been already asked but for me, it was hard to find an answer online.

Thanks in advance for your help

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-02-15 11:06:59 -0500

gvdhoorn gravatar image

updated 2018-02-15 11:07:29 -0500

With the default messages, this is not supported.

With the merge of ros/gencpp#32 this is now possible (after gencpp version 0.6.0 has been released), but will need custom code.

See wiki/roscpp/Overview/MessagesSerializationAndAdaptingTypes - Customizing generated message headers for C++ for more info on this.

edit flag offensive delete link more

Comments

Great, thanks a lot for your help.

fabbro gravatar image fabbro  ( 2018-02-15 11:12:44 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2018-02-15 10:55:38 -0500

Seen: 422 times

Last updated: Feb 15 '18