Hello everyone,
i am currently working on a motion planning algorithm for a fixed base manipulator. Currently i am encountering some problems
with the collision checking procedure of MoveIt. The collision object is correctly added to the planning scene by the following code:
ps_obj_pub_ = nh_.advertise<moveit_msgs::PlanningScene>("planning_scene", 1);
ros::WallDuration sleep_t(0.5);
sleep_t.sleep();
moveit_msgs::CollisionObject coll_object;
coll_object.header.frame_id = "/lbr_0_link"; //"/lbr_0_link = base frame of the manipulator
coll_object.header.stamp = ros::Time::now();
coll_object.id = "box";
geometry_msgs::Pose pose;
pose.position.x = 0.0;
pose.position.y = -0.2;
pose.position.z = 0.6;
pose.orientation.w = 1.0;
shape_msgs::SolidPrimitive primitive;
primitive.type = primitive.BOX;
primitive.dimensions.resize(3);
primitive.dimensions[0] = 1.5; //X dim
primitive.dimensions[1] = 0.1; //Y dim
primitive.dimensions[2] = 0.1; //Z dim
coll_object.primitives.push_back(primitive);
coll_object.primitive_poses.push_back(pose);
coll_object.operation = coll_object.ADD;
//Publish on planning_scene topic
moveit_msgs::PlanningScene planning_scene_msg;
planning_scene_msg.name = "motion_planning_scene";
planning_scene_msg.world.collision_objects.push_back(coll_object);
planning_scene_msg.is_diff = true;
ps_obj_pub_.publish(planning_scene_msg);
sleep_time.sleep();
However, when running my planner collisions with the object are not detected by the "checkCollision" function of the PlanningScene object. Here are the
lines for collision checking:
//Collision checking Setup (ps_ is the PlanningScene Object)
collision_detection::CollisionRequest collision_request;
collision_request.group_name = planning_group_;
collision_detection::CollisionResult collision_result;
//collision_detection::AllowedCollisionMatrix acm = ps_->getAllowedCollisionMatrix();
collision_detection::AllowedCollisionMatrix acm = ps_->getAllowedCollisionMatrix();
robot_state::RobotState state(ps_->getRobotModel());
state.setToDefaultValues();
//Set Configuration of robot state
state.setVariablePositions(configuration); //"configuration" is a std::map<std::string, double>
//Apply robot state to planning scene
ps_->setCurrentState(state);
//Clear the collision checking result
collision_result.clear();
//Check for collisions
ps_->checkCollision(collision_request, collision_result, state, acm);
For debugging i checked whether the object is added to the CollisionWorld
bool obj_exist = ps_->getCollisionWorld()->getWorld()->hasObject("box");
cout<<"Object exists in collision world: "<<obj_exist<<endl;
and it turned out that the object does not exist there. Any ideas, or sample code how to make the collision check work?
Thank you for your answer in advance! Best,
Felix