-
Notifications
You must be signed in to change notification settings - Fork 0
/
env.sh
72 lines (59 loc) · 2.52 KB
/
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
69
70
71
72
#!/bin/bash
# ----------------------------------------------------------------------
#
# This script configures a terminal environment
# to run properly in interaction with this repository
#
# ----------------------------------------------------------------------
WORKSPACE_ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source ~/.bashrc
# ROS2 specific environment
if [ -d /opt/ros ]; then
source /opt/ros/humble/setup.bash
fi
if [ -d /usr/share/colcon_cd ]; then
source /usr/share/colcon_cd/function/colcon_cd.sh
export _colcon_cd_root=/opt/ros/humble/
fi
if [ -d /usr/share/colcon_argcomplete ]; then
source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash
fi
if [ -f "${WORKSPACE_ROOT_DIR}/install/local_setup.bash" ]; then
source "${WORKSPACE_ROOT_DIR}/install/local_setup.bash"
fi
#
# Add local python packages to PYTHONPATH
#
PYTHON_VERSION="python3.10" # Replace with your Python version
# Check if the workspace is using merge-install (look for 'install/local/lib/<python_version>/dist-packages')
MERGE_INSTALL_PATH="$WORKSPACE_ROOT_DIR/install/local/lib/$PYTHON_VERSION/dist-packages"
if [ -d "$MERGE_INSTALL_PATH" ]; then
# Merge-install setup detected
# echo "Merge-install setup detected."
export PYTHONPATH="$MERGE_INSTALL_PATH:$PYTHONPATH"
else
# Non-merge-install setup detected
# echo "Non-merge-install setup detected."
# Loop through all packages in the workspace src directory
for PACKAGE in "$WORKSPACE_ROOT_DIR"/src/*; do
SITE_PACKAGES_PATH="$WORKSPACE_ROOT_DIR/install/$(basename "$PACKAGE")/local/lib/$PYTHON_VERSION/dist-packages"
if [ -d "$SITE_PACKAGES_PATH" ]; then
# Append the dist-packages path to PYTHONPATH if it exists
export PYTHONPATH="$SITE_PACKAGES_PATH:$PYTHONPATH"
fi
done
fi
#
# Related programs
#
export PX4_ROS2_ENV_DEFAULT_BASE_DIR="$HOME/Desktop"
# Change these variables if necessary
export PX4_ROS2_ENV_PX4_AUTOPILOT_DIR="${PX4_ROS2_ENV_DEFAULT_BASE_DIR}/PX4-Autopilot"
export PX4_ROS2_ENV_QGROUNDCONTROL_APP="${PX4_ROS2_ENV_DEFAULT_BASE_DIR}/QGroundControl.AppImage"
export PX4_ROS2_ENV_GROOT2_APP="${PX4_ROS2_ENV_DEFAULT_BASE_DIR}/Groot2-v1.6.1-x86_64.AppImage"
if [ -f "$PX4_ROS2_ENV_QGROUNDCONTROL_APP" ] && [ $(stat -c "%a" "$PX4_ROS2_ENV_QGROUNDCONTROL_APP") -ne 755 ]; then
chmod +x "$PX4_ROS2_ENV_QGROUNDCONTROL_APP"
fi
if [ -f "$PX4_ROS2_ENV_GROOT2_APP" ] && [ $(stat -c "%a" "$PX4_ROS2_ENV_GROOT2_APP") -ne 755 ]; then
chmod +x "$PX4_ROS2_ENV_GROOT2_APP"
fi