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

Problem loading Mesh with createMeshFromResource

asked 2014-06-03 18:27:21 -0500

Fran Marquez gravatar image

updated 2014-06-09 14:12:18 -0500

gvdhoorn gravatar image

Hi everyone,

I get the warning "Mesh definition is empty" when I run this code, Is there any problem? I have tried with a lot of .dae and .stl files, but the result is the same.

moveit_msgs::CollisionObject co;
shapes::Mesh* m = shapes::createMeshFromResource("file://...");
shape_msgs::Mesh co_mesh;
shapes::ShapeMsg co_mesh_msg = co_mesh;
shapes::constructMsgFromShape(m,co_mesh_msg);
co.meshes.resize(1);
co.meshes[0] = co_mesh;
co.mesh_poses.resize(1);
co.mesh_poses[0].position.x = 1.0;
co.mesh_poses[0].position.y = 1.0;
co.mesh_poses[0].position.z = 0.0;
co.mesh_poses[0].orientation.w= 1.0;
co.mesh_poses[0].orientation.x= 0.0;
co.mesh_poses[0].orientation.y= 0.0;
co.mesh_poses[0].orientation.z= 0.0;
pub_co.publish(co);

Thanks for your help

Best

edit retag flag offensive close merge delete

Comments

Hi! I tried to compile your code. But I get the error:

error: ‘pub_co’ was not declared in this scope pub_co.publish(co);

Could you help me out here? Do I need to implement a some header I forgot? Thanks

bluefish gravatar image bluefish  ( 2015-03-22 04:23:57 -0500 )edit

1 Answer

Sort by » oldest newest most voted
2

answered 2014-06-09 12:37:08 -0500

yvk gravatar image

The first 6 lines of your code should be:

moveit_msgs::CollisionObject co;
shapes::Mesh* m = shapes::createMeshFromResource("file://...");
shape_msgs::Mesh co_mesh;
shapes::ShapeMsg co_mesh_msg;
shapes::constructMsgFromShape(m,co_mesh_msg);
co_mesh = boost::get<shape_msgs::Mesh>(co_mesh_msg);

I had the same problem when I followed the buggy response in this topic: http://answers.ros.org/question/14788...

edit flag offensive delete link more

Comments

Thanks! That work fine!

Fran Marquez gravatar image Fran Marquez  ( 2014-06-10 08:00:01 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-06-03 18:27:21 -0500

Seen: 2,274 times

Last updated: Jun 09 '14