Pr2_Player.cc
Go to the documentation of this file.
1 #include <libplayerc++/playerc++.h>
2 #include <iostream>
3 
4 int main()
5 {
6  // We throw exceptions on creation if we fail
7  try
8  {
9  using namespace PlayerCc;
10  using namespace std;
11 
12  // Create a player client object, using the variables assigned by the
13  // call to parse_args()
14  PlayerClient robot(PlayerCc::PLAYER_HOSTNAME, PlayerCc::PLAYER_PORTNUM);
15 
16  // Subscribe to the simulation proxy
17  ActArrayProxy ap_l(&robot, 0); // left arm
18  ActArrayProxy ap_r(&robot, 1); // right arm
19  ActArrayProxy ap_c(&robot, 2); // caster steering
20  ActArrayProxy ap_s(&robot, 3); // spine slider
21  ActArrayProxy ap_h(&robot, 4); // head
22 
23  Position2dProxy flc(&robot, 0); // front left caster differential drive
24  Position2dProxy frc(&robot, 1); // front right caster differential drive
25  Position2dProxy rlc(&robot, 2); // rear left caster differential drive
26  Position2dProxy rrc(&robot, 3); // rear right caster differential drive
27 
28  // Print out some stuff
29  std::cout << robot << std::endl;
30 
31  flc.SetMotorEnable(true);
32  frc.SetMotorEnable(true);
33  rlc.SetMotorEnable(true);
34  rrc.SetMotorEnable(true);
35 
36  for (;;)
37  {
38  // This blocks until new data comes
39  robot.Read();
40 
41  flc.SetSpeed(1, 0);
42  frc.SetSpeed(1, 0);
43  rlc.SetSpeed(1, 0);
44  rrc.SetSpeed(1, 0);
45 
46  ap_h.MoveTo(0, -M_PI/4.0); // head tilt
47  ap_h.MoveTo(1, M_PI/6.0); // head neck yaw
48  ap_h.MoveTo(2, -M_PI/4.0); // hokuyo pitch
49  ap_h.MoveTo(3, M_PI/5.0); // left cam yaw
50  ap_h.MoveTo(4, -M_PI/3.0); // left cam pitch
51  ap_h.MoveTo(5, -M_PI/5.0); // right cam yaw
52  ap_h.MoveTo(6, M_PI/4.0); // right cam pitch
53 
54  ap_l.MoveTo(0, M_PI/4.0);
55  ap_l.MoveTo(1, M_PI/4.0);
56  ap_l.MoveTo(2, M_PI/4.0);
57  ap_l.MoveTo(3, M_PI/5.0);
58  ap_l.MoveTo(4, M_PI/3.0);
59  ap_l.MoveTo(5, M_PI/2.0);
60  ap_l.MoveTo(6, M_PI/1.0);
61 
62  ap_r.MoveTo(0, -M_PI/3.0);
63  ap_r.MoveTo(1, -M_PI/3.0);
64  ap_r.MoveTo(2, -M_PI/3.0);
65  ap_r.MoveTo(3, -M_PI/2.0);
66  ap_r.MoveTo(4, -M_PI/3.0);
67  ap_r.MoveTo(5, -M_PI/1.0);
68  ap_r.MoveTo(6, -M_PI/2.0);
69 
70  ap_c.MoveTo(0, - M_PI/4.0);
71  ap_c.MoveTo(1, -3.0*M_PI/4.0);
72  ap_c.MoveTo(2, M_PI/4.0);
73  ap_c.MoveTo(3, 3.0*M_PI/4.0);
74 
75  ap_s.MoveTo(0,0.5);
76 
77  player_actarray_actuator_t data0 = ap_l.GetActuatorData(0);
78  printf("0 Pos[%f] Speed[%f]\n",data0.position, data0.speed);
79  player_actarray_actuator_t data1 = ap_l.GetActuatorData(1);
80  printf("1 Pos[%f] Speed[%f]\n",data1.position, data1.speed);
81  player_actarray_actuator_t data2 = ap_l.GetActuatorData(2);
82  printf("2 Pos[%f] Speed[%f]\n",data2.position, data2.speed);
83  }
84  }
85  catch (PlayerCc::PlayerError e)
86  {
87  std::cerr << "Error:" << e << std::endl;
88  return -1;
89  }
90 }
int main()
Definition: Pr2_Player.cc:4


pr2_gazebo_plugins
Author(s): John Hsu
autogenerated on Fri May 3 2019 02:24:24