Skip to content

Commit 48ea149

Browse files
Add odometry (#54)
Signed-off-by: Ari Lowy <arilow@ekumenlabs.com> Signed-off-by: Franco Cipollone <franco.c@ekumenlabs.com> Co-authored-by: Ari Lowy <arilow@ekumenlabs.com> Co-authored-by: Franco Cipollone <franco.c@ekumenlabs.com>
1 parent 1817dde commit 48ea149

16 files changed

Lines changed: 260 additions & 26 deletions

File tree

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ repository = "https://github.com/ekumenlabs/andino-rs"
1717
authors = ["Franco Cipollone <franco.c@ekumenlabs.com>"]
1818

1919
[workspace.dependencies]
20+
approx = { version = "0.5" }
2021
clap = { version = "4.5" }
2122
crossterm = { version = "0.29" }
2223
env_logger = { version = "0.10" }

andino_dora/graphs/dataflow.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,20 @@ nodes:
2626
path: ../../target/debug/dora_diff_drive_controller
2727
inputs:
2828
cmd_vel: dora_teleop_keyboard/cmd_vel
29+
wheel_joint_positions: dora_andino_hal/wheel_joint_positions
2930
outputs:
3031
- joints_speed_cmd # [left, right]
32+
- odom # [x, y, theta, linear_vel, angular_vel, timestamp]
3133
env:
3234
WHEEL_RADIUS: 0.0315 # [m]
3335
WHEEL_SEPARATION: 0.137 # [m]
3436

3537
# Node that reads the keyboard input and outputs the character pressed.
3638
- id: dora_keyboard
37-
build: uv pip install git+https://github.com/dora-rs/dora.git@v0.3.12#egg=dora-keyboard&subdirectory=node-hub/dora-keyboard
39+
# TODO(#55): Note we are here not using `uv`. It seems there is an issue with `uv` for the Raspberry Pi's architecture
40+
# causing an illegal instruction error.
41+
# Once this is fixed, we can switch back to using `uv` for consistency.
42+
build: pip install dora-keyboard
3843
path: dora-keyboard
3944
outputs:
4045
- char
@@ -52,11 +57,10 @@ nodes:
5257
DEFAULT_ANGULAR_SPEED: 1.0 # [rad/s]
5358

5459
# - id: dora-record
55-
# custom:
56-
# build: cargo install --git https://github.com/dora-rs/dora --tag v0.3.12 dora-record
57-
# source: dora-record
58-
# inputs:
59-
# wheel_joint_positions: dora_andino_hal/wheel_joint_positions
60-
# wheel_joint_velocities: dora_andino_hal/wheel_joint_velocities
61-
# joints_speed_cmd: diff_drive_controller/joints_speed_cmd
62-
# cmd_vel: gamepad/cmd_vel
60+
# build: cargo install --git https://github.com/dora-rs/dora --tag v0.3.12 dora-record
61+
# path: dora-record
62+
# inputs:
63+
# wheel_joint_positions: dora_andino_hal/wheel_joint_positions
64+
# wheel_joint_velocities: dora_andino_hal/wheel_joint_velocities
65+
# joints_speed_cmd: dora_diff_drive_controller/joints_speed_cmd
66+
# odom: dora_diff_drive_controller/odom

andino_dora/graphs/gemini_navigation.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ nodes:
77
tick: dora/timer/millis/100
88
joints_speed_cmd: dora_diff_drive_controller/joints_speed_cmd
99
outputs:
10-
- wheel_joint_positions # [left, right]
11-
- wheel_joint_velocities # [left, right]
10+
- wheel_joint_positions # [left, right, timestamp ]
11+
- wheel_joint_velocities # [left, right, timestamp ]
1212
env:
1313
# Serial port name.
1414
SERIAL_DEVICE: /dev/ttyUSB0
@@ -25,9 +25,11 @@ nodes:
2525
build: cargo build -p dora_diff_drive_controller
2626
path: ../../target/debug/dora_diff_drive_controller
2727
inputs:
28-
cmd_vel: dora_gemini_diff_drive_navigation/cmd_vel
28+
cmd_vel: dora_teleop_keyboard/cmd_vel
29+
wheel_joint_positions: dora_andino_mujoco_sim/wheel_joint_positions
2930
outputs:
3031
- joints_speed_cmd # [left, right]
32+
- odom # [x, y, theta, linear_vel, angular_vel, timestamp]
3133
env:
3234
WHEEL_RADIUS: 0.0315 # [m]
3335
WHEEL_SEPARATION: 0.137 # [m]

andino_dora_sim/graphs/mujoco_sim.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ nodes:
1212
camera_tick: dora/timer/millis/100 # 10 Hz
1313
joints_speed_cmd: dora_diff_drive_controller/joints_speed_cmd
1414
outputs:
15-
- wheel_joint_positions # [left, right]
16-
- wheel_joint_velocities # [left, right]
15+
- wheel_joint_positions # [left, right, timestamp]
16+
- wheel_joint_velocities # [left, right, timestamp]
1717
- camera_image # Encoding: bgr8
1818
env:
1919
TIMESTEP: 0.001 # [s]
@@ -25,8 +25,10 @@ nodes:
2525
path: ../../target/debug/dora_diff_drive_controller
2626
inputs:
2727
cmd_vel: dora_teleop_keyboard/cmd_vel
28+
wheel_joint_positions: dora_andino_mujoco_sim/wheel_joint_positions
2829
outputs:
2930
- joints_speed_cmd # [left, right]
31+
- odom # [x, y, theta, linear_vel, angular_vel, timestamp]
3032
env:
3133
WHEEL_RADIUS: 0.0315 # [m]
3234
WHEEL_SEPARATION: 0.137 # [m]

andino_dora_sim/graphs/mujoco_sim_gemini_navigation.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ nodes:
1212
camera_tick: dora/timer/millis/100 # 10 Hz
1313
joints_speed_cmd: dora_diff_drive_controller/joints_speed_cmd
1414
outputs:
15-
- wheel_joint_positions # [left, right]
16-
- wheel_joint_velocities # [left, right]
15+
- wheel_joint_positions # [left, right, timestamp]
16+
- wheel_joint_velocities # [left, right, timestamp]
1717
- camera_image # Encoding: bgr8
1818
env:
1919
TIMESTEP: 0.001 # [s]
@@ -24,9 +24,11 @@ nodes:
2424
build: cargo build -p dora_diff_drive_controller
2525
path: ../../target/debug/dora_diff_drive_controller
2626
inputs:
27-
cmd_vel: dora_gemini_diff_drive_navigation/cmd_vel
27+
cmd_vel: dora_teleop_keyboard/cmd_vel
28+
wheel_joint_positions: dora_andino_mujoco_sim/wheel_joint_positions
2829
outputs:
2930
- joints_speed_cmd # [left, right]
31+
- odom # [x, y, theta, linear_vel, angular_vel, timestamp]
3032
env:
3133
WHEEL_RADIUS: 0.0315 # [m]
3234
WHEEL_SEPARATION: 0.137 # [m]

dora_node_hub/dora_andino_hal/src/dora_node.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ pub fn main() -> eyre::Result<()> {
6060
let wheel_joint_positions_data = Float64Array::from(vec![
6161
andino_hal_state.left_wheel_state.position,
6262
andino_hal_state.right_wheel_state.position,
63+
metadata.timestamp().get_time().to_duration().as_secs_f64(),
6364
]);
6465
node.send_output(
6566
output_wheel_joint_positions.clone(),
@@ -70,6 +71,7 @@ pub fn main() -> eyre::Result<()> {
7071
let wheel_joint_velocities_data = Float64Array::from(vec![
7172
andino_hal_state.left_wheel_state.velocity,
7273
andino_hal_state.right_wheel_state.velocity,
74+
metadata.timestamp().get_time().to_duration().as_secs_f64(),
7375
]);
7476
node.send_output(
7577
output_wheel_joint_velocities.clone(),

dora_node_hub/dora_andino_mujoco_sim/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ nodes:
5959
model_tick: dora/timer/millis/1 # ~1000Hz
6060
joints_speed_cmd: dora_diff_drive_controller/joints_speed_cmd
6161
outputs:
62-
- wheel_joint_positions # [left, right]
63-
- wheel_joint_velocities # [left, right]
62+
- wheel_joint_positions # [left, right, timestamp]
63+
- wheel_joint_velocities # [left, right, timestamp]
6464
env:
6565
TIMESTEP: 0.001 # [s]
6666
```

dora_node_hub/dora_andino_mujoco_sim/dora_andino_mujoco_sim/assets/andino/andino.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@
3434
<geom type="mesh" rgba="0 0 1 1" mesh="chassis_top"/>
3535
</body><!-- chassis_top -->
3636

37-
<body name="right_wheel" pos="0.0185 -0.0675 -0.017">
37+
<body name="right_wheel" pos="0.0185 -0.0685 -0.017">
3838
<site name="right_wheel"/>
3939
<joint name="right_wheel_joint" type="hinge" axis="0 1 0" damping="0.001" />
4040
<geom class="visual" quat="0 0 -0.707107 -0.707107" type="mesh" mesh="wheel"/>
41-
<geom quat="1 1 0 0" type="cylinder" mass="0.03" size="0.03 0.010" />
41+
<geom quat="1 1 0 0" type="cylinder" mass="0.03" size="0.0315 0.010" />
4242
</body><!-- right_wheel -->
4343

44-
<body name="left_wheel" pos="0.0185 0.0675 -0.017">
44+
<body name="left_wheel" pos="0.0185 0.0685 -0.017">
4545
<joint name="left_wheel_joint" type="hinge" axis="0 1 0" damping="0.001" />
4646
<geom class="visual" quat="0.707107 0.707107 0 0" type="mesh" mesh="wheel"/>
47-
<geom quat="1 1 0 0" type="cylinder" mass="0.03" size="0.03 0.010" />
47+
<geom quat="1 1 0 0" type="cylinder" mass="0.03" size="0.0315 0.010" />
4848
</body><!-- left_wheel -->
4949

5050
<body name="caster_base" pos="-0.076 0 -0.0155" >

dora_node_hub/dora_andino_mujoco_sim/dora_andino_mujoco_sim/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,20 @@ def main() -> None:
7474

7575
# Advance the simulation
7676
mujoco.mj_step(mj_model, mj_data)
77-
7877
# Send position and velocity data or any other form of feedback from MuJoCo.
7978
# Replicating same behavior as the dora_andino_hal we outputs:
8079
# - wheel_joint_positions
8180
# - wheel_joint_velocities
8281
wheel_joint_positions = [
8382
mj_data.joint("left_wheel_joint").qpos[0],
8483
mj_data.joint("right_wheel_joint").qpos[0],
84+
mj_data.time,
8585
]
8686

8787
wheel_joint_velocities = [
8888
mj_data.joint("left_wheel_joint").qvel[0],
8989
mj_data.joint("right_wheel_joint").qvel[0],
90+
mj_data.time,
9091
]
9192
node.send_output(
9293
"wheel_joint_positions",

0 commit comments

Comments
 (0)