Repository navigation
Expand file tree
/
Copy pathenv.sh
More file actions
executable file
·66 lines (58 loc) · 2.54 KB
/
Copy pathenv.sh
File metadata and controls
executable file
·66 lines (58 loc) · 2.54 KB
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
# Activates the emdb-simulator dev environment in the current shell.
# Source this (from bash) in every new terminal, don't execute it:
# source env.sh
#
# Replaces the old machine-specific setup_tfm.sh / setup_desktop_casa.sh,
# which hardcoded a single computer's absolute path.
#
# Override the venv location (must match what setup.sh used) with:
# VENV_DIR=/path/to/venv source env.sh
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
VENV_DIR="${VENV_DIR:-$REPO_ROOT/.venv}"
# 1. ROS 2 first, so its PYTHONPATH additions are in place before the venv
# (which does not have access to system site-packages) is activated.
if [ -z "${ROS_DISTRO:-}" ]; then
for d in /opt/ros/*/; do
if [ -f "$d/setup.bash" ]; then
ROS_DISTRO="$(basename "$d")"
break
fi
done
fi
if [ -n "${ROS_DISTRO:-}" ]; then
# shellcheck disable=SC1090
source "/opt/ros/$ROS_DISTRO/setup.bash"
else
echo "env.sh: no ROS 2 installation found under /opt/ros" >&2
fi
# 2. Python virtualenv.
if [ -f "$VENV_DIR/bin/activate" ]; then
# shellcheck disable=SC1091
source "$VENV_DIR/bin/activate"
else
echo "env.sh: no venv at $VENV_DIR -- run ./setup.sh first" >&2
fi
# 3. DDS implementation (only if not already chosen by the user/shell).
export RMW_IMPLEMENTATION="${RMW_IMPLEMENTATION:-rmw_cyclonedds_cpp}"
# 4. MuJoCo headless rendering via EGL, needed on machines without a
# working GLFW/OpenGL context (works around a GL_INVALID_VALUE/0x501
# error some GPU/driver combos hit). Unset MUJOCO_GL before sourcing
# this file if your machine renders fine without it.
export MUJOCO_GL="${MUJOCO_GL:-egl}"
# 5. The workspace's own built packages.
if [ -f "$REPO_ROOT/ros_packages/install/setup.bash" ]; then
# shellcheck disable=SC1091
source "$REPO_ROOT/ros_packages/install/setup.bash"
else
echo "env.sh: workspace not built yet -- run ./setup.sh first" >&2
fi
# 6. Colcon autocompletion, if available on this machine.
if [ -f /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash ]; then
# shellcheck disable=SC1091
source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash
fi
# 7. Convenience aliases, using this venv's python explicitly.
alias colcon_dev="$VENV_DIR/bin/python -m colcon build --symlink-install"
alias colcon_clean_build="cd $REPO_ROOT/ros_packages && rm -rf build install log && $VENV_DIR/bin/python -m colcon build --symlink-install"
alias emdb_env='echo ROS=$(which ros2) && echo PY=$(which python) && python -c "import sys; print(sys.executable)"'
unset REPO_ROOT VENV_DIR