Skip to content

Add wheel angular velocity sensor interface - #13

Merged
Aeh961 merged 8 commits into
mainfrom
aeh961/motor-encoder-interface
Aug 13, 2026
Merged

Add wheel angular velocity sensor interface#13
Aeh961 merged 8 commits into
mainfrom
aeh961/motor-encoder-interface

Conversation

@Aeh961

@Aeh961 Aeh961 commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR adds a reusable interface for accessing the NeoRacer's wheel angular-velocity sensors.

Changes

  • Added a frozen WheelAngularVelocityReading dataclass.

  • Added motor_encoder_readings() to package the existing wheel angular-velocity sensor values into a typed object.

  • Added helpers for:

    • average wheel angular velocity
    • estimated linear vehicle speed
  • Reused the existing wheel-radius constant.

  • Added focused validation and logic tests.

Sensor semantics

The current MuJoCo model exposes wheel joint angular velocity through <jointvel> sensors.

It does not currently expose:

  • encoder ticks
  • accumulated encoder counts
  • wheel position measurements

Accordingly, this interface represents wheel angular-velocity measurements rather than a full hardware encoder model.

Estimated vehicle speed

The estimated linear speed is derived from average wheel angular velocity and wheel radius.

It is explicitly an estimate and assumes negligible wheel slip, so it may differ from chassis ground-truth velocity during wheelspin or lockup.

Validation

Added tests verify:

  • expected wheel sensors are present
  • finite sensor values
  • expected wheel ordering
  • stationary readings near zero
  • forward throttle produces positive wheel velocity
  • reasonable left/right consistency during straight driving
  • helper calculations behave as expected

All 22 validation tests pass.

Scope

This PR does not modify:

  • MuJoCo XML
  • vehicle physics
  • controllers
  • steering or suspension
  • IMU
  • LiDAR
  • camera behavior
  • simulator stepping

Comment thread examples/sensor_logger.py Outdated
Abdallahelhamawi and others added 3 commits July 12, 2026 21:13
Resolves conflicts in examples/sensor_logger.py, validation/test_conformance.py,
and validation/test_logic.py between this branch's MotorEncoderReading rename
and main's now-merged IMU (#12), LidarScan (#11), and track-centering (#19)
work — both sides' additions are kept side by side.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Aeh961

Aeh961 commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator Author

PR #13 is conflict-free and ready for review. The full validation suite passes locally (40/40), and Ruff passes on all three files changed by this PR. The remaining required Ruff failures come from unrelated pre-existing files outside this PR's scope, so I left them unchanged.

Comment thread examples/sensor_logger.py Outdated
@Aeh961

Aeh961 commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator Author

Updated the implementation to address the review feedback. MotorEncoderReading now represents one scalar motor encoder value rather than four per-wheel values. The helper was renamed to motor_encoder_reading(), the redundant averaging helper was removed, and the tests were updated to validate the single-motor abstraction. All 39 validation tests pass, and the modified files pass Ruff.

Comment thread src/neoracer_mujoco/sensors.py Outdated
Comment thread src/neoracer_mujoco/sensors.py
Address bmabsout's PR review comment that the docstring was too long
for what it describes.
@Aeh961
Aeh961 merged commit d4b87bd into main Aug 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants