Skip to content

Commit 84b1552

Browse files
committed
Adds odometry output to dora node
Signed-off-by: Ari Lowy <arilow@ekumenlabs.com>
1 parent 06ffd27 commit 84b1552

7 files changed

Lines changed: 32 additions & 12 deletions

File tree

andino_dora/graphs/dataflow.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ 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_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/graphs/gemini_navigation.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ nodes:
2626
inputs:
2727
cmd_vel: dora_teleop_keyboard/cmd_vel
2828
wheel_joint_positions: dora_andino_mujoco_sim/wheel_joint_positions
29-
# wheel_joint_velocities: dora_andino_mujoco_sim/wheel_joint_velocities
3029
outputs:
3130
- joints_speed_cmd # [left, right]
31+
- odom # [x, y, theta, linear_vel, angular_vel, timestamp]
3232
env:
3333
WHEEL_RADIUS: 0.0315 # [m]
3434
WHEEL_SEPARATION: 0.137 # [m]

andino_dora_sim/graphs/mujoco_sim_gemini_navigation.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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_diff_drive_controller/src/dora_node.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use dora_node_api::{DoraNode, Event, arrow::array::Float64Array, dora_core::conf
22

33
pub fn main() -> eyre::Result<()> {
44
let output_joints_speed = DataId::from("joints_speed_cmd".to_owned());
5+
let output_odom = DataId::from("odom".to_owned());
56

67
let (mut node, mut events) = DoraNode::init_from_env()?;
78

@@ -68,11 +69,22 @@ pub fn main() -> eyre::Result<()> {
6869
);
6970
continue;
7071
}
72+
let timestamp = values.value(2);
7173
diff_drive_odometry.update(
7274
values.value(0), // left wheel position
7375
values.value(1), // right wheel position
74-
values.value(2), // timestamp
76+
timestamp, // timestamp
7577
);
78+
79+
let odom_array = Float64Array::from(vec![
80+
diff_drive_odometry.current_pose.x,
81+
diff_drive_odometry.current_pose.y,
82+
diff_drive_odometry.current_pose.heading,
83+
diff_drive_odometry.linear,
84+
diff_drive_odometry.angular,
85+
timestamp,
86+
]);
87+
node.send_output(output_odom.clone(), metadata.parameters, odom_array)?;
7688
// Process wheel joint positions if needed
7789
}
7890
_ => {

dora_node_hub/dora_diff_drive_controller/src/odometry.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ fn normalize_angle(angle: f64) -> f64 {
1010
}
1111
/// Odometry for a diff drive mobile robot.
1212
pub struct DiffDriveOdometry {
13+
/// Current pose:
14+
pub current_pose: Pose2D,
15+
16+
/// Current velocity:
17+
pub linear: f64, // [m/s]
18+
pub angular: f64, // [rad/s]
19+
1320
/// The distance between the wheels.
1421
wheel_separation: f64, // [m]
1522
/// The radius of the wheels.
1623
wheel_radius: f64, // [m]
1724

18-
/// Current pose:
19-
current_pose: Pose2D,
20-
21-
/// Current velocity:
22-
linear: f64, // [m/s]
23-
angular: f64, // [rad/s]
24-
2525
/// Previous data for odometry calculations.
2626
previous_time: f64, // [s]
2727
previous_left_wheel_position: f64, // [rad]

dora_node_hub/dora_gemini_diff_drive_navigation/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,11 @@ uv run pytest . # Test
8181
build: cargo build -p dora_diff_drive_controller
8282
path: ../../target/debug/dora_diff_drive_controller
8383
inputs:
84-
cmd_vel: dora_gemini_diff_drive_navigation/cmd_vel
84+
cmd_vel: dora_teleop_keyboard/cmd_vel
85+
wheel_joint_positions: dora_andino_mujoco_sim/wheel_joint_positions
8586
outputs:
8687
- joints_speed_cmd # [left, right]
88+
- odom # [x, y, theta, linear_vel, angular_vel, timestamp]
8789
env:
8890
WHEEL_RADIUS: 0.0315 # [m]
8991
WHEEL_SEPARATION: 0.137 # [m]

0 commit comments

Comments
 (0)