Project

General

Profile

Planning API functions description » History » Version 2

Kévin Desormeaux, 2021-06-11 11:51

1 1 Kévin Desormeaux
h1. Planning API functions description
2
3
h2. Master branch
4
5
The whole CM2P stack can be launched with a simple launch file. The launch files are available in this package (dual_arm_planning_api/launch).
6
There is two of them. One is for launching CM2P in simulation mode. 
7
8
<pre>
9
roslaunch dual_arm_planning_api dual_arm_planning_api_simu.launch
10
</pre>
11
12
The other is for launching CM2P with the real robots. *The two instances of CM2C must be running beforehand so that the controllers are spawned.* 
13
14
<pre>
15
roslaunch dual_arm_planning_api dual_arm_planning_api.launch
16
</pre>
17
18
Now the dual_arm_planning_api node is running. It is necessary to run the following rosservice in another terminal to finish the initialization of the node:
19
20
<pre>
21
rosservice call /dual_arm_planning_api/init "{}"
22
</pre>
23
24
This takes a few seconds to load the environment, the frames etc. You should see all of this pop in Rviz.
25
After that the node is ready to take commands.
26
27
28
We can start with a left pick or a right pick.
29
30
<pre>
31
rostopic pub /dual_arm_planning_api/PickLeft/goal dual_arm_planning_api/PickActionGoal "header:
32
  seq: 0
33
  stamp:
34
    secs: 0
35
    nsecs: 0
36
  frame_id: ''
37
goal_id:
38
  stamp:
39
    secs: 0
40
    nsecs: 0
41
  id: ''
42
goal:
43
  planning_time: 10.0
44
  pre_grasp_approach_direction:
45
    x: 0.0
46
    y: 0.0
47
    z: 1.0
48
  pre_grasp_approach_distance: 0.1"
49 2 Kévin Desormeaux
50
51
rostopic pub /dual_arm_planning_api/PickRight/goal dual_arm_planning_api/PickActionGoal "header:
52
  seq: 0
53
  stamp:
54
    secs: 0
55
    nsecs: 0
56
  frame_id: ''
57
goal_id:
58
  stamp:
59
    secs: 0
60
    nsecs: 0
61
  id: ''
62
goal:
63
  planning_time: 10.0
64
  pre_grasp_approach_direction:
65
    x: 0.0
66
    y: 0.0
67
    z: 1.0
68
  pre_grasp_approach_distance: 0.1"
69 1 Kévin Desormeaux
</pre>
70
71 2 Kévin Desormeaux
First you can notice that i use rostopic pub instead of rosaction call. The reason is that with rostopic pub we can have auto-completion in the terminal (with tab) which is very useful when we have a lot of arguments. You will have it with rosservices as well, but not with rosactions.
72 1 Kévin Desormeaux
But most importantly you will notice that there is no pose defined for the grasp frame. This is because there is one defined during the initialization for each arm. 
73
But you can change it whenever you want with the following service:
74
75
<pre>
76
rosservice call /dual_arm_planning_api/SetLeftGrasp  "position:
77
  x: 0.0
78
  y: 0.0
79
  z: 0.0
80
orientation:
81
  x: 0.0
82
  y: 0.0
83
  z: 0.0"
84 2 Kévin Desormeaux
</pre>
85
86
You can notice that the frames (left_arm_desired_Grasp or right_arm_desired_Grasp) are updated in Rviz after calling the service. 
87
The SetLeftGrasp (respectively SetRightGrasp) service must be called however before the PickLeft (respectively PickRight) action. 
88
You can use PickLeft or PickRight in the order you want. The first pick will be a default moveit! pick and the second one a dual-arm pick. 
89
You don't have to worry about that as you will use PickLeft (respectively PickRight) for both.
90
91
Now that the object is picked by both arms, we can start to think about the place.
92
First we have to define the new location of the object after the place. For that we call the following service:
93
94
<pre>
95
rosservice call  /dual_arm_planning_api/SetObjectPose "position:
96
  x: 0.0
97
  y: 0.0
98
  z: 0.4
99
orientation:
100
  x: 0.0
101
  y: 0.0
102
  z: 0.0"
103
</pre>
104
105
With this service we define the pose of the dynamic object (after place) in the frame of the static object.
106
You can notice that the frames are updated in Rviz after calling the service. This is really useful to check the validity of the new pose before planning.
107
Once this is done we can plan a place().
108
109
This is done by calling the following action:
110
111
<pre>
112
rostopic pub /dual_arm_planning_api/PlanPlace/goal dual_arm_planning_api/PlanPlaceActionGoal "header:
113
  seq: 0
114
  stamp:
115
    secs: 0
116
    nsecs: 0
117
  frame_id: ''
118
goal_id:
119
  stamp:
120
    secs: 0
121
    nsecs: 0
122
  id: ''
123
goal:
124
  planning_time: 400.0
125
  start_translation_direction:
126
    x: 0.0
127
    y: 0.0
128
    z: 1.0
129
  start_translation_distance: 0.1"
130
</pre>
131
132
It only takes the start translation (translation at the beginning of the place) and the planning time as arguments. 
133
In the example above we add a translation of 10cm in the Z direction. This is defined in the frame of the object.
134
We use a planning time of 400seconds. Once a solution is found, the remaining time will be used for path simplification.
135
136
Once the solution is found and the path simplified, you should be able to see in Rviz the planned trajectories displayed in purple. 
137
After checking the validity of the trajectories you can execute the place() by calling the following action:
138
139
<pre>
140
rosaction call /dual_arm_planning_api/Place "{}"
141 1 Kévin Desormeaux
</pre>