Project

General

Profile

Planning API functions description » History » Version 5

Kévin Desormeaux, 2021-06-11 12:02

1 1 Kévin Desormeaux
h1. Planning API functions description
2
3
h2. Master branch
4
5 5 Kévin Desormeaux
The following concerns the master branch of the dual_arm_planning_api package.
6
7 3 Kévin Desormeaux
h3. Main functions
8
9 1 Kévin Desormeaux
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).
10
There is two of them. One is for launching CM2P in simulation mode. 
11
12
<pre>
13
roslaunch dual_arm_planning_api dual_arm_planning_api_simu.launch
14
</pre>
15
16
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.* 
17
18
<pre>
19
roslaunch dual_arm_planning_api dual_arm_planning_api.launch
20
</pre>
21
22
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:
23
24
<pre>
25
rosservice call /dual_arm_planning_api/init "{}"
26
</pre>
27
28
This takes a few seconds to load the environment, the frames etc. You should see all of this pop in Rviz.
29
After that the node is ready to take commands.
30
31
32
We can start with a left pick or a right pick.
33
34
<pre>
35
rostopic pub /dual_arm_planning_api/PickLeft/goal dual_arm_planning_api/PickActionGoal "header:
36
  seq: 0
37
  stamp:
38
    secs: 0
39
    nsecs: 0
40
  frame_id: ''
41
goal_id:
42
  stamp:
43
    secs: 0
44
    nsecs: 0
45
  id: ''
46
goal:
47
  planning_time: 10.0
48
  pre_grasp_approach_direction:
49
    x: 0.0
50
    y: 0.0
51
    z: 1.0
52
  pre_grasp_approach_distance: 0.1"
53 2 Kévin Desormeaux
54
55
rostopic pub /dual_arm_planning_api/PickRight/goal dual_arm_planning_api/PickActionGoal "header:
56
  seq: 0
57
  stamp:
58
    secs: 0
59
    nsecs: 0
60
  frame_id: ''
61
goal_id:
62
  stamp:
63
    secs: 0
64
    nsecs: 0
65
  id: ''
66
goal:
67
  planning_time: 10.0
68
  pre_grasp_approach_direction:
69
    x: 0.0
70
    y: 0.0
71
    z: 1.0
72
  pre_grasp_approach_distance: 0.1"
73 1 Kévin Desormeaux
</pre>
74
75 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.
76 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. 
77
But you can change it whenever you want with the following service:
78
79
<pre>
80
rosservice call /dual_arm_planning_api/SetLeftGrasp  "position:
81
  x: 0.0
82
  y: 0.0
83
  z: 0.0
84
orientation:
85
  x: 0.0
86
  y: 0.0
87
  z: 0.0"
88 2 Kévin Desormeaux
</pre>
89
90
You can notice that the frames (left_arm_desired_Grasp or right_arm_desired_Grasp) are updated in Rviz after calling the service. 
91
The SetLeftGrasp (respectively SetRightGrasp) service must be called however before the PickLeft (respectively PickRight) action. 
92
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. 
93
You don't have to worry about that as you will use PickLeft (respectively PickRight) for both.
94
95
Now that the object is picked by both arms, we can start to think about the place.
96
First we have to define the new location of the object after the place. For that we call the following service:
97
98
<pre>
99
rosservice call  /dual_arm_planning_api/SetObjectPose "position:
100
  x: 0.0
101
  y: 0.0
102
  z: 0.4
103
orientation:
104
  x: 0.0
105
  y: 0.0
106
  z: 0.0"
107
</pre>
108
109
With this service we define the pose of the dynamic object (after place) in the frame of the static object.
110
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.
111
Once this is done we can plan a place().
112
113
This is done by calling the following action:
114
115
<pre>
116
rostopic pub /dual_arm_planning_api/PlanPlace/goal dual_arm_planning_api/PlanPlaceActionGoal "header:
117
  seq: 0
118
  stamp:
119
    secs: 0
120
    nsecs: 0
121
  frame_id: ''
122
goal_id:
123
  stamp:
124
    secs: 0
125
    nsecs: 0
126
  id: ''
127
goal:
128
  planning_time: 400.0
129
  start_translation_direction:
130
    x: 0.0
131
    y: 0.0
132
    z: 1.0
133
  start_translation_distance: 0.1"
134
</pre>
135
136
It only takes the start translation (translation at the beginning of the place) and the planning time as arguments. 
137
In the example above we add a translation of 10cm in the Z direction. This is defined in the frame of the object.
138
We use a planning time of 400seconds. Once a solution is found, the remaining time will be used for path simplification.
139
140
Once the solution is found and the path simplified, you should be able to see in Rviz the planned trajectories displayed in purple. 
141
After checking the validity of the trajectories you can execute the place() by calling the following action:
142
143
<pre>
144
rosaction call /dual_arm_planning_api/Place "{}"
145 1 Kévin Desormeaux
</pre>
146 3 Kévin Desormeaux
147
h3. Utilities, untested functions
148
149
I am currently adding various utilities to the API. For examples functions to release the object, homing functions, or move functions (without pick). 
150
Not sure if this will be finished before i leave the lab but i will list some here:
151
152
<pre>
153
rosservice call /dual_arm_planning_api/ReleaseLeft "{}"
154
rosservice call /dual_arm_planning_api/ReleaseRight "{}"
155
rosservice call /dual_arm_planning_api/HomingLeft "{}"
156
rosservice call /dual_arm_planning_api/HomingRight "{}"
157
</pre>
158
159
May be not everything will be listed here, and you can check what is available with the following commands:
160
161
<pre>
162
rosservice list
163
rossaction list
164
</pre>
165
166
167 4 Kévin Desormeaux
h2. pro_act_demo branch
168 3 Kévin Desormeaux
169
There is another branch, the pro_act_demo branch. This is the code used for the pro-act demonstration. It is a linear sequence of pick/place hardcoded functions etc. You can replay the demo by using the launch file and pressing enter in the terminal to execute each step of the demo. The code can be interesting to look at as i reused it a lot to create the master branch. This code should still run as it is without any modification to CM2C.