Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardware ZED Camera Node Part 1 (Installation Overhaul) #91

Merged
merged 39 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
00fc6af
expose all gpus to docker instead of just one
alberthli Jul 24, 2024
a4081c0
fix cuda deps versions by removing nvidia channel spec in pixi.toml
alberthli Jul 24, 2024
8c7848d
minimum stuff required to see ZED cameras using sdk
alberthli Jul 24, 2024
59c8fcf
Merge branch 'main' of github.com:Caltech-AMBER/obelisk into hardware…
alberthli Jul 24, 2024
2e1f24c
clean up current setup slightly
alberthli Jul 24, 2024
3fb3aa7
revamped setup interactions with docker + exposed docker build args t…
alberthli Jul 25, 2024
a6a1538
remove errant included script
alberthli Jul 25, 2024
86edcc1
various updates to installation
alberthli Jul 25, 2024
fd6f0ad
Merge branch 'main' of github.com:Caltech-AMBER/obelisk into hardware…
alberthli Jul 25, 2024
b762b1a
consolidated python leap stuff into one package
alberthli Jul 25, 2024
d6dd271
consolidated leap cpp stuff to one package
alberthli Jul 25, 2024
8fb7da3
slight tweak to leap controller names
alberthli Jul 25, 2024
75d3612
separate leap hand deps into own opt-in group
alberthli Jul 25, 2024
18e769e
sharpen docker configuration significantly
alberthli Jul 25, 2024
c72378c
update lock file
alberthli Jul 25, 2024
5ed9c43
removed ros building pixi tasks, obk-build now builds packages condit…
alberthli Jul 25, 2024
0ce49d5
attempt to fix CI
alberthli Jul 25, 2024
ca4e940
another attempt to fix CI
alberthli Jul 25, 2024
671c995
yet another attempt at fixing CI
alberthli Jul 25, 2024
42906fb
try fixing aliases in CI by adding 'shopt -s expand_aliases'
alberthli Jul 25, 2024
e73bf0a
attempt to fix CI by sourcing bash_aliases
alberthli Jul 25, 2024
972e302
Attempt to fix CI by add aliases to docker container
alberthli Jul 25, 2024
4554965
fix missing code to attempt to fix CI
alberthli Jul 25, 2024
4347c83
update README
alberthli Jul 25, 2024
84d4222
update README
alberthli Jul 25, 2024
df4dc51
attempt to fix CI by not using aliases
alberthli Jul 25, 2024
713c760
Attempt to fix CI by running manual colcon commands with pixi executable
alberthli Jul 25, 2024
42086cd
removed dependency of all-tests on ros-build
alberthli Jul 25, 2024
dc3f3a4
make ci pixi tasks because broken CI is driving me crazy
alberthli Jul 25, 2024
f0d148c
typo
alberthli Jul 25, 2024
da6b983
remove docker obk aliases
alberthli Jul 25, 2024
a4d4e68
add ability to source ros to Dockerfile
alberthli Jul 25, 2024
b454c8b
fixed pyzed not being installed on fresh .pixi folder
alberthli Jul 25, 2024
44f0413
minor case fixed in pyzed install
alberthli Jul 25, 2024
920a279
new ruff + pytest = updated pixi.lock
alberthli Jul 25, 2024
4c59140
fix borking of pixi shell due to activation script in zed environment
alberthli Jul 25, 2024
a0915d2
fix local install without pixi by granting 755 to /usr/local/lib/pyth…
alberthli Jul 25, 2024
f069e50
add python-is-python3 because it's awesome and useful
alberthli Jul 25, 2024
837362c
add instructions on restarting the udev rules to README
alberthli Jul 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/code_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ jobs:
key: ${{ env.pythonLocation }}-${{ hashFiles('pixi.toml') }}
- name: Set Up Development Environment
run: |
source setup.sh
source setup.sh --recommended --leap
docker compose -f $GITHUB_WORKSPACE/docker/docker-compose-ci.yml up -d
- name: Build ROS2 Messages
- name: Build Obelisk ROS2 messages
run: |
docker compose -f $GITHUB_WORKSPACE/docker/docker-compose-ci.yml exec -T obelisk bash -c "$HOME/.pixi/bin/pixi run --environment dev-no-gpu messages-build"
- name: Build and Source ROS2
docker compose -f $GITHUB_WORKSPACE/docker/docker-compose-ci.yml exec -T obelisk bash -c "$HOME/.pixi/bin/pixi run --environment dev-no-gpu messages-build-ci"
- name: Build and Source Obelisk ROS2 Packages
run: |
docker compose -f $GITHUB_WORKSPACE/docker/docker-compose-ci.yml exec -T obelisk bash -c "$HOME/.pixi/bin/pixi run --environment dev-no-gpu ros-build"
docker compose -f $GITHUB_WORKSPACE/docker/docker-compose-ci.yml exec -T obelisk bash -c "$HOME/.pixi/bin/pixi run --environment dev-no-gpu ros-build-ci"
- name: Run Ruff Linter
run: |
docker compose -f $GITHUB_WORKSPACE/docker/docker-compose-ci.yml exec -T obelisk bash -c "$HOME/.pixi/bin/pixi run --environment dev-no-gpu ruff check docs/ obelisk/ tests/ --output-format=github"
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -240,5 +240,9 @@ MUJOCO_LOG.TXT
# ###### #
.vscode

