Skip to content

Commit 0f8bbad

Browse files
committed
ci: dependent workflows, caching and extension linting
1 parent 4e15bc2 commit 0f8bbad

21 files changed

Lines changed: 790 additions & 140 deletions

File tree

.github/workflows/cpp.yaml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ on:
44
pull_request:
55
paths:
66
- "src/**"
7-
- ".github/workflows/**"
7+
- "include/**"
8+
- "extensions/**"
9+
- ".github/workflows/cpp.yaml"
810
push:
911
branches:
1012
- master
@@ -14,6 +16,13 @@ jobs:
1416
runs-on: ubuntu-latest
1517
steps:
1618
- uses: actions/checkout@v4
19+
- name: Cache apt packages
20+
uses: actions/cache@v4
21+
with:
22+
path: /var/cache/apt/archives
23+
key: ${{ runner.os }}-apt-${{ hashFiles('debian_deps.txt') }}
24+
restore-keys: |
25+
${{ runner.os }}-apt-
1726
- name: Install dependencies
1827
run: sudo apt install $(cat debian_deps.txt)
1928
- name: Check clang format
@@ -33,6 +42,13 @@ jobs:
3342
runs-on: ubuntu-latest
3443
steps:
3544
- uses: actions/checkout@v4
45+
- name: Cache apt packages
46+
uses: actions/cache@v4
47+
with:
48+
path: /var/cache/apt/archives
49+
key: ${{ runner.os }}-apt-${{ hashFiles('debian_deps.txt') }}
50+
restore-keys: |
51+
${{ runner.os }}-apt-
3652
- name: Install dependencies
3753
run: sudo apt install $(cat debian_deps.txt)
3854
- name: Set up Python 3.11
@@ -43,3 +59,7 @@ jobs:
4359
cache: "pip"
4460
- name: GCC build
4561
run: make gcccompile PYTHON_EXECUTABLE=${{ steps.setup-python.outputs.python-path }}
62+
63+
build_extensions:
64+
needs: [build_clang, build_gcc]
65+
uses: ./.github/workflows/extensions.yaml

