-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlaunch_as2.bash
executable file
·90 lines (77 loc) · 2.39 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
#!/bin/bash
usage() {
echo "Usage: $0 [-r] [-t]"
echo " options:"
echo " -r: record rosbag"
echo " -t: launch keyboard teleoperation"
}
# Arg parser
while getopts "rth" opt; do
case ${opt} in
r )
record_rosbag="true"
;;
t )
launch_keyboard_teleop="true"
;;
h )
usage
exit 0
;;
\? )
echo "Invalid option: -$OPTARG" >&2
usage
exit 1
;;
: )
if [[ ! $OPTARG =~ ^[rt]$ ]]; then
echo "Option -$OPTARG requires an argument" >&2
usage
exit 1
fi
;;
esac
done
# Shift optional args
shift $((OPTIND -1))
## OVERIDE MODEL PATH TO GET FIRST MODELS FROM PROJECT (planar_lidar)
export IGN_GAZEBO_RESOURCE_PATH=$PWD/assets/worlds:$PWD/assets/models:$IGN_GAZEBO_RESOURCE_PATH
export GZ_SIM_RESOURCE_PATH=$PWD/assets/worlds:$PWD/assets/models:$GZ_SIM_RESOURCE_PATH
## DEFAULTS
record_rosbag=${record_rosbag:="false"}
launch_keyboard_teleop=${launch_keyboard_teleop:="false"}
# CHOOSE SIMULATION CONFIG FILE
echo "Choose simulation config file to open:"
cat -n <(ls -1 assets/worlds/*.json) # list json files
simulation_config=$(python utils/pick_sim_config.py assets/worlds | tail -n 1)
if [[ ${simulation_config} == "Invalid" ]]; then
echo "Invalid option" >&2
exit 1
fi
estimator_plugin="ground_truth"
rviz_config="assets/rviz/three_drone.rviz"
# Get drone namespaces from swarm config file
drones=$(python utils/get_drones.py ${simulation_config})
tmuxinator start -p tmuxinator/gazebo.yml \
simulation_config=${simulation_config} &
sleep 20
tmuxinator start -p tmuxinator/aerostack2.yml \
drones=${drones} \
simulation_config=${simulation_config} \
rviz_config=${rviz_config} &
wait
if [[ ${record_rosbag} == "true" ]]; then
tmuxinator start -p tmuxinator/rosbag.yml \
drones=${drones} &
wait
fi
if [[ ${launch_keyboard_teleop} == "true" ]]; then
# TODO: Keyboard Teleop uses ',' as separator for drone namespaces
drones_sep=$(python utils/get_drones.py ${simulation_config} --sep ",")
tmuxinator start -p tmuxinator/keyboard_teleop.yml \
simulation=true \
drones=${drones_sep} &
wait
fi
# Attach to tmux session aerostack2, window 0
tmux attach-session -t aerostack2:alphanumeric_viewer