-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathrexos-launch-ros.sh
314 lines (294 loc) · 12.5 KB
/
rexos-launch-ros.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
#!/usr/bin/env sh
###################### SETTINGS ######################
keepWindowOpenAfterCommandEnds=true
defaultManufacturer="HU"
defaultTypeNumber="workplane_type_A"
defaultSerialNumber="1"
###################### END OF SETTINGS ######################
###################### VARS ######################
launchedPrimaryInfrastructureWithSimulation=false
cancelAction=false
###################### END OF VARS ######################
###################### FUNCTIONS ######################
function getEquipletName() {
echo -n "Choose equipletName: "
read equipletName
}
function getPartName() {
echo -n "Choose partName: "
read partName
}
function getModuleIdentifier() {
echo -n "Choose manufacturer (default: $defaultManufacturer): "
read manufacturer
if [ "$manufacturer" == "" ]; then
manufacturer="$defaultManufacturer"
fi
echo -n "Choose typeNumber (default: $defaultTypeNumber): "
read typeNumber
if [ "$typeNumber" == "" ]; then
typeNumber="$defaultTypeNumber"
fi
echo -n "Choose serialNumber (default: $defaultSerialNumber): "
read serialNumber
if [ "$serialNumber" == "" ]; then
serialNumber="$defaultSerialNumber"
fi
moduleIdentifier="$manufacturer|$typeNumber|$serialNumber"
}
function getPosition() {
echo -n "Choose positionX: "
read positionX
echo -n "Choose positionY: "
read positionY
}
function getOriginPlacementType() {
echo "Choose origin placement type: "
echo "1: Relative to equiplet origin (relativeToEquipletOrigin)"
echo "2: Relative to module origin (relativeToModuleOrigin)"
echo "3: Relative to part origin (relativeToIdentifier)"
echo "4: Relative to world origin (relativeToWorldOrigin)"
echo "Q: Cancel"
echo ""
echo -n "Choose option: "
read chosenOption
if [ "$chosenOption" == 1 ]; then
originPlacementType=RELATIVE_TO_EQUIPLET_ORIGIN
getEquipletName
relativeTo="$equipletName"
elif [ "$chosenOption" == 2 ]; then
originPlacementType=RELATIVE_TO_MODULE_ORIGIN
getModuleIdentifier
relativeTo="$moduleIdentifier"
elif [ "$chosenOption" == 3 ]; then
originPlacementType=RELATIVE_TO_PART_ORIGIN
getPartName
relativeTo="$partName"
elif [ "$chosenOption" == 4 ]; then
originPlacementType=RELATIVE_TO_WORLD_ORIGIN
relativeTo=""
else
echo "Cancelling"
cancelAction=true
fi
}
function getPose() {
echo -n "Choose positionX: "
read positionX
echo -n "Choose positionY: "
read positionY
echo -n "Choose positionZ: "
read positionZ
echo -n "Choose rotationX: "
read rotationX
echo -n "Choose rotationY: "
read rotationY
echo -n "Choose rotationZ: "
read rotationZ
}
function launchPrimaryInfrastructureWithSimulation() {
echo "Launching primary infrastructure with simulation"
if [ "$keepWindowOpenAfterCommandEnds" == true ]; then
gnome-terminal --title="Primary infrastructure" \
--tab -t "roscore" -e "bash -c \"roscore\";bash" \
--tab -t "gzserver" -e "bash -c \"rosrun gazebo_ros gzserver --verbose world.sdf\";bash" \
--tab -t "gzclient" -e "bash -c \"rosrun gazebo_ros gzclient --verbose\";bash"
else
gnome-terminal --title="Primary infrastructure" \
--tab -t "roscore" -e "bash -c \"roscore\"" \
--tab -t "gzserver" -e "bash -c \"rosrun gazebo_ros gzserver --verbose world.sdf\"" \
--tab -t "gzclient" -e "bash -c \"rosrun gazebo_ros gzclient --verbose\""
fi
launchedPrimaryInfrastructureWithSimulation=true
}
function launchPrimaryInfrastructureWithoutSimulation() {
echo "Launching primary infrastructure without simulation"
if [ "$keepWindowOpenAfterCommandEnds" == true ]; then
gnome-terminal --title="Primary infrastructure" \
--tab -t "roscore" -e "bash -c \"roscore\";bash"
else
gnome-terminal --title="Primary infrastructure" \
--tab -t "roscore" -e "bash -c \"roscore\""
fi
}
function launchEquipletWithPrimaryNodes() {
echo "Launching equiplet with primary nodes"
getEquipletName
if [ "$keepWindowOpenAfterCommandEnds" == true ]; then
gnome-terminal --title="$equipletName" \
--tab -t "equiplet_node" -e "bash -c \"rosrun equiplet_node equiplet_node $equipletName\";bash" \
--tab -t "node_spawner_node" -e "bash -c \"rosrun node_spawner_node node_spawner_node $equipletName\";bash" \
--tab -t "environment_cache" -e "bash -c \"rosrun environment_cache environment_cache $equipletName\";bash"
else
gnome-terminal --title="$equipletName" \
--tab -t "equiplet_node" -e "bash -c \"rosrun equiplet_node equiplet_node $equipletName\"" \
--tab -t "node_spawner_node" -e "bash -c \"rosrun node_spawner_node node_spawner_node $equipletName\"" \
--tab -t "environment_cache" -e "bash -c \"rosrun environment_cache environment_cache $equipletName\""
fi
}
function launchEquipletWithoutPrimaryNodes() {
echo "Launching equiplet without primary nodes"
getEquipletName
if [ "$keepWindowOpenAfterCommandEnds" == true ]; then
gnome-terminal --title="$equipletName" \
--tab -e "bash -c \"rosrun equiplet_node equiplet_node $equipletName\";bash"
else
gnome-terminal --title="$equipletName" \
--tab -e "bash -c \"rosrun equiplet_node equiplet_node $equipletName\""
fi
}
function launchSimulatedEquipletWithPrimaryNodes() {
echo "Launching simulated equiplet with primary nodes"
getEquipletName
getPosition
if [ "$keepWindowOpenAfterCommandEnds" == true ]; then
gnome-terminal --title="$equipletName" \
--tab -t "equiplet_node" -e "bash -c \"rosrun equiplet_node equiplet_node --isSimulated $equipletName\";bash" \
--tab -t "node_spawner_node" -e "bash -c \"rosrun node_spawner_node node_spawner_node --isSimulated $equipletName\";bash" \
--tab -t "environment_cache" -e "bash -c \"rosrun environment_cache environment_cache --isSimulated $equipletName\";bash" \
--tab -t "model_spawner_node" -e "bash -c \"rosrun model_spawner_node model_spawner_node --spawnEquipletModel -x $positionX -y $positionY $equipletName\";bash"
else
gnome-terminal --title="$equipletName" \
--tab -t "equiplet_node" -e "bash -c \"rosrun equiplet_node equiplet_node --isSimulated $equipletName\"" \
--tab -t "node_spawner_node" -e "bash -c \"rosrun node_spawner_node node_spawner_node --isSimulated $equipletName\"" \
--tab -t "environment_cache" -e "bash -c \"rosrun environment_cache environment_cache --isSimulated $equipletName\"" \
--tab -t "model_spawner_node" -e "bash -c \"rosrun model_spawner_node model_spawner_node --spawnEquipletModel -x $positionX -y $positionY $equipletName\""
fi
}
function launchSimulatedEquipletWithoutPrimaryNodes() {
echo "Launching simulated equiplet without primary nodes"
getEquipletName
if [ "$keepWindowOpenAfterCommandEnds" == true ]; then
gnome-terminal --title="$equipletName" \
--tab -t "equiplet_node" -e "bash -c \"rosrun equiplet_node equiplet_node --isSimulated $equipletName\";bash"
else
gnome-terminal --title="$equipletName" \
--tab -t "equiplet_node" -e "bash -c \"rosrun equiplet_node equiplet_node --isSimulated $equipletName\""
fi
}
function launchShadowEquipletWithPrimaryNodes() {
echo "Launching shadow equiplet with primary nodes"
getEquipletName
getPosition
if [ "$keepWindowOpenAfterCommandEnds" == true ]; then
gnome-terminal --title="$equipletName" \
--tab -t "equiplet_node" -e "bash -c \"rosrun equiplet_node equiplet_node --isShadow $equipletName\";bash" \
--tab -t "node_spawner_node" -e "bash -c \"rosrun node_spawner_node node_spawner_node --isShadow $equipletName\";bash" \
--tab -t "environment_cache" -e "bash -c \"rosrun environment_cache environment_cache --isShadow $equipletName\";bash" \
--tab -t "model_spawner_node" -e "bash -c \"rosrun model_spawner_node model_spawner_node --isShadow --spawnEquipletModel -x $positionX -y $positionY $equipletName\";bash"
else
gnome-terminal --title="$equipletName" \
--tab -t "equiplet_node" -e "bash -c \"rosrun equiplet_node equiplet_node --isShadow $equipletName\"" \
--tab -t "node_spawner_node" -e "bash -c \"rosrun node_spawner_node node_spawner_node --isShadow $equipletName\"" \
--tab -t "environment_cache" -e "bash -c \"rosrun environment_cache environment_cache --isShadow $equipletName\"" \
--tab -t "model_spawner_node" -e "bash -c \"rosrun model_spawner_node model_spawner_node --isShadow --spawnEquipletModel -x $positionX -y $positionY $equipletName\""
fi
}
function launchShadowEquipletWithoutPrimaryNodes() {
echo "Launching shadow equiplet without primary nodes"
getEquipletName
if [ "$keepWindowOpenAfterCommandEnds" == true ]; then
gnome-terminal --title="$equipletName" \
--tab -t "equiplet_node" -e "bash -c \"rosrun equiplet_node equiplet_node --isShadow $equipletName\";bash"
else
gnome-terminal --title="$equipletName" \
--tab -t "equiplet_node" -e "bash -c \"rosrun equiplet_node equiplet_node --isShadow $equipletName\""
fi
}
function launchPartModel() {
echo "Launching part model"
getPartName
partNameToSpawn="$partName"
if [ "$cancelAction" == true ] ; then
return
fi
getOriginPlacementType
if [ "$cancelAction" == true ] ; then
return
fi
getPose
echo "bash -c \"rosrun model_spawner_node model_spawner_node --spawnPartModel --partName $partNameToSpawn \
--originPlacementType $originPlacementType \\\"$relativeTo\\\" \
-x $positionX -y $positionY -z $positionZ --pitch $rotationX --roll $rotationY --yaw $rotationZ\""
if [ "$keepWindowOpenAfterCommandEnds" == true ]; then
gnome-terminal --title="$partName" \
--tab -t "$partName" -e "bash -c \"rosrun model_spawner_node model_spawner_node --isShadow --spawnPartModel --partName $partNameToSpawn \
--originPlacementType $originPlacementType \\\"$relativeTo\\\" \
-x $positionX -y $positionY -z $positionZ --pitch $rotationX --roll $rotationY --yaw $rotationZ\";bash"
else
gnome-terminal --title="$partName" \
--tab -t "$partName" -e "bash -c \"rosrun model_spawner_node model_spawner_node --isShadow --spawnPartModel --partName $partNameToSpawn \
--originPlacementType $originPlacementType \\\"$relativeTo\\\" \
-x $positionX -y $positionY -z $positionZ --pitch $rotationX --roll $rotationY --yaw $rotationZ\""
fi
}
###################### END OF FUNCTIONS ######################
###################### USER INTERFACE ######################
echo "This script allows you to dynamically launch ROS components of REXOS";
echo "Step 1: choose primary infrastructure:"
echo "1: Launch primary infrastructure with simulation"
echo "2: Launch primary infrastructure without simulation"
echo "3: Primary infrastructure with simulation is already running"
echo "4: Primary infrastructure without simulation is already running"
echo "Q: Exit"
echo ""
echo -n "Choose option: "
read chosenOption
if [ "$chosenOption" == 1 ]; then
launchPrimaryInfrastructureWithSimulation
elif [ "$chosenOption" == 2 ]; then
launchPrimaryInfrastructureWithoutSimulation
elif [ "$chosenOption" == 3 ]; then
launchedPrimaryInfrastructureWithSimulation=true
elif [ "$chosenOption" == 4 ]; then
launchedPrimaryInfrastructureWithSimulation=false
elif [ "$chosenOption" == "Q" ] || [ "$chosenOption" == "q" ];
then
echo "Exiting"
return
else
echo "Invalid option"
return
fi
exitRequested=false
while [ "$exitRequested" == false ];
do
cancelAction=false
echo ""
echo ""
echo "Step 2: choose action:"
echo "1: Launch equiplet with primary nodes"
echo "2: Launch equiplet without primary nodes"
if [ "$launchedPrimaryInfrastructureWithSimulation" == true ]; then
echo "3: Launch simulated equiplet with primary nodes"
echo "4: Launch simulated equiplet without primary nodes"
echo "5: Launch shadow equiplet with primary nodes"
echo "6: Launch shadow equiplet without primary nodes"
echo "7: Launch equiplet model and module models only"
echo "8: Launch part model"
fi
echo "Q: Exit"
echo ""
echo -n "Choose option: "
read chosenOption
if [ "$chosenOption" == 1 ]; then
launchEquipletWithPrimaryNodes
elif [ "$chosenOption" == 2 ]; then
launchEquipletWithoutPrimaryNodes
elif [ "$chosenOption" == 3 ] && [ "$launchedPrimaryInfrastructureWithSimulation" == true ]; then
launchSimulatedEquipletWithPrimaryNodes
elif [ "$chosenOption" == 4 ] && [ "$launchedPrimaryInfrastructureWithSimulation" == true ]; then
launchSimulatedEquipletWithoutPrimaryNodes
elif [ "$chosenOption" == 5 ] && [ "$launchedPrimaryInfrastructureWithSimulation" == true ]; then
launchShadowEquipletWithPrimaryNodes
elif [ "$chosenOption" == 6 ] && [ "$launchedPrimaryInfrastructureWithSimulation" == true ]; then
launchShadowEquipletWithoutPrimaryNodes
elif [ "$chosenOption" == 8 ] && [ "$launchedPrimaryInfrastructureWithSimulation" == true ]; then
launchPartModel
elif [ "$chosenOption" == "Q" ] || [ "$chosenOption" == "q" ]; then
echo "Exiting"
exitRequested=true
else echo "Invalid option"
fi
done
###################### END OF USER INTERFACE ######################