terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc Aborted (core dumped) adding Collision

asked 2021-11-05 10:19:10 -0500

Hello everyone, I was trying to add a cube to my robot its planning scene by creating a node that will spawn this cube But I always get the same error.

* Loading robot model 'panda'... Ready to take commands for planning group panda_arm. terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc Aborted (core dumped)*

I am using Ros Melodic

int main(int argc, char** argv)
{
  ros::init(argc, argv, "panda_arm_adding_objs");
  ros::NodeHandle nh;
  ros::AsyncSpinner spinner(1);
  spinner.start();

  static const std::string PLANNING_GROUP = "panda_arm";

  moveit::planning_interface::MoveGroupInterface move_group(PLANNING_GROUP);

  moveit::planning_interface::PlanningSceneInterface planning_scene_interface;
  std::vector<moveit_msgs::CollisionObject> collision_object;
  collision_object.resize(1);
  collision_object[0].id = "box1";
  collision_object[0].header.frame_id = move_group.getPlanningFrame();

  shape_msgs::SolidPrimitive primitive;
  primitive.type = primitive.BOX;

  primitive.dimensions.resize(3);
  primitive.dimensions[0] = 0.4;
  primitive.dimensions[1] = 0.1;
  primitive.dimensions[2] = 0.4;

  // Define a pose for the box (specified relative to frame_id)
  geometry_msgs::Pose box_pose;
  box_pose.orientation.w = 1.0;
  box_pose.position.x = 0.4;
  box_pose.position.y = -0.2;
  box_pose.position.z = 1.0;


  collision_object[0].operation = collision_object[0].ADD;;

  planning_scene_interface.applyCollisionObjects(collision_object);
  move_group.attachObject(collision_object[0].id);


  ros::waitForShutdown();

  return 0;
}
edit retag flag offensive close merge delete