Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 3 additions & 4 deletions .devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"--ipc=host",
"--privileged"
],
"containerUser": "cev",
"containerEnv": {
"DISPLAY": "${localEnv:DISPLAY}"
},
Expand All @@ -20,10 +21,8 @@
"customizations": {
"vscode": {
"extensions": [
"ms-iot.vscode-ros",
"ms-vscode.cpptools-extension-pack",
"ms-python.black-formatter",
"xaver.clang-format"
"llvm-vs-code-extensions.vscode-clangd"
],
"settings": {
"terminal.integrated.defaultProfile.linux": "bash",
Expand All @@ -33,7 +32,7 @@
}
},
"[cpp]": {
"editor.defaultFormatter": "xaver.clang-format"
"editor.defaultFormatter": "llvm-vs-code-extensions.vscode-clangd"
},
"[python]": {
"diffEditor.ignoreTrimWhitespace": false,
Expand Down
21 changes: 16 additions & 5 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,28 @@ on:
branches: [ "main" ]

jobs:

build:

build-deploy:
runs-on: ubuntu-22.04

steps:
- name: Fetch recursively
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build the Docker image
run: docker build . --file Dockerfile.deploy --tag rc-brain-deploy:$(date +%s)

build-dev:
runs-on: ubuntu-22.04
steps:
- name: Fetch recursively
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build the Docker image
run: docker build . --file Dockerfile --tag my-image-name:$(date +%s)
run: docker build . --file Dockerfile.dev --tag rc-brain-dev:$(date +%s)
56 changes: 0 additions & 56 deletions Dockerfile

This file was deleted.

48 changes: 27 additions & 21 deletions Dockerfile.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ FROM ros:humble

SHELL ["/bin/bash", "-c"]

# Set up CEV user
RUN useradd -m -s /bin/bash cev
RUN usermod -aG sudo cev
# Grant passwordless sudo access to the 'sudo' group
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
Comment thread
utkudotdev marked this conversation as resolved.
USER cev

# Docker doesn't do this by default
RUN sudo chown -R cev /home/cev


ARG FOLDER_NAME=rc-brain
ARG WORKSPACE_DIR=/home/cev
WORKDIR $WORKSPACE_DIR
Expand All @@ -12,36 +23,31 @@ RUN echo "source /opt/ros/$ROS_DISTRO/setup.bash" >> ~/.bashrc
RUN echo "source $WORKSPACE_DIR/install/setup.bash" >> ~/.bashrc

# Init rosdep and update package index
# for some reason we need to do this
RUN rm /var/lib/dpkg/info/libc-bin.*
RUN apt-get clean
RUN apt-get update
RUN apt-get install libc-bin
RUN sudo apt-get update
RUN rosdep update --rosdistro $ROS_DISTRO

RUN mkdir -p src/$FOLDER_NAME

# Install and build build-from-source packages
# We do this as a separate step from the stuff for our code, since that changes more frequently
RUN cd src && \
git clone https://github.com/Slamtec/sllidar_ros2.git && \
cd sllidar_ros2 && \
git checkout 3430009
COPY --chown=cev --parents external/**/package.xml src/$FOLDER_NAME/
RUN source /opt/ros/$ROS_DISTRO/setup.bash && rosdep install --from-paths src -r -y
RUN source /opt/ros/$ROS_DISTRO/setup.bash && colcon build

# Install self dependencies with rosdep
COPY --parents ./*/package.xml src/$FOLDER_NAME
# Run install_extra.sh, which installs additional dependencies
COPY --chown=cev scripts/install_extra.sh src/$FOLDER_NAME/scripts/
RUN sudo src/$FOLDER_NAME/scripts/install_extra.sh

# Finally build external packages
COPY --chown=cev external src/$FOLDER_NAME/external/
RUN source /opt/ros/$ROS_DISTRO/setup.bash && colcon build --symlink-install

# Install all other dependencies
COPY --chown=cev --parents **/package.xml src/$FOLDER_NAME/
RUN source /opt/ros/$ROS_DISTRO/setup.bash && rosdep install --from-paths src -r -y

# Clean up apt cache to make container smaller
RUN apt-get clean
RUN sudo apt-get clean

# Build
COPY . src/$FOLDER_NAME
RUN source /opt/ros/$ROS_DISTRO/setup.bash && colcon build
COPY --chown=cev . src/$FOLDER_NAME
RUN source /opt/ros/$ROS_DISTRO/setup.bash && colcon build --symlink-install

# Copy entrypoint script
COPY entrypoint.sh entrypoint.sh
RUN chmod +x entrypoint.sh
ENTRYPOINT ["/bin/bash", "/home/cev/entrypoint.sh"]
ENTRYPOINT ["/bin/bash", "/home/cev/src/rc-brain/scripts/deployed_entrypoint.sh"]
52 changes: 26 additions & 26 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,44 @@ FROM ros:humble

SHELL ["/bin/bash", "-c"]

# Set up CEV user
RUN useradd -m -s /bin/bash cev
RUN usermod -aG sudo cev
# Grant passwordless sudo access to the 'sudo' group
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
USER cev

ARG FOLDER_NAME=rc-brain
ARG WORKSPACE_DIR=/home/cev
WORKDIR $WORKSPACE_DIR

# Docker doesn't do this by default
RUN sudo chown -R cev /home/cev

# Source the ROS2 environment automatically when a new shell is created
RUN echo "source /opt/ros/$ROS_DISTRO/setup.bash" >> ~/.bashrc
RUN echo "source $WORKSPACE_DIR/install/setup.bash" >> ~/.bashrc

# Install dev tools
RUN apt-get update
RUN apt-get install -y curl
RUN curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
RUN cat /etc/apt/trusted.gpg.d/apt.llvm.org.asc
RUN echo $'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy main\n' \
$'deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy main\n' \
$'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main\n' \
$'deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main\n' \
$'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-19 main\n' \
$'deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-19 main\n' \
| tee -a /etc/apt/sources.list
RUN apt-get update
RUN apt-get install -y clang-format clang-format-19
RUN sudo apt-get update
# Tools required to run clang install
RUN sudo apt-get install -y \
curl \
lsb-release \
software-properties-common \
gnupg
RUN curl -fsSL https://apt.llvm.org/llvm.sh | sudo bash -s -- 19
RUN sudo apt-get install -y clangd-19
RUN sudo update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-19 100

# Init rosdep and update package index
# for some reason we need to do this
RUN rm /var/lib/dpkg/info/libc-bin.*
RUN apt-get clean
RUN apt-get update
RUN apt-get install -y libc-bin
RUN rosdep update --rosdistro $ROS_DISTRO

RUN mkdir -p src/$FOLDER_NAME

# Copy install.sh
COPY --parents ./install.sh src/$FOLDER_NAME

# Run install.sh
RUN src/$FOLDER_NAME/install.sh
# Run install_extra.sh, which installs additional dependencies
COPY --chown=cev scripts/install_extra.sh src/$FOLDER_NAME/scripts/
RUN sudo src/$FOLDER_NAME/scripts/install_extra.sh

COPY --parents ./*/package.xml src/$FOLDER_NAME
# Install own dependencies
RUN mkdir -p src/$FOLDER_NAME
COPY --chown=cev --parents **/package.xml src/$FOLDER_NAME/
RUN source /opt/ros/$ROS_DISTRO/setup.bash && rosdep install --from-paths src -r -y
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
# rc-brain
One repo to rule them all

## Installation
## Installation (local)
`git clone --recurse-submodules https://github.com/cornellev/rc-brain.git`
`cd rc-brain && sudo ./install.sh`

## Docker
`docker build -t cev-rc-autonomy .`
Then run either
`docker run --rm ros2-autonomy launch`
or
`docker run --rm ros2-autonomy teleop`
`cd rc-brain && sudo ./scripts/install_extra.sh`

## Development

Expand All @@ -21,12 +14,25 @@ Run `./scripts/deploy/arduino_deploy.sh` to compile and flash code to the arduin
#### Formatting
If you're not using the DevContainer, please make sure to install `clang-format`, ideally version 19! This will help keep the formatting of our C++ code formatted consistently. Python code is formatted by `black`. The DevContainer will install the `Black` extension for you, which ships with `black`, but otherwise you'll need to install it in VSCode or whatever other IDE you're using.

### Docker (DevContainer)
Everything should pretty much work out of the box, except...
> [!WARNING]
> You must have the Docker buildx plugin installed to build the image correctly. You may get very confusing failures!
> On Ubuntu, you can install the `docker-buildx-plugin` package.

### Deployment

#### Regular deployment
If you're just developing, building Docker images will probably take too long. You can deploy normally just by running `scripts/deploy.sh`. It will drop you into an interactive session at the end so you can launch whatever you want to.

#### Docker deployment
Use `docker build . --file Dockerfile.deploy -t rc-brain-deploy:latest` to build the deploy container.
Then run either `docker run --rm rc-brain-deploy launch` or `docker run --rm rc-brain-deploy teleop` to launch.

> [!WARNING]
> You must have the Docker buildx plugin installed to build the image correctly. You may get very confusing failures!
> On Ubuntu, you can install the `docker-buildx-plugin` package.

Our Docker deployment pipeline works by pushing Docker images to a local registry and pulling them down on the mini cars. This avoids both long build times on the mini cars and the long time it takes to transfer whole images (as we can take advantage of Docker's cache).

You'll have to do a bit of setup to get your computer to use the local registry. Note that you must be connected to `cev-router`.
Expand Down
11 changes: 0 additions & 11 deletions install.sh

This file was deleted.

File renamed without changes.
11 changes: 11 additions & 0 deletions scripts/install_extra.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
apt-get install -y \
libeigen3-dev \
libnlopt-dev \
libnlopt-cxx-dev \
libopencv-dev \
libyaml-cpp-dev \
libqt5serialport5-dev \
libsuitesparse-dev \
libceres-dev \
ros-humble-slam-toolbox
Comment thread
utkudotdev marked this conversation as resolved.
Comment thread
utkudotdev marked this conversation as resolved.