本文整理汇总了C++中planning_scene::PlanningSceneConstPtr::getPlanningFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ PlanningSceneConstPtr::getPlanningFrame方法的具体用法?C++ PlanningSceneConstPtr::getPlanningFrame怎么用?C++ PlanningSceneConstPtr::getPlanningFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类planning_scene::PlanningSceneConstPtr
的用法示例。
在下文中一共展示了PlanningSceneConstPtr::getPlanningFrame方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: displayPlannerData
void displayPlannerData(const planning_scene::PlanningSceneConstPtr& planning_scene,
const std::string &link_name) const
{
std::cout << "displayPlannerData called ... " << std::endl;
const ompl_interface::ModelBasedPlanningContextPtr &pc = ompl_interface_->getLastPlanningContext();
if (pc)
{
ompl::base::PlannerData pd(pc->getOMPLSimpleSetup().getSpaceInformation());
pc->getOMPLSimpleSetup().getPlannerData(pd);
robot_state::RobotState kstate = planning_scene->getCurrentState();
visualization_msgs::MarkerArray arr;
std_msgs::ColorRGBA color;
color.r = 1.0f;
color.g = 0.25f;
color.b = 1.0f;
color.a = 1.0f;
unsigned int nv = pd.numVertices();
for (unsigned int i = 0 ; i < nv ; ++i)
{
pc->getOMPLStateSpace()->copyToRobotState(kstate, pd.getVertex(i).getState());
kstate.getJointStateGroup(pc->getJointModelGroupName())->updateLinkTransforms();
const Eigen::Vector3d &pos = kstate.getLinkState(link_name)->getGlobalLinkTransform().translation();
visualization_msgs::Marker mk;
mk.header.stamp = ros::Time::now();
mk.header.frame_id = planning_scene->getPlanningFrame();
mk.ns = "planner_data";
mk.id = i;
mk.type = visualization_msgs::Marker::SPHERE;
mk.action = visualization_msgs::Marker::ADD;
mk.pose.position.x = pos.x();
mk.pose.position.y = pos.y();
mk.pose.position.z = pos.z();
mk.pose.orientation.w = 1.0;
mk.scale.x = mk.scale.y = mk.scale.z = 0.025;
mk.color = color;
mk.lifetime = ros::Duration(30.0);
arr.markers.push_back(mk);
}
pub_markers_.publish(arr);
}
}
示例2: solve
bool ConvexConstraintSolver::solve(const planning_scene::PlanningSceneConstPtr& planning_scene,
const moveit_msgs::GetMotionPlan::Request &req,
moveit_msgs::GetMotionPlan::Response &res) const
{
// Need to add in joint limit constraints
// Get the position constraints from the collision detector
// The raw algorithm laid out in Chan et. al. is as follows:
// 1. Compute unconstrained motion to go from proxy to goal.
// 2. Get the current contact set by moving the proxy toward the goal by some epsilon and get all collision points.
// 3. Compute constrained motion (convex solver).
// 4. Compute collisions along the constrained motion path.
// 5. Set proxy to stop at the first new contact along path.
// In our framework this will look more like this:
// Outside ths planner:
// 1. Compute error between cartesian end effector and cartesian goal.
// 2. Cap pose error (based on some heuristic?) because we are about to make a linear approximation.
// 3. Use Jinverse to compute the joint deltas for the pose error (or perhaps we should frame this as a velocity problem).
// 4. Add the joint deltas to the start state to get a goal state.
// Inside the planner:
// 1. Get the "current" contact set by moving the proxy toward the goal by some epsilon and get all collision points.
// 2. Compute constrained motion (convex solver).
// 3. Subdivide motion subject to some sort of minimum feature size.
// 4. Move proxy in steps, checking for colliding state along the way. Optionally use interval bisection to refine.
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -/
std::string group_name = req.motion_plan_request.group_name;
std::string ee_group_name;
std::string ee_control_frame;
if(group_name == "right_arm"){ ee_group_name = "r_end_effector"; ee_control_frame = "r_wrist_roll_link"; }
if(group_name == "left_arm") { ee_group_name = "l_end_effector"; ee_control_frame = "l_wrist_roll_link"; }
ROS_WARN("Solving for group [%s], end-effector [%s], control frame [%s] using ConvexConstraintSolver!", group_name.c_str(), ee_group_name.c_str(), ee_control_frame.c_str());
// We "getCurrentState" just to populate the structure with auxiliary info, then copy in the transform info from the planning request.
planning_models::KinematicState start_state = planning_scene->getCurrentState();
planning_models::robotStateToKinematicState(*(planning_scene->getTransforms()), req.motion_plan_request.start_state, start_state);
// constrained_goal_state is the optimization output before interval stepping, proxy_state will be used as we step around.
planning_models::KinematicState proxy_state = start_state;
planning_models::KinematicState constrained_goal_state = start_state;
std::string planning_frame = ros::names::resolve("/", planning_scene->getPlanningFrame());
const planning_models::KinematicState::JointStateGroup * jsg = proxy_state.getJointStateGroup(group_name);
const planning_models::KinematicModel::JointModelGroup * jmg = planning_scene->getKinematicModel()->getJointModelGroup(group_name);
// std::string end_effector_group_name = jmg->getAttachedEndEffectorGroupName();
// const std::vector<std::string>& subgroups = jmg->getSubgroupNames();
// ROS_INFO("End-effector group name is [%s].", end_effector_group_name.c_str());
// for(size_t i = 0; i< subgroups.size(); i++)
// ROS_INFO("Subgroup [%zd] is [%s].", i, subgroups[i].c_str());
const planning_models::KinematicModel::JointModelGroup * ee_jmg = planning_scene->getKinematicModel()->getJointModelGroup(ee_group_name);
// const std::vector<const planning_models::KinematicModel::JointModel*>& joint_models = jmg->getJointModels();
// std::map<std::string, unsigned int> joint_index_map;
// for(size_t i = 0; i < joint_models.size(); i++)
// {
// //ROS_INFO("Group [%s] has joint %d: [%s]", req.motion_plan_request.group_name.c_str(), i, joint_models[i]->getName().c_str());
// joint_index_map[joint_models[i]->getName()] = i;
// }
const std::map<std::string, unsigned int>& joint_index_map = jmg->getJointVariablesIndexMap();
std::vector<double> limits_min, limits_max, joint_vector;
std::vector<std::string> joint_names;
limits_min.resize(7);
limits_max.resize(7);
joint_vector.resize(7);
joint_names.resize(7);
{
const moveit_msgs::Constraints &c = req.motion_plan_request.goal_constraints[1];
for (std::size_t i = 0 ; i < c.joint_constraints.size() ; ++i)
{
std::string joint_name = c.joint_constraints[i].joint_name;
if(joint_index_map.find(joint_name) == joint_index_map.end())
{
ROS_WARN("Didin't find [%s] in the joint map, ignoring...", joint_name.c_str());
continue;
}
unsigned int joint_index = joint_index_map.find(joint_name)->second;
std::vector<moveit_msgs::JointLimits> limits = planning_scene->getKinematicModel()->getJointModel(joint_name)->getLimits();
moveit_msgs::JointLimits limit = limits[0];
if(limit.has_position_limits)
{
limits_min[joint_index] = limit.min_position;
limits_max[joint_index] = limit.max_position;
//.........这里部分代码省略.........