-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlaunch_as2.bash
executable file
·115 lines (100 loc) · 2.77 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
usage() {
echo " options:"
echo " -s: simulated, choices: [true | false]"
echo " -m: multi agent, choices: [true | false]"
echo " -e: estimator_type, choices: [ground_truth, raw_odometry, mocap_pose]"
echo " -r: record rosbag"
echo " -t: launch keyboard teleoperation"
echo " -n: drone namespace, default is cf0"
}
# Arg parser
while getopts "se:mrtn" opt; do
case ${opt} in
s )
simulated="true"
;;
m )
swarm="true"
;;
e )
estimator_plugin="${OPTARG}"
;;
r )
record_rosbag="true"
;;
t )
launch_keyboard_teleop="true"
;;
n )
drone_namespace="${OPTARG}"
;;
\? )
echo "Invalid option: -$OPTARG" >&2
usage
exit 1
;;
: )
if [[ ! $OPTARG =~ ^[swrt]$ ]]; 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
simulated=${simulated:="false"} # default ign_gz
if [[ ${simulated} == "false" && -z ${estimator_plugin} ]]; then
echo "Error: when -s is false, -e argument must be set" 1>&2
usage
exit 1
fi
swarm=${swarm:="false"}
estimator_plugin=${estimator_plugin:="ground_truth"} # default ign_gz
record_rosbag=${record_rosbag:="false"}
launch_keyboard_teleop=${launch_keyboard_teleop:="false"}
drone_namespace=${drone_namespace:="cf"}
if [[ ${swarm} == "true" ]]; then
num_drones=2
simulation_config="sim_config/world_swarm.json"
else
num_drones=1
simulation_config="sim_config/world.json"
fi
# 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
if [[ ${ns} == ${drone_ns[0]} ]]; then
base_launch="true"
else
base_launch="false"
fi
tmuxinator start -n ${ns} -p utils/session.yml drone_namespace=${ns} base_launch=${base_launch} estimator_plugin=${estimator_plugin} simulation=${simulated} simulation_config=${simulation_config} &
wait
done
if [[ ${estimator_plugin} == "mocap_pose" ]]; then
tmuxinator start -n mocap -p utils/mocap4ros2.yml &
wait
fi
if [[ ${record_rosbag} == "true" ]]; then
tmuxinator start -n rosbag -p utils/rosbag.yml drone_namespace=$(list_to_string "${drone_ns[@]}") &
wait
fi
if [[ ${launch_keyboard_teleop} == "true" ]]; then
tmuxinator start -n keyboard_teleop -p utils/keyboard_teleop.yml simulation=true drone_namespace=$(list_to_string "${drone_ns[@]}") &
wait
fi
if [[ ${simulated} == "true" ]]; then
tmuxinator start -n gazebo -p utils/gazebo.yml simulation_config=${simulation_config} &
wait
fi
# Attach to tmux session ${drone_ns[@]}, window 0
tmux attach-session -t ${drone_ns[0]}:mission