forked from TIERS/drone_racing_ros2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_env.sh
executable file
·68 lines (52 loc) · 1.61 KB
/
setup_env.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
#!/bin/bash
echo $'\nLoading Tello ROS Package Environment...\n'
# Load the current directory
curr_dir=$(pwd)
echo $"Current Directory: $curr_dir"
# Find the Tello ROS Package to source
setup=$(find "${curr_dir}/install" -type f -name "setup.bash" | grep -E setup.bash$)
# Verify if the setup file was found
if [[ -z "$setup" ]]; then
echo $"\nCould not find setup.bash file under the install directory."
exit 1
fi
# Print the setup file
echo $'\nSetup File:'
echo "$setup"
# Find the Tello model directory
model_dir=$(find "${curr_dir}/install" -type d -name "models" | grep -E models$)
# Verify if the model directory was found
if [[ -z "$model_dir" ]]; then
echo $'\nCould not find tello_gazebo model directory.'
exit 1
fi
# Print the models directory (only the first one)
echo $'\nModel Directory:'
echo "$model_dir"
# Source the Tello ROS Package
source $setup
# Add the path models to the GAZEBO_MODEL_PATH variable (if it exists and is not already there)
if [[ -n "$GAZEBO_MODEL_PATH" ]]; then
if [[ ! "$GAZEBO_MODEL_PATH" == *"$model_dir"* ]]; then
export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:$model_dir
fi
else
export GAZEBO_MODEL_PATH=$model_dir
fi
# Source Gazebo
gazebo_setup=/usr/share/gazebo/setup.sh
source $gazebo_setup
# Print Gazebo setup file
echo $'\nGazebo Setup File:'
echo "$gazebo_setup"
# Source ROS
ros_setup=/opt/ros/galactic/setup.bash
source $ros_setup
# Print ROS setup file
echo $'\nROS Setup File:'
echo "$ros_setup"
# Generate a random number between 1 and 99
rand_num=$((1 + RANDOM % 99))
export ROS_DOMAIN_ID=$rand_num
# Print the ROS_DOMAIN_ID
echo $'\nROS_DOMAIN_ID: '$ROS_DOMAIN_ID