我在 Ubuntu 14.04 下设置了 ROS indigo, Gazebo。在 ROS 下,moveit 节点正在运行。模拟机械臂 IRB120 并站在 Gazebo 中。我有一个节点,它使用moveit
(move_group node)为Bob 想要的目的地规划路径(轨迹) 。计划的轨迹将被发送到 Gazebo 以便稍后显示。
Bob 可以使用两种方法来描述目的地:
手臂每个关节的角度:使用六个数字的数组(对于手臂的六个关节),定义每个关节和胫骨的形式。这种方法效果很好。它使用
JointConstraint
类:双目标姿势 [] = {0.52, 0.50, 0.73, -0.02, 0.31, 6.83}; for(int i = 0 ; i < 6; i++) // 迭代手臂的关节。{ moveit_msgs::JointConstraint jc; jc.weight = 1.0; jc.tolerance_above = 0.0001; jc.tolerance_below = 0.0001; jc.position = 目标姿势[i]; jc.joint_name = 名称[i]; 目标约束.joint_constraints.push_back(jc); }
仅定义末端执行器的位置和方向。我不能使用这种方法。我已经使用了
PositionConstraint
类。
简而言之:我可以使用类来描述一个目的地JointConstraint
,但我不知道如何在PositionConstraint
类中描述它。如何通过指出末端执行器的位置来描述目标?
我如何用格式描述目标PositionConstraint
:(我指出末端执行器应该在哪里以及它的方向应该是什么。)
moveit_msgs::PositionConstraint pc;
pc.weight = 1.0;
geometry_msgs::Pose p;
p.position.x = 0.3; // not sure if feasible position
p.position.y = 0.3; // not sure if feasible position
p.position.z = 0.3; // not sure if feasible position
pc.link_name="tool0";
p.orientation.x = 0;
p.orientation.y = 0;
p.orientation.z = 0;
p.orientation.w = 1;
pc.constraint_region.mesh_poses.push_back(p);
goal_constraint.position_constraints.push_back(pc);
但是当请求发送时,服务器会响应:
[ERROR] [1527689581.951677797, 295.242000000]: Unable to construct goal representation
笔记:
在这两种情况下,我都将其添加goal_constraint
到trajectory_request
:
trajectory_request.goal.request.goal_constraints.push_back(goal_constraint);
// add other details to trajectory_request here...
trajectory_request
是要发送到的move_group
。(通过发表trajectory_request
关于该/move_group/goal
主题的文章)