Skip to content
Open
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
112 changes: 112 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Test Colcon Build
on:
pull_request:
branches:
- main
push:

jobs:
lint_and_format:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: recursive
token: ${{ secrets.GH_PAT }}

- name: Install clang-format
run: |
sudo apt-get update
sudo apt-get install -y clang-format

- name: Check formatting
run: |
find src -iname *.h -o -iname *.hpp -o -iname *.cpp -o -iname *.c | xargs clang-format --dry-run --Werror

- name: Install Ruff
run: pip install ruff

- name: Check Python formatting
run: ruff format --check .

- name: Check Python linting
run: ruff check .

# Currently this takes 3+ minutes, but I'm keeping this here if we ever need it
# build:
# needs: format
# runs-on: ubuntu-22.04
# container:
# image: ros:humble-ros-base

# steps:
# - name: Checkout code
# uses: actions/checkout@v3
# with:
# submodules: recursive
# token: ${{ secrets.GH_PAT }}

# - name: Cache Python dependencies
# uses: actions/cache@v3
# id: cache-venv
# with:
# path: .venv
# key: venv-${{ runner.os }}-${{ hashFiles('requirements/all_requirements.txt') }}
# restore-keys: |
# venv-${{ runner.os }}-

# - name: Cache rosdep packages
# uses: actions/cache@v3
# id: cache-rosdep
# with:
# path: |
# /var/cache/apt/archives
# /var/lib/apt/lists
# key: rosdep-${{ runner.os }}-${{ hashFiles('src/**/package.xml') }}
# restore-keys: |
# rosdep-${{ runner.os }}-

# - name: Install Python Venv (if cache miss)
# if: steps.cache-venv.outputs.cache-hit != 'true'
# shell: bash
# run: |
# # Install python3-venv if not available
# apt-get update
# apt-get install -y python3-venv

# # Create virtual environment
# python3 -m venv .venv

# # Activate and install dependencies
# source .venv/bin/activate
# pip install --upgrade pip
# pip install -r requirements/all_requirements.txt

# - name: Install rosdep dependencies
# run: |
# # Ensure apt cache is preserved
# rm -f /etc/apt/apt.conf.d/docker-clean

# # Update rosdep
# apt-get update
# rosdep update

# # Install dependencies from all packages in src/
# rosdep install --from-paths src --ignore-src -r -y

# - name: Build with colcon
# shell: bash
# run: |
# # Activate venv and source ROS2 and workspace environment
# source .venv/bin/activate
# source /opt/ros/humble/setup.bash

# # Make sure build works (ignore hardware specific packages)
# colcon build --packages-ignore \
# camera_node \
# tr-camera-basler \
# lidar_node \
# yolox_ros_cpp \
# yolox_ros \
# yolox_cpp
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ rosbag2*

# clangd cache
.cache/
.ruff_cache/
7 changes: 6 additions & 1 deletion .md/cpp_python_lsp_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,17 @@ optionally also add the following to save on format
"editor.formatOnSave": true,
```

If you want to auto-format using the terminal, run:
```
find . -name "*.cpp" -o -name "*.h" | xargs clang-format -i -style=file
```

## Python

1. Install the `Python` and `Pylance` extensions by microsoft
2. install `Robot Developer Extensions for Ros2` by `Ranch Hand Robotics LLC`
![extension](ros2_vscode_extension.png)

3. Install `Ruff` by Astral Software
3. run `ROS2: Update Python Path` (you may need to run this periodically when you add new files or make major changes)
4. you can verify it worked by checking `.vscode/settings.json` and seeing it has added python auto complete and analysis extra paths.
5. you should now have type hints for ros msg definitions and custom msg definitions like tr_messages inside python!
Expand Down
20 changes: 20 additions & 0 deletions requirements/all_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# colcon build deps
catkin_pkg==1.1.0
empy==3.3.4
lark==1.3.1
catkin-pkg==1.1.0
PyYAML==6.0.3
setuptools==80.9.0
jinja2==3.1.6
typeguard==4.4.4

# for messages
numpy==1.26.4

# for sim_node
mani_skill==3.0.0b21
torch==2.9.1
pynput==1.8.1

# for linting & formatting
ruff==0.14.14
13 changes: 6 additions & 7 deletions requirements.txt → requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# simulation deps
mani_skill
torch
pynput==1.8.1
coacd

# colcon build deps
catkin_pkg
empy==3.3.4
lark
catkin-pkg
PyYAML
setuptools
setuptools
jinja2
typeguard

# for linting & formatting
ruff==0.14.14
8 changes: 8 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
line-length = 88
indent-width = 4

[format]
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"
Loading