[SOLVED] Number of primitive shapes does not match number of poses in collision object message
Hi, i would like to add a STL collision object. I have similar code and it works perfectly with primitive box.
I followed https://answers.ros.org/question/2311...
but it still writes me
[ERROR] [1594897964.204647300]: Number of primitive shapes does not match number of poses in collision object message
And i cannot see an *.STL file in RViz.
ROS Melodic, windows 10 - Ubuntu terminal, Xming.
Any adwices what i'm doing wrong? Thank you. (Apologize for bad english).
uname -a
Linux ### 4.4.0-18362-Microsoft #836-Microsoft Mon May 05 16:04:00 PST 2020 x86_64 x86_64 x86_64 GNU/Linux
float addMeshCollObj(float fX, float fY, float fZ, string sName){
static const std::string PLANNING_GROUP = "arm";
moveit::planning_interface::MoveGroupInterface move_group(PLANNING_GROUP);
moveit::planning_interface::PlanningSceneInterface planning_scene_interface;
const robot_state::JointModelGroup* joint_model_group =move_group.getCurrentState()>getJointModelGroup(PLANNING_GROUP);
moveit_msgs::CollisionObject collision_object;
collision_object.header.frame_id = move_group.getPlanningFrame();
collision_object.id = sName;
Vector3d b(0.001, 0.001, 0.001);
shapes::Mesh* m = shapes::createMeshFromResource("package://robot_rx160/meshes/gtbx/Ramecek.STL",b);
shape_msgs::Mesh mesh;
shapes::ShapeMsg mesh_msg;
shapes::constructMsgFromShape(m, mesh_msg);
mesh = boost::get<shape_msgs::Mesh>(mesh_msg);
collision_object.meshes.resize(1);
collision_object.mesh_poses.resize(1);
collision_object.meshes[0] = mesh;
collision_object.mesh_poses[0].position.x= fX;
collision_object.mesh_poses[0].position.y= fY;
collision_object.mesh_poses[0].position.z= fZ;
collision_object.mesh_poses[0].orientation.w=0.0;
collision_object.mesh_poses[0].orientation.x=0.0;
collision_object.mesh_poses[0].orientation.y=0.0;
collision_object.mesh_poses[0].orientation.z=0.0;
collision_object.meshes.push_back(mesh);
collision_object.mesh_poses.push_back(collision_object.mesh_poses[0]);
collision_object.operation = collision_object.ADD;
std::vector<moveit_msgs::CollisionObject> collision_objects;
collision_objects.push_back(collision_object);
ROS_INFO("Add an object \"%s\" into the world", sName.c_str());
planning_scene_interface.addCollisionObjects(collision_objects);
sleep(1.0);
return 0.0;
}