41 #include <pr2_controllers_msgs/QueryTrajectoryState.h>
42 #include <pr2_controllers_msgs/JointTrajectoryAction.h>
44 #include <geometry_msgs/PoseStamped.h>
45 #include <pr2_arm_kinematics/pr2_arm_ik_solver.h>
46 #include <pr2_common_action_msgs/ArmMoveIKAction.h>
47 #include <kdl/frames_io.hpp>
68 std::string xml_string;
69 if (!nh_toplevel.
getParam(std::string(
"robot_description"), xml_string))
71 ROS_ERROR(
"Could not find parameter robot_description on parameter server.");
127 ROS_DEBUG(
"%s: Waiting for %s action server to come up",
action_name_.c_str(), trajectory_action_name.c_str());
131 ROS_ERROR(
"%s: %s action server took too long to start",
action_name_.c_str(), trajectory_action_name.c_str());
154 void executeCB(
const pr2_common_action_msgs::ArmMoveIKGoalConstPtr & goal)
162 if (goal->tool_frame.header.frame_id ==
"")
169 geometry_msgs::PoseStamped tip_to_tool_msg;
176 ROS_ERROR(
"Failed to transform tool_frame into \"%s\": %s",
tip_name_.c_str(), ex.what());
186 geometry_msgs::PoseStamped root_to_tool_goal_msg;
203 KDL::Frame desired_pose;
204 tf::PoseTFToKDL(root_to_tip_goal, desired_pose);
208 ROS_ERROR(
"The goal ik_seed must be size %d but is size %lu",
dimension_, goal->ik_seed.name.size());
219 std::vector<KDL::JntArray> jnt_pos_out;
223 ROS_ERROR(
"%s: Aborted: IK invalid. Cannot get to (%.3f,%.3f,%.3f)(%.2f,%.2f,%.2f,%.2f)",
action_name_.c_str(),
232 std::vector<std::string> traj_names(
dimension_);
236 traj_names[i] = goal->ik_seed.name[i];
237 traj_desired[i] = jnt_pos_out[0](
getJointIndex(goal->ik_seed.name[i]));
240 pr2_controllers_msgs::JointTrajectoryGoal traj_goal ;
241 std::vector<double> velocities(
dimension_, 0.0);
243 traj_goal.trajectory.points.resize(1);
244 traj_goal.trajectory.joint_names = traj_names;
246 traj_goal.trajectory.points[0].positions = traj_desired;
247 traj_goal.trajectory.points[0].velocities = velocities;
248 traj_goal.trajectory.points[0].time_from_start = goal->move_duration;
273 if(
kdl_chain_.getSegment(i).getJoint().getType() == KDL::Joint::None)
278 if(
kdl_chain_.getSegment(i).getJoint().getName() == name)
307 pr2_common_action_msgs::ArmMoveIKResult
result_;
311 int main(
int argc,
char** argv)