# Obelisk
# ####### #
# OBELISK #
# ####### #
obk_logs/
docker/user_setup.sh
docker/install_sys_deps.sh
77 changes: 59 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,74 @@ Obelisk should be used as a dependency for external robot control code that is w
3. Use Obelisk in a project that uses `pixi`.

### Initial Setup
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth clarifying that if the user wants to use Obelisk in a custom docker container (i.e. not the one we provide) then they will want to clone this inside the docker container and run the command that modify the "system level deps", because all of the conditional building is really for the dev container and presumably the user won't want to dev their robot stack in the Obelisk dev container.

On the flip side maybe this is an overreach of the docs, but I think it might make the intended use clearer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a halfway attempt at commenting on this - if we need further clarity, let's resolve in a future PR

Initial setup proceeds by running the `setup.sh` script in the repository root. This script has the ability to make changes to your local dependencies - all such changes are opt-in. The available options are:
```
source setup.sh [--no-skip-docker] [--pixi] [--cyclone-perf] [--bash-aliases] [--obk-aliases]
```
* The `--no-skip-docker` flag installs `docker` and `nvidia-container-toolkit` on your local filesystem. You should only specify this if you want to develop in a containerized setting.
* The `--pixi` flag installs `pixi` on your local filesystem.
* The `--cyclone-perf` flag adds [performance optimizations for Cyclone DDS](https://github.com/ros2/rmw_cyclonedds?tab=readme-ov-file#performance-recommendations) in the `/etc/sysctl.d/60-cyclonedds.conf` file on your local filesystem. You should specify this if you plan to use Obelisk in a non-containerized environment.
* The `--bash-aliases` flag will check if `~/.bash_aliases` is sourced in the `~/.bashrc` file (and will add it if not already in there), and will create the `~/.bash_aliases` file if it doesn't already exist. This is a very benign flag, so we recommend using it.
* The `--obk-aliases` flag will add useful Obelisk aliases to the `~/.bash_aliases` file. **We highly recommend using this flag.**
* If you trust us, you can use the `--all` flag to just opt-in to all of these dependencies.
If you're more cautious, we recommend running
Initial setup proceeds by running the `setup.sh` script in the repository root. This script has the ability to make changes to your local dependencies - all such changes are opt-in. **It is very important that you run `setup.sh` using the `source` command, and not `bash`, because there are environment variables that will be sourced!**

This script has the ability to do 3 things:
1. configure a conditional Docker build so that the image has the right dependencies in it to run Obelisk
2. install system dependencies **on the machine running this script**
3. set up user-specific settings, including very useful bash aliases

The options are as follows:
```
source setup.sh --pixi --bash-aliases --obk-aliases
source setup.sh [OPTIONS]

Options:
--recommended Apply recommended system-level changes
(cyclone performance optimizations, pixi, obelisk aliases)

--basic Enables basic dependencies necessary for Obelisk locally
--cyclone-perf Enables cyclone performance optimizations
--leap Enables LEAP hand dependencies
--zed Enables ZED SDK

--docker-install Install Docker and nvidia-container-toolkit
--install-sys-deps-docker Installs system dependencies in Docker

--install-sys-deps Installs system dependencies
--source-ros Sources base ROS in ~/.bashrc (only used if --install-sys-deps)

--pixi Install pixi
--obk-aliases Add obelisk aliases to the ~/.bash_aliases file

--help Display this help message and exit
```

Some guidance/recommendations on choosing flags:
* If you don't have Docker on your machine, use the `--docker-install` flag
* If you are not using Docker, then you should use `--install-sys-deps`
* If you are using Docker, but not pixi, you should also use `--install-sys-deps`
* If you are using Docker, use `--install-sys-deps-docker` if and only if you are **not** using pixi within the container.
* If you are using pixi, regardless of whether you are using Docker, you should **not** use the `--basic` flag (note: you may have to manually install `mesa-common-dev`)
* If you are not using pixi or conda, you should probably use `--source-ros` along with `--install-sys-deps`
* We believe using `--pixi` will make your life easier, but you don't have to use it
* We strongly recommend using `--obk-aliases` and `--cyclone-perf`
* If you are using the LEAP Hand, use `--leap`
* If you are using ZED cameras, use `--zed`. Additionally, you will need to adjust the `udev` permissions on your host machine if you want to use the ZED cameras in a Docker container with a non-root user (if you are acting as root in your container, you probably don't need to do this next step):
```
# grab the ZED SDK installer (version 4.1.3, this README written July 25, 2024)
wget -q https://download.stereolabs.com/zedsdk/4.1/cu121/ubuntu22 -O zed_installer.run

# just pull the udev rules out of the installer
bash ./zed_installer.run --tar -x './99-slabs.rules' > /dev/null 2>&1

# copy the rules to the right directory, make them executable, and reload udev permissions
sudo mv "./99-slabs.rules" "/etc/udev/rules.d/"
sudo chmod 777 "/etc/udev/rules.d/99-slabs.rules"
sudo udevadm control --reload-rules && sudo udevadm trigger

# remove the installer
rm zed_installer.run
```

If you're installing `docker` for the first time using this script, you also need to run afterwards
```
newgrp docker
```

### Building Obelisk
### Building Obelisk ROS Packages
Next, since Obelisk acts as a dependency for a downstream ROS2 project, you have to build it. You can either build it on your local filesystem or in a virtual environment that we manage using `pixi`.

* If you are building it on your local filesystem, you need some minimal set of local dependencies. You can install these by running
```
bash scripts/install_sys_deps.sh
```
This will prompt you to confirm changes to your local filesystem. To auto-accept the installations, use the `-y` flag. To source the base ROS installation in the `~/.bashrc` without prompting, use the `--source-ros` flag. To not source it without prompting, use the `--no-source-ros` flag.
* If you are building it on your local filesystem, you need some minimal set of local dependencies. These should have been installed in the previous step.

If you have run the initial setup script with the `--obk-aliases` flag, then running
```
Expand Down
45 changes: 35 additions & 10 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,34 @@
FROM ubuntu:22.04 as base
SHELL ["/bin/bash", "-c"]

# username, uid, gid
# username, uid, gid, and conditional build args
ARG USER=user
ARG UID=1000
ARG GID=1000
ARG OBELISK_ROOT=/
ARG OBELISK_DOCKER_BASIC=false
ARG OBELISK_DOCKER_CYCLONE_PERF=false
ARG OBELISK_DOCKER_LEAP=false
ARG OBELISK_DOCKER_ZED=false
ARG OBELISK_DOCKER_PIXI=false

ENV USER=$USER
ENV UID=$UID
ENV GID=$GID
ENV OBELISK_ROOT=$OBELISK_ROOT
ENV OBELISK_DOCKER_BASIC=$OBELISK_DOCKER_BASIC
ENV OBELISK_DOCKER_CYCLONE_PERF=$OBELISK_DOCKER_CYCLONE_PERF
ENV OBELISK_DOCKER_LEAP=$OBELISK_DOCKER_LEAP
ENV OBELISK_DOCKER_ZED=$OBELISK_DOCKER_ZED
ENV OBELISK_DOCKER_PIXI=$OBELISK_DOCKER_PIXI

ENV XDG_RUNTIME_DIR=/run/user/${UID}

# set timezone
# set timezone (used by ROS dependencies)
ENV TZ=America/Los_Angeles
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# basic dependencies that are not handled by pixi
# mandatory dependencies that are not handled by pixi
RUN apt-get update && apt-get install -y \
curl \
git \
Expand All @@ -29,22 +41,35 @@ RUN apt-get update && apt-get install -y \
rm -rf /var/lib/apt/lists/* && \
locale-gen en_US.UTF-8

# create non-root user with sudo privileges for certain commands
# create non-root user with sudo privileges
RUN groupadd --gid $GID $USER && \
useradd --uid $UID --gid $GID -m $USER -d /home/${USER} --shell /usr/bin/bash && \
echo "${USER}:password" | chpasswd && \
usermod -aG sudo ${USER} && \
echo "%${USER} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

# add user to dialout group to enable serial port access from the container
RUN usermod -a -G dialout ${USER}
# conditionally install dependencies based on build args
# source base ROS if basic deps are installed and you are not using pixi
COPY install_sys_deps.sh /tmp/install_sys_deps.sh
RUN FLAGS=""; \
[ "$OBELISK_DOCKER_BASIC" = "true" ] && FLAGS="$FLAGS --basic"; \
[ "$OBELISK_DOCKER_CYCLONE_PERF" = "true" ] && FLAGS="$FLAGS --cyclone-perf"; \
[ "$OBELISK_DOCKER_BASIC" = "true" ] && [ "$OBELISK_DOCKER_PIXI" = "false" ] && FLAGS="$FLAGS --source-ros"; \
[ "$OBELISK_DOCKER_LEAP" = "true" ] && FLAGS="$FLAGS --leap"; \
[ "$OBELISK_DOCKER_ZED" = "true" ] && FLAGS="$FLAGS --zed"; \
bash /tmp/install_sys_deps.sh $FLAGS && \
sudo rm /tmp/install_sys_deps.sh

# switch to new user and workdir
USER ${UID}

# run docker setup script in Dockerfile
COPY docker_setup.sh /tmp/docker_setup.sh
RUN source /tmp/docker_setup.sh --pixi --cyclone-perf && \
sudo rm /tmp/docker_setup.sh
# run user setup script in Dockerfile
# these are deps that can/should be installed without root access
# obelisk aliases are mounted, so we don't create them here
COPY user_setup.sh /tmp/user_setup.sh
RUN FLAGS=""; \
[ "$OBELISK_DOCKER_PIXI" = "true" ] && FLAGS="$FLAGS --pixi"; \
source /tmp/user_setup.sh $FLAGS && \
sudo rm /tmp/user_setup.sh

WORKDIR /home/${USER}
2 changes: 2 additions & 0 deletions docker/docker-compose-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ services:
UID: $UID
GID: $UID
OBELISK_ROOT: $OBELISK_ROOT
OBELISK_DOCKER_PIXI: true
dockerfile: Dockerfile
network_mode: host
ipc: host
Expand All @@ -17,6 +18,7 @@ services:
UID: $UID
GID: $UID
OBELISK_ROOT: $OBELISK_ROOT
OBELISK_DOCKER_PIXI: true
QT_X11_NO_MITSHM: 1
security_opt:
- seccomp=unconfined
Expand Down
8 changes: 8 additions & 0 deletions docker/docker-compose-no-gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ services:
UID: $UID
GID: $UID
OBELISK_ROOT: $OBELISK_ROOT
OBELISK_DOCKER_BASIC: $OBELISK_DOCKER_BASIC
OBELISK_DOCKER_CYCLONE_PERF: $OBELISK_DOCKER_CYCLONE_PERF
OBELISK_DOCKER_LEAP: $OBELISK_DOCKER_LEAP
OBELISK_DOCKER_PIXI: $OBELISK_DOCKER_PIXI
dockerfile: Dockerfile
network_mode: host
ipc: host
Expand All @@ -17,6 +21,10 @@ services:
UID: $UID
GID: $UID
OBELISK_ROOT: $OBELISK_ROOT
OBELISK_DOCKER_BASIC: $OBELISK_DOCKER_BASIC
OBELISK_DOCKER_CYCLONE_PERF: $OBELISK_DOCKER_CYCLONE_PERF
OBELISK_DOCKER_LEAP: $OBELISK_DOCKER_LEAP
OBELISK_DOCKER_PIXI: $OBELISK_DOCKER_PIXI
QT_X11_NO_MITSHM: 1
security_opt:
- seccomp=unconfined
Expand Down
12 changes: 11 additions & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ services:
UID: $UID
GID: $UID
OBELISK_ROOT: $OBELISK_ROOT
OBELISK_DOCKER_BASIC: $OBELISK_DOCKER_BASIC
OBELISK_DOCKER_CYCLONE_PERF: $OBELISK_DOCKER_CYCLONE_PERF
OBELISK_DOCKER_LEAP: $OBELISK_DOCKER_LEAP
OBELISK_DOCKER_ZED: $OBELISK_DOCKER_ZED
OBELISK_DOCKER_PIXI: $OBELISK_DOCKER_PIXI
dockerfile: Dockerfile
network_mode: host
ipc: host
Expand All @@ -18,6 +23,11 @@ services:
UID: $UID
GID: $UID
OBELISK_ROOT: $OBELISK_ROOT
OBELISK_DOCKER_BASIC: $OBELISK_DOCKER_BASIC
OBELISK_DOCKER_CYCLONE_PERF: $OBELISK_DOCKER_CYCLONE_PERF
OBELISK_DOCKER_LEAP: $OBELISK_DOCKER_LEAP
OBELISK_DOCKER_ZED: $OBELISK_DOCKER_ZED
OBELISK_DOCKER_PIXI: $OBELISK_DOCKER_PIXI
QT_X11_NO_MITSHM: 1
security_opt:
- seccomp=unconfined
Expand All @@ -40,7 +50,7 @@ services:
reservations:
devices:
- driver: nvidia
count: 1
count: all
capabilities: [ gpu ]
working_dir: $OBELISK_ROOT
stdin_open: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ namespace obelisk {
/**
* @brief Controller that generates a sinusoidal position setpoint for the Leap hand
*/
class LeapPositionSetpointController : public ObeliskController<leap_controller_msg, leap_estimator_msg> {
class LeapExamplePositionSetpointController : public ObeliskController<leap_controller_msg, leap_estimator_msg> {
public:
/**
* @brief Construct a new Leap Position Setpoint Controller object
*
* @param name Name of the controller
*/
LeapPositionSetpointController(const std::string& name)
LeapExamplePositionSetpointController(const std::string& name)
: ObeliskController<leap_controller_msg, leap_estimator_msg>(name) {}

protected:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from obelisk_py.core.obelisk_typing import ObeliskControlMsg, ObeliskEstimatorMsg, is_in_bound


class LeapPositionSetpointController(ObeliskController):
class LeapExamplePositionSetpointController(ObeliskController):
"""Example position setpoint controller."""

def __init__(self, node_name: str = "example_position_setpoint_controller") -> None:
def __init__(self, node_name: str = "leap_example_position_setpoint_controller") -> None:
"""Initialize the example position setpoint controller."""
super().__init__(node_name)

Expand Down
35 changes: 0 additions & 35 deletions obelisk_ws/src/cpp/obelisk_leap_control_cpp/CMakeLists.txt

This file was deleted.

21 changes: 0 additions & 21 deletions obelisk_ws/src/cpp/obelisk_leap_control_cpp/package.xml

This file was deleted.

This file was deleted.

Loading