pr2_arm_ik_test.cpp
Go to the documentation of this file.
1 #include <ros/ros.h>
4 #include <pr2_common_action_msgs/ArmMoveIKAction.h>
5 
6 int main (int argc, char **argv)
7 {
8  ros::init(argc, argv, "test_pr2_arm_ik");
9 
10  // create the action client
11  // true causes the client to spin it's own thread
13 
14  ROS_INFO("Waiting for action server to start.");
15  // wait for the action server to start
16  ac.waitForServer(); //will wait for infinite time
17 
18  ROS_INFO("Action server started, sending goal.");
19  // send a goal to the action
20  pr2_common_action_msgs::ArmMoveIKGoal goal;
21  goal.pose.header.frame_id = "base_link";
22  goal.pose.header.stamp = ros::Time::now();
23  goal.pose.pose.orientation.x = 0.0;
24  goal.pose.pose.orientation.y = 0.0;
25  goal.pose.pose.orientation.z = 0.0;
26  goal.pose.pose.orientation.w = 1.0;
27  goal.pose.pose.position.x = 0.5;
28  goal.pose.pose.position.y = -0.1;
29  goal.pose.pose.position.z = 0.5;
30  goal.ik_timeout = ros::Duration(5.0);
31  goal.ik_seed.name.push_back("r_shoulder_pan_joint");
32  goal.ik_seed.name.push_back("r_shoulder_lift_joint");
33  goal.ik_seed.name.push_back("r_upper_arm_roll_joint");
34  goal.ik_seed.name.push_back("r_elbow_flex_joint");
35  goal.ik_seed.name.push_back("r_forearm_roll_joint");
36  goal.ik_seed.name.push_back("r_wrist_flex_joint");
37  goal.ik_seed.name.push_back("r_wrist_roll_joint");
38  goal.ik_seed.position.push_back(-1.46);
39  goal.ik_seed.position.push_back(1.09);
40  goal.ik_seed.position.push_back(-6.58);
41  goal.ik_seed.position.push_back(-1.73);
42  goal.ik_seed.position.push_back(4.82);
43  goal.ik_seed.position.push_back(-0.46);
44  goal.ik_seed.position.push_back(-4.72);
45  goal.move_duration= ros::Duration(1.0);
46  ac.sendGoal(goal);
47 
48  //wait for the action to return
49  bool finished_before_timeout = ac.waitForResult(ros::Duration(40.0));
50 
51  if (finished_before_timeout)
52  {
54  ROS_INFO("Action finished: %s",state.toString().c_str());
55  }
56  else
57  ROS_INFO("Action did not finish before the time out.");
58 
59  //exit
60  return 0;
61 }
62 
bool waitForServer(const ros::Duration &timeout=ros::Duration(0, 0)) const
bool waitForResult(const ros::Duration &timeout=ros::Duration(0, 0))
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
std::string toString() const
int main(int argc, char **argv)
#define ROS_INFO(...)
void sendGoal(const Goal &goal, SimpleDoneCallback done_cb=SimpleDoneCallback(), SimpleActiveCallback active_cb=SimpleActiveCallback(), SimpleFeedbackCallback feedback_cb=SimpleFeedbackCallback())
static Time now()
SimpleClientGoalState getState() const


pr2_arm_move_ik
Author(s): Wim Meeusen, Melonee Wise
autogenerated on Fri Jun 7 2019 22:06:41