.github/workflows/extensions.yaml

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
name: Extensions
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
build_extensions:
8+
strategy:
9+
matrix:
10+
extension:
11+
# C++ extensions
12+
- rcs_fr3
13+
- rcs_panda
14+
- rcs_robotics_library
15+
- rcs_so101
16+
# Python extensions
17+
- rcs_xarm7
18+
- rcs_realsense
19+
- rcs_robotiq
20+
- rcs_tacto
21+
- rcs_usb_cam
22+
- rcs_zed
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
- name: Cache apt packages
27+
uses: actions/cache@v4
28+
with:
29+
path: /var/cache/apt/archives
30+
key: ${{ runner.os }}-apt-${{ hashFiles('debian_deps.txt') }}
31+
restore-keys: |
32+
${{ runner.os }}-apt-
33+
- name: Install dependencies
34+
run: sudo apt install $(cat debian_deps.txt)
35+
- name: Set up Python 3.11
36+
id: setup-python
37+
uses: actions/setup-python@v5
38+
with:
39+
python-version: "3.11"
40+
cache: "pip"
41+
42+
- name: Install build dependencies
43+
run: pip install -r requirements.txt
44+
45+
- name: Install rcs
46+
run: pip install -e .
47+
48+
- name: Install extension
49+
run: pip install -e extensions/${{ matrix.extension }}
50+
51+
build_cpp_extensions_clang:
52+
strategy:
53+
matrix:
54+
extension:
55+
- rcs_fr3
56+
- rcs_panda
57+
- rcs_robotics_library
58+
- rcs_so101
59+
runs-on: ubuntu-latest
60+
steps:
61+
- uses: actions/checkout@v4
62+
- name: Cache apt packages
63+
uses: actions/cache@v4
64+
with:
65+
path: /var/cache/apt/archives
66+
key: ${{ runner.os }}-apt-${{ hashFiles('debian_deps.txt') }}
67+
restore-keys: |
68+
${{ runner.os }}-apt-
69+
- name: Install dependencies
70+
run: sudo apt install $(cat debian_deps.txt)
71+
- name: Check clang format
72+
run: make -C extensions/${{ matrix.extension }} cppcheckformat
73+
- name: Clang Tidy
74+
run: make -C extensions/${{ matrix.extension }} cpplint
75+
- name: Set up Python 3.11
76+
id: setup-python
77+
uses: actions/setup-python@v5
78+
with:
79+
python-version: "3.11"
80+
cache: "pip"
81+
- name: Clang build
82+
run: make -C extensions/${{ matrix.extension }} clangcompile PYTHON_EXECUTABLE=${{ steps.setup-python.outputs.python-path }}
83+
84+
build_cpp_extensions_gcc:
85+
strategy:
86+
matrix:
87+
extension:
88+
- rcs_fr3
89+
- rcs_panda
90+
- rcs_robotics_library
91+
- rcs_so101
92+
runs-on: ubuntu-latest
93+
steps:
94+
- uses: actions/checkout@v4
95+
- name: Cache apt packages
96+
uses: actions/cache@v4
97+
with:
98+
path: /var/cache/apt/archives
99+
key: ${{ runner.os }}-apt-${{ hashFiles('debian_deps.txt') }}
100+
restore-keys: |
101+
${{ runner.os }}-apt-
102+
- name: Install dependencies
103+
run: sudo apt install $(cat debian_deps.txt)
104+
- name: Set up Python 3.11
105+
id: setup-python
106+
uses: actions/setup-python@v5
107+
with:
108+
python-version: "3.11"
109+
cache: "pip"
110+
- name: GCC build
111+
run: make -C extensions/${{ matrix.extension }} gcccompile PYTHON_EXECUTABLE=${{ steps.setup-python.outputs.python-path }}
112+
113+
stubgen:
114+
runs-on: ubuntu-latest
115+
needs: build_extensions
116+
steps:
117+
- uses: actions/checkout@v4
118+
- name: Cache apt packages
119+
uses: actions/cache@v4
120+
with:
121+
path: /var/cache/apt/archives
122+
key: ${{ runner.os }}-apt-${{ hashFiles('debian_deps.txt') }}
123+
restore-keys: |
124+
${{ runner.os }}-apt-
125+
- name: Install dependencies
126+
run: sudo apt install $(cat debian_deps.txt)
127+
- name: Set up Python 3.11
128+
id: setup-python
129+
uses: actions/setup-python@v5
130+
with:
131+
python-version: "3.11"
132+
cache: "pip"
133+
- name: Install build dependencies
134+
run: pip install -r requirements.txt
135+
- name: Install rcs
136+
run: pip install -e .
137+
- name: Install all extensions
138+
run: |
139+
for d in extensions/*; do
140+
if [ -d "$d" ]; then
141+
pip install -e "$d"
142+
fi
143+
done
144+
- name: Check that stub files are up-to-date
145+
run: make stubgen && git diff --exit-code

.github/workflows/py.yaml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
paths:
66
- "python/**"
77
- "src/pybind/**"
8-
- ".github/workflows/**"
8+
- ".github/workflows/py.yaml"
99
push:
1010
branches:
1111
- master
@@ -15,17 +15,18 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- uses: actions/checkout@v4
18-
- name: Set up Python 3.10
18+
- name: Set up Python 3.11
1919
uses: actions/setup-python@v5
2020
with:
21-
python-version: "3.10"
21+
python-version: "3.11"
2222
cache: "pip"
2323
- name: Install linting and formatting dependencies
2424
run: python -m pip install -r requirements.txt
2525
- name: Check formatting
2626
run: make pycheckformat
2727

2828
pythonpackage:
29+
needs: format
2930
runs-on: ubuntu-latest
3031
env:
3132
CC: clang
@@ -48,10 +49,6 @@ jobs:
4849
run: python -m pip install wheel
4950
- name: Install the package
5051
run: python -m pip install --no-build-isolation .
51-
- name: Install the fr3 extension
52-
run: python -m pip install --no-build-isolation extensions/rcs_fr3
53-
- name: Install the panda extension
54-
run: python -m pip install --no-build-isolation extensions/rcs_panda
5552
- name: Code linting
5653
run: make pylint
5754
- name: Check that stub files are up-to-date

extensions/rcs_so101/src/pybind/SO101.h

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,19 @@
99
#include <eigen3/Eigen/Geometry>
1010
#include <memory>
1111
#include <optional>
12-
#include <string>
13-
1412
#include <pinocchio/algorithm/frames.hpp>
1513
#include <pinocchio/algorithm/jacobian.hpp>
1614
#include <pinocchio/algorithm/joint-configuration.hpp>
1715
#include <pinocchio/algorithm/kinematics.hpp>
1816
#include <pinocchio/parsers/mjcf.hpp>
1917
#include <pinocchio/parsers/urdf.hpp>
18+
#include <string>
2019

2120
namespace rcs {
2221
namespace so101 {
2322

2423
class SO101IK : public rcs::common::Kinematics {
25-
private:
24+
private:
2625
const double eps = 1e-4;
2726
const int IT_MAX = 1000;
2827
const double DT = 1e-1;
@@ -35,7 +34,8 @@ class SO101IK : public rcs::common::Kinematics {
3534
pinocchio::Data data;
3635

3736
public:
38-
SO101IK(const std::string& path, const std::string& frame_id, bool urdf = true)
37+
SO101IK(const std::string& path, const std::string& frame_id,
38+
bool urdf = true)
3939
: model() {
4040
if (urdf) {
4141
pinocchio::urdf::buildModel(path, this->model);
@@ -53,10 +53,12 @@ class SO101IK : public rcs::common::Kinematics {
5353
const rcs::common::Pose& pose, const rcs::common::VectorXd& q0,
5454
const rcs::common::Pose& tcp_offset =
5555
rcs::common::Pose::Identity()) override {
56-
// --- Tunables (could be class members) ------------------------------------
57-
const double WP = 1.0; // position weight
58-
const double WO = 0.12; // orientation (pitch+yaw) weight
59-
const double WO_ROLL = 0.03; // orientation roll weight (let it "float" more)
56+
// --- Tunables (could be class members)
57+
// ------------------------------------
58+
const double WP = 1.0; // position weight
59+
const double WO = 0.12; // orientation (pitch+yaw) weight
60+
const double WO_ROLL =
61+
0.03; // orientation roll weight (let it "float" more)
6062
const double ORI_TOL = 5.0 * M_PI / 180.0; // 5 deg tolerance (dead-zone)
6163
const double ORI_CAP =
6264
0.6; // cap on |eo| scaling (rad/s-equivalent per iter)
@@ -78,7 +80,7 @@ class SO101IK : public rcs::common::Kinematics {
7880
bool success = false;
7981

8082
// Pre-allocations
81-
rcs::common::Vector6d err, err_w; // 6x1
83+
rcs::common::Vector6d err, err_w; // 6x1
8284
Eigen::Vector3d ep, eo; // position/orientation parts
8385
Eigen::VectorXd v(model.nv); // nv x 1
8486
pinocchio::Data::Matrix6 JJt; // 6x6
@@ -106,8 +108,9 @@ class SO101IK : public rcs::common::Kinematics {
106108
ep = err.head<3>();
107109
eo = err.tail<3>();
108110

109-
// ---- Orientation tolerance (dead-zone + soft cap) ----------------------
110-
// If |eo| is small, ignore it completely (prevents twitch).
111+
// ---- Orientation tolerance (dead-zone + soft cap)
112+
// ---------------------- If |eo| is small, ignore it completely (prevents
113+
// twitch).
111114
const double eo_norm = eo.norm();
112115
if (eo_norm < ORI_TOL) {
113116
eo.setZero();
@@ -140,9 +143,10 @@ class SO101IK : public rcs::common::Kinematics {
140143
pinocchio::Jlog6(iMd.inverse(), Jlog);
141144
J = -Jlog * J; // tangent-space Jacobian for the error you’re minimizing
142145

143-
// ---- Weighted damped least-squares -------------------------------------
144-
// Apply sqrt-weights on rows: this prioritizes translation > orientation,
145-
// and de-weights tool roll further.
146+
// ---- Weighted damped least-squares
147+
// ------------------------------------- Apply sqrt-weights on rows: this
148+
// prioritizes translation > orientation, and de-weights tool roll
149+
// further.
146150
const auto Jw = Wsqrt * J; // 6xnv
147151
err_w = Wsqrt * err; // 6x1
148152

@@ -168,10 +172,11 @@ class SO101IK : public rcs::common::Kinematics {
168172
v.noalias() = -Jw.transpose() * JJt.ldlt().solve(err_w);
169173
// ------------------------------------------------------------------------
170174

171-
// ---- Step-size limiter in task space to avoid sudden jumps -------------
172-
// Predict task step and scale if too large
175+
// ---- Step-size limiter in task space to avoid sudden jumps
176+
// ------------- Predict task step and scale if too large
173177
Eigen::Matrix<double, 6, 1> task_step = J * v * this->DT;
174-
double step_norm = task_step.head<3>().norm() + task_step.tail<3>().norm();
178+
double step_norm =
179+
task_step.head<3>().norm() + task_step.tail<3>().norm();
175180
if (step_norm > STEP_CAP && step_norm > 1e-9) {
176181
const double scale = STEP_CAP / step_norm;
177182
v *= scale;
@@ -199,7 +204,7 @@ class SO101IK : public rcs::common::Kinematics {
199204
q.head(q0.size()) = q0;
200205
pinocchio::framesForwardKinematics(model, data, q);
201206
rcs::common::Pose pose(data.oMf[this->FRAME_ID].rotation(),
202-
data.oMf[this->FRAME_ID].translation());
207+
data.oMf[this->FRAME_ID].translation());
203208

204209
// apply the tcp offset
205210
return pose * tcp_offset.inverse();

extensions/rcs_so101/src/pybind/rcs.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,8 @@ PYBIND11_MODULE(_core, m) {
3838

3939
py::object kinematics =
4040
(py::object)py::module_::import("rcs").attr("common").attr("Kinematics");
41-
py::class_<rcs::so101::SO101IK,
42-
std::shared_ptr<rcs::so101::SO101IK>>(
41+
py::class_<rcs::so101::SO101IK, std::shared_ptr<rcs::so101::SO101IK>>(
4342
ik, "SO101IK", kinematics)
44-
.def(py::init<const std::string &, const std::string &, bool>(), py::arg("path"),
45-
py::arg("frame_id"), py::arg("urdf") = true);
43+
.def(py::init<const std::string&, const std::string&, bool>(),
44+
py::arg("path"), py::arg("frame_id"), py::arg("urdf") = true);
4645
}

extensions/rcs_zed/pyproject.toml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[build-system]
2+
requires = ["setuptools"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "rcs_zed"
7+
version = "0.5.2"
8+
description="RCS ZED module"
9+
dependencies = [
10+
"rcs>=0.5.0",
11+
"diskcache", # Keep for potential calibration, similar to realsense
12+
]
13+
readme = "README.md"
14+
maintainers = [
15+
{ name = "Tobias Jülg", email = "tobias.juelg@utn.de" },
16+
]
17+
authors = [
18+
{ name = "Tobias Jülg", email = "tobias.juelg@utn.de" },
19+
]
20+
requires-python = ">=3.10"
21+
22+
[tool.black]
23+
line-length = 120
24+
target-version = ["py311"]
25+
26+
[tool.isort]
27+
profile = "black"

extensions/rcs_zed/src/rcs_zed/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)