Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
bea4e06
nix: add flake
gwennlbh May 21, 2025
d74325d
nix: update sdk package name reference
gwennlbh May 21, 2025
7e4022a
nix: don't use submodules
gwennlbh May 21, 2025
641e483
nix: update after d5d6105f8db1770cd07fdde300c4c008e36de818 on master-…
gwennlbh May 21, 2025
7c703ac
ci: add nix build
gwennlbh May 21, 2025
22da2e3
ci: enable logs for nix build
gwennlbh May 21, 2025
1ca239e
nix: get package version dynamically
gwennlbh May 21, 2025
5587444
nix: update flake.lock
gwennlbh May 22, 2025
c556f6e
ci: enforce flake.lock correctness
gwennlbh May 22, 2025
ba65ab1
nix: set yaml-cpp as propagated build input
gwennlbh May 22, 2025
16d0409
nix: use gepetto/nix and flake template
gwennlbh May 26, 2025
c026c2b
factor out paths to demo config files
gwennlbh May 27, 2025
53f94a0
bake demo configs into binary
gwennlbh May 27, 2025
214ab9c
Revert "bake demo configs into binary"
gwennlbh May 27, 2025
af04179
git: gitignore a bunch of things
gwennlbh May 28, 2025
1089c8a
nix: update flake lock
gwennlbh May 28, 2025
62b8661
nix: add solo12 app to flake
gwennlbh May 28, 2025
61f89f5
nix: fmt
gwennlbh May 28, 2025
307c7e6
ci: run nix flake check instead of nix build
gwennlbh May 28, 2025
1a3dde8
fix demo config paths handling
gwennlbh May 28, 2025
0e800d1
nix: add a devshell to run demos/ .py scripts
gwennlbh Jun 2, 2025
8a90dca
nix: reference gepetto/nix instead of my fork
gwennlbh Jun 3, 2025
4b8ec15
use PYTHONPATH instead of a shellhook
gwennlbh Jun 3, 2025
d8ac492
ci: use gepetto cachix
gwennlbh Jun 3, 2025
c186238
gitignore: revert cmake-related ignores
gwennlbh Jun 3, 2025
bdd68a0
nix: tidy up flake apps' program decls
gwennlbh Jun 3, 2025
ef06648
ci: run on macos too
gwennlbh Jun 4, 2025
2424998
nix: fix pname for PYTHONPATH
gwennlbh Jun 4, 2025
bc6321f
ci: only prevent lockfile changes on ubuntu
gwennlbh Jun 4, 2025
36e6bb2
ci: dedupe job creation
gwennlbh Jun 5, 2025
884d94c
nix: fix path to apps' program
gwennlbh Jun 5, 2025
9d9ff5f
maybe fix demo testbench
gwennlbh Jun 5, 2025
1137873
add python testbench demo
gwennlbh Jun 5, 2025
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
29 changes: 29 additions & 0 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI - Nix

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
CI:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]

runs-on: ${{ matrix.os }}
name: CI (${{ matrix.os }})
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
- uses: cachix/cachix-action@v15
with:
name: gepetto
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix flake check -L
- name: Check if there are changes
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: NathanielHill/[email protected]
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
*build*

*.user
*.code-workspace
result
.vscode/c_cpp_properties.json
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,15 @@ endif(BUILD_PYTHON_INTERFACE)
macro(create_demo source)

set(demo_name ${PROJECT_NAME}_${source})
string(REPLACE "demo_" "" device "${source}")
set(DEMO_ROOT "${CMAKE_INSTALL_PREFIX}/demos")
file(COPY "${PROJECT_SOURCE_DIR}/demos/config_${device}.yaml" DESTINATION "${DEMO_ROOT}")
add_executable(${demo_name} demos/${source}.cpp)
target_link_libraries(${demo_name} ${PROJECT_NAME})
target_compile_definitions(
${demo_name}
PUBLIC CONFIG_SOLO12_YAML="${PROJECT_SOURCE_DIR}/demos/config_solo12.yaml"
PUBLIC CONFIG_TESTBENCH_YAML="${PROJECT_SOURCE_DIR}/demos/config_testbench.yaml")
PUBLIC CONFIG_SOLO12_YAML="${DEMO_ROOT}/config_solo12.yaml"
PUBLIC CONFIG_TESTBENCH_YAML="${DEMO_ROOT}/config_testbench.yaml")
install(TARGETS ${demo_name} DESTINATION bin)

endmacro(create_demo source)
Expand Down
49 changes: 31 additions & 18 deletions demos/demo_testbech_joint_calibrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,6 @@

imu = oci.IMU(robot_if)

robot = oci.Robot(robot_if, joints, imu)
robot.start()
robot.wait_until_ready()

# As the data is returned by reference, it's enough
# to get hold of the data one. It will update after
# each call to `robot.parse_sensor_data`.
imu_attitude = imu.attitude_euler
positions = joints.positions
velocities = joints.velocities

des_pos = np.zeros(12)

# Setup the calibration method
joint_offsets = np.array(
[
Expand All @@ -100,15 +87,41 @@
0.0,
0.0,
0.0,
]
)
],
dtype=np.float64,
).reshape(-1, 1)

sdir = oci.CalibrationMethod.positive

zero_offsets = np.zeros(12, dtype=np.int32).reshape(-1, 1)
some_other_array = np.zeros(12, dtype=np.float64).reshape(-1, 1)

joint_calibrator = oci.JointCalibrator(
joints, 12 * [sdir], joint_offsets,
np.zeros(12, dtype=int), np.zeros(12),
5.0 / 20.0, 0.05 / 20.0, 2.0, 0.001
joints,
12 * [sdir],
joint_offsets,
zero_offsets,
some_other_array,
5.0 / 20.0,
0.05 / 20.0,
2.0,
0.001,
)

robot = oci.Robot(robot_if, joints, imu, joint_calibrator)
robot.start()
robot.wait_until_ready()

# As the data is returned by reference, it's enough
# to get hold of the data one. It will update after
# each call to `robot.parse_sensor_data`.
imu_attitude = imu.attitude_euler
positions = joints.positions
velocities = joints.velocities

des_pos = np.zeros(12)


c = 0
dt = 0.001
calibration_done = False
Expand Down
35 changes: 35 additions & 0 deletions demos/demo_testbench.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import numpy as np

np.set_printoptions(suppress=True, precision=2)

import libodri_control_interface_pywrap as oci

robot = oci.robot_from_yaml_file("config_testbench.yaml")

des_pos = np.array([np.pi / 2, -np.pi / 2])

robot.initialize(des_pos)

kp, kd = 0.125, 0.0025
c = 0
while not robot.is_timeout:
robot.parse_sensor_data()

positions = robot.joints.positions
velocities = robot.joints.velocities

# Compute the PD control on the zero position.
torques = kp * (des_pos - positions) - kd * velocities

robot.joints.set_torques(torques)
robot.send_command_and_wait_end_of_cycle(0.001)

c += 1

if c % 1000 == 0:
print("joint pos: ", positions)
print("joint vel: ", velocities)
print("torques: ", torques)
robot.robot_interface.PrintStats()

print("timeout detected")
Loading