0
$\begingroup$

Rosanswers logo

I'm trying to create create a collision object from a mesh resource and am having trouble understanding how to pass an enumerated type to a message constructor:

const shapes::Mesh* navstar_shape = shapes::createMeshFromResource("package://altius_arm/meshes/NAVSTAR_GPS_Satellite.dae");
shape_msgs::Mesh navstar_mesh;
shapes::constructMsgFromShape(navstar_shape,navstar_mesh);
navstar_collision_object.meshes[0] = navstar_mesh;

I get the following compiler error:

/home/peter/ros/altius_ws/src/altius_arm/src/servo_capture.cpp: In constructor ‘ServoCapture::ServoCapture()’:
/home/peter/ros/altius_ws/src/altius_arm/src/servo_capture.cpp:77:61: error: invalid initialization of reference of type ‘shapes::ShapeMsg& {aka boost::variant<shape_msgs::SolidPrimitive_<std::allocator<void> >, shape_msgs::Mesh_<std::allocator<void> >, shape_msgs::Plane_<std::allocator<void> > >&}’ from expression of type ‘shape_msgs::Mesh’
/opt/ros/hydro/include/geometric_shapes/shape_operations.h:62:6: error: in passing argument 2 of ‘bool shapes::constructMsgFromShape(const shapes::Shape*, shapes::ShapeMsg&)’

I thought constructMsgFromShape was asking for the message object by reference, but it didn't work so I tried passing it by address which at least gets the compiler to realize that I'm passing the right typedef but gives a similar error. Does anyone have any idea what I'm doing wrong?


Originally posted by St3am on ROS Answers with karma: 170 on 2014-04-02

Post score: 3

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

shapes::Mesh* navstar_shape = shapes::createMeshFromResource("package://altius_arm/meshes/NAVSTAR_GPS_Satellite.dae");
shape_msgs::Mesh navstar_mesh;
shapes::ShapeMsg navstar_mesh_msg = navstar_mesh;
shapes::constructMsgFromShape(navstar_shape,navstar_mesh_msg);
navstar_collision_object.meshes[0] = navstar_mesh;
navstar_collision_object.mesh_poses[0] = navstar_pose;
navstar_collision_object_topic = node.advertise<moveit_msgs::CollisionObject>("collision_object",0);

Using a templated typedef solves it, props to Nandan Banerjee


Originally posted by St3am with karma: 170 on 2014-04-02

This answer was ACCEPTED on the original site

Post score: 4


Original comments

Comment by Simon Schmeisser on 2015-06-11:
I had to do

shapes::constructMsgFromShape(navstar_shape,navstar_mesh_msg);

navstar_mesh = boost::get<shape_msgs::Mesh>(navstar_mesh_msg);

Comment by fvd on 2018-09-09:
The includes for these commands are currently here.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.