MoveIt Attach Object Error
Here is my node to add an object and attach it to the robot :
#include <moveit/move_group_interface/move_group.h>
#include <moveit/planning_scene_interface/planning_scene_interface.h>
#include <geometric_shapes/shape_operations.h>
using namespace Eigen;
int main(int argc, char **argv)
{
ros::init(argc, argv, "add_workpiece_wall");
ros::NodeHandle nh;
ros::AsyncSpinner spin(1);
spin.start();
moveit::planning_interface::PlanningSceneInterface current_scene;
sleep(2.0);
Vector3d b(0.001, 0.001, 0.001);
moveit_msgs::CollisionObject co;
co.id = "workpiece_wall";
shapes::Mesh* m = shapes::createMeshFromResource("package://mitsubishi_rv6sd_support/meshes/workpiece_wall.stl",b);
ROS_INFO("Workpiece Wall mesh loaded");
shape_msgs::Mesh mesh;
shapes::ShapeMsg mesh_msg;
shapes::constructMsgFromShape(m, mesh_msg);
mesh = boost::get<shape_msgs::Mesh>(mesh_msg);
co.meshes.resize(1);
co.mesh_poses.resize(1);
co.meshes[0] = mesh;
co.header.frame_id = "base_link";
co.mesh_poses[0].position.x = 0.560651;
co.mesh_poses[0].position.y = 0.579113;
co.mesh_poses[0].position.z = 0.0;
co.mesh_poses[0].orientation.w= 0.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;
co.meshes.push_back(mesh);
co.mesh_poses.push_back(co.mesh_poses[0]);
co.operation = co.ADD;
std::vector<moveit_msgs::CollisionObject> abc;
abc.push_back(co);
ROS_INFO("Workpiece Wall added into the world");
current_scene.addCollisionObjects(abc);
sleep(5.0);
moveit::planning_interface::MoveGroup g("arm");
ROS_INFO("Attach Workpiece Wall to the robot");
g.attachObject(co.id);
// Sleep to give Rviz time to show the object attached (different color).
sleep(4.0);
ros::shutdown();
return 0;
}
And the error I'm getting is this:
terminate called after throwing an instance of 'std::runtime_error'
what(): No Trajectory execution capability available.
[add_workpiece_wall-7] process has died [pid 47204, exit code -6, cmd /home/sbr/mitsubishi/devel/lib/mitsubishi_rv6sd_support/add_workpiece_wall __name:=add_workpiece_wall __log:=/home/sbr/.ros/log/d1c6e840-9ac0-11e6-ba06-480fcf447f3c/add_workpiece_wall-7.log].
log file: /home/sbr/.ros/log/d1c6e840-9ac0-11e6-ba06-480fcf447f3c/add_workpiece_wall-7*.log
From my previous question it is somewhat clear that the error is only because of these lines :
moveit::planning_interface::MoveGroup g("arm");
ROS_INFO("Attach Workpiece Wall to the robot");
g.attachObject(co.id);
// Sleep to give Rviz time to show the object attached (different color).
sleep(4.0);
Isn't this the same question as MoveIt Attach Object std::runtime_error?
yes, but I had deleted that question before posting this one.