-
Notifications
You must be signed in to change notification settings - Fork 0
/
launch_as2.bash
executable file
·92 lines (77 loc) · 2.18 KB
/
launch_as2.bash
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
#!/bin/bash
usage() {
echo " options:"
echo " -b: launch behavior tree"
echo " -t: launch keyboard teleoperation"
echo " -n: n drones, default is 1"
echo " -p: n drones, default is 1"
echo " -r: n drones, default is 1"
}
# Arg parser
while getopts "n:p:r:brt" opt; do
case ${opt} in
b )
behavior_tree="true"
;;
t )
launch_keyboard_teleop="true"
;;
n )
num_drones=${OPTARG}
;;
p )
num_panels=${OPTARG}
;;
r )
num_rows=${OPTARG}
;;
\? )
echo "Invalid option: -$OPTARG" >&2
usage
exit 1
;;
: )
if [[ ! $OPTARG =~ ^[wrt]$ ]]; then
echo "Option -$OPTARG requires an argument" >&2
usage
exit 1
fi
;;
esac
done
source utils/tools.bash
# Shift optional args
shift $((OPTIND -1))
## DEFAULTS
behavior_tree=${behavior_tree:="false"}
swarm=${swarm:="false"}
record_rosbag="false"
launch_keyboard_teleop=${launch_keyboard_teleop:="false"}
drone_namespace="drone"
export GZ_SIM_RESOURCE_PATH=$PWD/assets/worlds:$GZ_SIM_RESOURCE_PATH
export GZ_SIM_RESOURCE_PATH=$PWD/assets/models:$GZ_SIM_RESOURCE_PATH
echo $num_drones
python3 scripts/world_customizer.py $num_drones $num_panels $num_rows
simulation_config="assets/worlds/solar_field.json"
# Generate the list of drone namespaces
drone_ns=()
for ((i=0; i<${num_drones}; i++)); do
drone_ns+=("$drone_namespace$i")
done
for ns in "${drone_ns[@]}"
do
tmuxinator start -n ${ns} -p tmuxinator/session.yml drone_namespace=${ns} simulation_config=${simulation_config} behavior_tree=${behavior_tree} &
wait
done
if [[ ${record_rosbag} == "true" ]]; then
tmuxinator start -n rosbag -p tmuxinator/rosbag.yml drone_namespace=$(list_to_string "${drone_ns[@]}") &
wait
fi
if [[ ${launch_keyboard_teleop} == "true" ]]; then
tmuxinator start -n keyboard_teleop -p tmuxinator/keyboard_teleop.yml simulation=true drone_namespace=$(list_to_string "${drone_ns[@]}") &
wait
fi
tmuxinator start -n gazebo -p tmuxinator/gazebo.yml simulation_config=${simulation_config} &
wait
# Attach to tmux session ${drone_ns[@]}, window mission
tmux attach-session -t ${drone_ns[0]}:mission