本文整理汇总了C++中planning_scene::PlanningSceneConstPtr::getAllowedCollisionMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ PlanningSceneConstPtr::getAllowedCollisionMatrix方法的具体用法?C++ PlanningSceneConstPtr::getAllowedCollisionMatrix怎么用?C++ PlanningSceneConstPtr::getAllowedCollisionMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类planning_scene::PlanningSceneConstPtr
的用法示例。
在下文中一共展示了PlanningSceneConstPtr::getAllowedCollisionMatrix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: plan
//.........这里部分代码省略.........
else
attached_object_name = attached_bodies[0]->getName();
}
const robot_state::AttachedBody *attached_body = planning_scene->getCurrentState().getAttachedBody(attached_object_name);
if (!attached_body)
{
ROS_ERROR_NAMED("manipulation", "There is no object to detach for place action");
error_code_.val = moveit_msgs::MoveItErrorCodes::INVALID_OBJECT_NAME;
return false;
}
ros::WallTime start_time = ros::WallTime::now();
// construct common data for possible manipulation plans
ManipulationPlanSharedDataPtr plan_data(new ManipulationPlanSharedData());
ManipulationPlanSharedDataConstPtr const_plan_data = plan_data;
plan_data->planning_group_ = jmg;
plan_data->end_effector_group_ = eef;
plan_data->ik_link_ = planning_scene->getRobotModel()->getLinkModel(eef->getEndEffectorParentGroup().second);
plan_data->timeout_ = endtime;
plan_data->path_constraints_ = goal.path_constraints;
plan_data->planner_id_ = goal.planner_id;
plan_data->minimize_object_distance_ = false;
plan_data->max_goal_sampling_attempts_ = std::max(2u, jmg->getDefaultIKAttempts());
moveit_msgs::AttachedCollisionObject &detach_object_msg = plan_data->diff_attached_object_;
// construct the attached object message that will change the world to what it would become after a placement
detach_object_msg.link_name = attached_body->getAttachedLinkName();
detach_object_msg.object.id = attached_object_name;
detach_object_msg.object.operation = moveit_msgs::CollisionObject::REMOVE;
collision_detection::AllowedCollisionMatrixPtr approach_place_acm(new collision_detection::AllowedCollisionMatrix(planning_scene->getAllowedCollisionMatrix()));
// we are allowed to touch certain other objects with the gripper
approach_place_acm->setEntry(eef->getLinkModelNames(), goal.allowed_touch_objects, true);
// we are allowed to touch the target object slightly while retreating the end effector
std::vector<std::string> touch_links(attached_body->getTouchLinks().begin(), attached_body->getTouchLinks().end());
approach_place_acm->setEntry(attached_object_name, touch_links, true);
if (!goal.support_surface_name.empty())
{
// we are allowed to have contact between the target object and the support surface before the place
approach_place_acm->setEntry(goal.support_surface_name, attached_object_name, true);
// optionally, it may be allowed to touch the support surface with the gripper
if (goal.allow_gripper_support_collision)
approach_place_acm->setEntry(goal.support_surface_name, eef->getLinkModelNames(), true);
}
// configure the manipulation pipeline
pipeline_.reset();
ManipulationStagePtr stage1(new ReachableAndValidPoseFilter(planning_scene, approach_place_acm, pick_place_->getConstraintsSamplerManager()));
ManipulationStagePtr stage2(new ApproachAndTranslateStage(planning_scene, approach_place_acm));
ManipulationStagePtr stage3(new PlanStage(planning_scene, pick_place_->getPlanningPipeline()));
pipeline_.addStage(stage1).addStage(stage2).addStage(stage3);
initialize();
pipeline_.start();
// add possible place locations
示例2: plan
bool PickPlan::plan(const planning_scene::PlanningSceneConstPtr &planning_scene, const moveit_msgs::PickupGoal &goal)
{
double timeout = goal.allowed_planning_time;
ros::WallTime endtime = ros::WallTime::now() + ros::WallDuration(timeout);
std::string planning_group = goal.group_name;
std::string end_effector = goal.end_effector;
if (end_effector.empty() && !planning_group.empty())
{
const robot_model::JointModelGroup *jmg = planning_scene->getRobotModel()->getJointModelGroup(planning_group);
if (!jmg)
{
error_code_.val = moveit_msgs::MoveItErrorCodes::INVALID_GROUP_NAME;
return false;
}
const std::vector<std::string> &eefs = jmg->getAttachedEndEffectorNames();
if (!eefs.empty())
{
end_effector = eefs.front();
if (eefs.size() > 1)
ROS_WARN_STREAM_NAMED("manipulation", "Choice of end-effector for group '" << planning_group << "' is ambiguous. Assuming '" << end_effector << "'");
}
}
else
if (!end_effector.empty() && planning_group.empty())
{
const robot_model::JointModelGroup *jmg = planning_scene->getRobotModel()->getEndEffector(end_effector);
if (!jmg)
{
error_code_.val = moveit_msgs::MoveItErrorCodes::INVALID_GROUP_NAME;
return false;
}
planning_group = jmg->getEndEffectorParentGroup().first;
if (planning_group.empty())
{
ROS_ERROR_STREAM_NAMED("manipulation", "No parent group to plan in was identified based on end-effector '" << end_effector << "'. Please define a parent group in the SRDF.");
error_code_.val = moveit_msgs::MoveItErrorCodes::INVALID_GROUP_NAME;
return false;
}
else
ROS_INFO_STREAM_NAMED("manipulation", "Assuming the planning group for end effector '" << end_effector << "' is '" << planning_group << "'");
}
const robot_model::JointModelGroup *eef = end_effector.empty() ? NULL : planning_scene->getRobotModel()->getEndEffector(end_effector);
if (!eef)
{
ROS_ERROR_NAMED("manipulation", "No end-effector specified for pick action");
error_code_.val = moveit_msgs::MoveItErrorCodes::INVALID_GROUP_NAME;
return false;
}
const std::string &ik_link = eef->getEndEffectorParentGroup().second;
ros::WallTime start_time = ros::WallTime::now();
// construct common data for possible manipulation plans
ManipulationPlanSharedDataPtr plan_data(new ManipulationPlanSharedData());
ManipulationPlanSharedDataConstPtr const_plan_data = plan_data;
plan_data->planning_group_ = planning_scene->getRobotModel()->getJointModelGroup(planning_group);
plan_data->end_effector_group_ = eef;
plan_data->ik_link_ = planning_scene->getRobotModel()->getLinkModel(ik_link);
plan_data->timeout_ = endtime;
plan_data->path_constraints_ = goal.path_constraints;
plan_data->planner_id_ = goal.planner_id;
plan_data->minimize_object_distance_ = goal.minimize_object_distance;
plan_data->max_goal_sampling_attempts_ = std::max(2u, plan_data->planning_group_->getDefaultIKAttempts());
moveit_msgs::AttachedCollisionObject &attach_object_msg = plan_data->diff_attached_object_;
// construct the attached object message that will change the world to what it would become after a pick
attach_object_msg.link_name = ik_link;
attach_object_msg.object.id = goal.target_name;
attach_object_msg.object.operation = moveit_msgs::CollisionObject::ADD;
attach_object_msg.touch_links = goal.attached_object_touch_links.empty() ? eef->getLinkModelNames() : goal.attached_object_touch_links;
collision_detection::AllowedCollisionMatrixPtr approach_grasp_acm(new collision_detection::AllowedCollisionMatrix(planning_scene->getAllowedCollisionMatrix()));
// we are allowed to touch the target object
approach_grasp_acm->setEntry(goal.target_name, attach_object_msg.touch_links, true);
// we are allowed to touch certain other objects with the gripper
approach_grasp_acm->setEntry(eef->getLinkModelNames(), goal.allowed_touch_objects, true);
if (!goal.support_surface_name.empty())
{
// we are allowed to have contact between the target object and the support surface before the grasp
approach_grasp_acm->setEntry(goal.support_surface_name, goal.target_name, true);
// optionally, it may be allowed to touch the support surface with the gripper
if (goal.allow_gripper_support_collision)
approach_grasp_acm->setEntry(goal.support_surface_name, eef->getLinkModelNames(), true);
}
// configure the manipulation pipeline
pipeline_.reset();
ManipulationStagePtr stage1(new ReachableAndValidPoseFilter(planning_scene, approach_grasp_acm, pick_place_->getConstraintsSamplerManager()));
ManipulationStagePtr stage2(new ApproachAndTranslateStage(planning_scene, approach_grasp_acm));
ManipulationStagePtr stage3(new PlanStage(planning_scene, pick_place_->getPlanningPipeline()));
pipeline_.addStage(stage1).addStage(stage2).addStage(stage3);
initialize();
pipeline_.start();
// order the grasps by quality
std::vector<std::size_t> grasp_order(goal.possible_grasps.size());
for (std::size_t i = 0 ; i < goal.possible_grasps.size() ; ++i)
//.........这里部分代码省略.........