Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update simulator to calculate and fill sensor values (IMUState) #34408

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

coding-jaguar
Copy link

@coding-jaguar coding-jaguar commented Jan 17, 2025

Description

The IMUState in the simulator was not being updated, causing locationd to receive zeros for the accelerometer and gyroscope values. This led to paramsd learning a bad offset and impacting the system's ability to process vehicle motion correctly.

This fix calculates and updates:

  1. Bearing: Directly retrieved from the metadrive_vehicle_state and stored in state.imu.bearing.
  2. Accelerometer: Computed based on the change in velocity (velocity) over time (dt) and stored in state.imu.accelerometer.
  3. Gyroscope: The yaw rate is calculated from the change in bearing over time (dt) and stored in state.imu.gyroscope.

These updates ensure that the IMU state provides meaningful data to locationd.

Fixes #33721


Verification

The bug fix was tested with simulated vehicle state data:

  • Bearing: Verified with "==", with md_vehicle.bearing
  • Accelerometer: Computed using velocity changes between consecutive time steps and validated with expected output.
  • Gyroscope: Yaw rate derived from bearing changes over time and logged to ensure accuracy.

Print statements were used during development to confirm:

  • Previous and current velocity values for acceleration.
  • Bearing and its changes for gyroscope values.
  • Logs and output confirmed that the IMU state was updated consistently across simulation runs.

@github-actions github-actions bot added simulation running openpilot in environments like CARLA tools labels Jan 17, 2025
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing to openpilot! In order for us to review your PR as quickly as possible, check the following:

  • Convert your PR to a draft unless it's ready to review
  • Read the contributing docs
  • Before marking as "ready for review", ensure:
    • the goal is clearly stated in the description
    • all the tests are passing
    • the change is something we merge
    • include a route or your device' dongle ID if relevant

@coding-jaguar coding-jaguar changed the title Fixes: #33721 - Update simulator to calculate and fill sensor values (IMUState) Fixes #33721 - Update simulator to calculate and fill sensor values (IMUState) Jan 17, 2025
@coding-jaguar coding-jaguar changed the title Fixes #33721 - Update simulator to calculate and fill sensor values (IMUState) Update simulator to calculate and fill sensor values (IMUState) Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
simulation running openpilot in environments like CARLA tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant