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

Creating a CollisionObject from a mesh in Hydro

asked 2014-04-02 17:27:43 -0600

St3am gravatar image

updated 2016-10-24 09:00:36 -0600

ngrennan gravatar image

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?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
4

answered 2014-04-02 17:50:47 -0600

St3am gravatar image

updated 2014-04-02 17:52:06 -0600

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

edit flag offensive delete link more

Comments

2

I had to do

shapes::constructMsgFromShape(navstar_shape,navstar_mesh_msg);

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

Simon Schmeisser gravatar image Simon Schmeisser  ( 2015-06-11 12:34:42 -0600 )edit

The includes for these commands are currently here.

fvd gravatar image fvd  ( 2018-09-09 03:51:05 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2014-04-02 17:27:43 -0600

Seen: 2,008 times

Last updated: Apr 02 '14