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

fix IMU sensor readings #33836

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

Conversation

sambhavnoobcoder
Copy link

Description

The simulator's IMU sensors were not being populated with realistic values, causing issues with:

  • locationd calibration
  • paramsd steering angle offset learning
  • overall vehicle control accuracy

This led to:

  • locationd receiving zero values for sensor data
  • paramsd learning incorrect steering offsets

Proposed Solution & Implementation

Implemented IMU sensor value calculation using vehicle state data from MetaDrive. The solution:

  • Added IMU calculation logic in read_sensors()

  • Added IMU calculation function that:

  • Computes realistic accelerometer values considering:

    • Linear acceleration
    • Centripetal forces during turns
    • Gravitational acceleration (9.81 m/s²)
  • Calculates gyroscope values from bearing changes

  • Applies appropriate coordinate transformations

  • Enforces realistic physical limits on sensor values

Testing and Validation

  1. Successfully generates non-zero, physically realistic IMU values
  2. Maintains accelerometer readings within vehicle limits (<18 m/s²)
  3. Produces reasonable gyroscope values during turns
  4. Enables proper locationd calibration
  5. Allows paramsd to learn accurate steering offsets
  6. Improves overall steering angle correction

Sample output and Inference

Here is a small screen recording of the outputs generated:

Screen.Recording.2024-10-21.at.11.20.20.PM.mov

This output was generated with the parameters :

metadrive_vehicle_state(
    velocity=vec3(x=3.25, y=10.50, z=0), 
    position=(217.06, 82.06),
    bearing=72.51,
    steering_angle=7.87
)

The inference drawn from this output was :

  • Accelerometer shows expected acceleration patterns during turns
  • Gyroscope correctly reflects vehicle rotation rate
  • Calculated values enable proper steering offset learning (previous invalid 0° → now realistic ~2.7°)

Impact

This fix:

  • Enables proper locationd calibration in simulator
  • Improves steering angle offset learning
  • Enhances simulation accuracy

The implementation maintains clean code organization while adding essential simulator functionality, making the simulation environment more realistic and useful for testing vehicle control systems.
Related Issues

- Add PreviousState class to track vehicle state for IMU calculations.
- added variables for :
- - timestamp
- - velocity 
- - bearing 
- - Position
- added function for calculation of accelerometer
- function also does for calculation of gyroscopes values
- update for including above changes
- Reset IMU state tracking on vehicle reset
- minor refactor to add dependencies etc .
@github-actions github-actions bot added simulation running openpilot in environments like CARLA tools labels Oct 21, 2024
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
@sambhavnoobcoder sambhavnoobcoder changed the title Bounty filling sensors Oct 21, 2024
@sambhavnoobcoder sambhavnoobcoder changed the title fix empty IMU sensor readings Oct 21, 2024
- refactored code to be back to tab for 2 spaces .
Copy link
Contributor

This PR has had no activity for 9 days. It will be automatically closed in 2 days if there is no activity.

@github-actions github-actions bot added the stale label Oct 31, 2024
@sambhavnoobcoder
Copy link
Author

@sshane can you review this ? else this will close in 2 days .

@github-actions github-actions bot removed the stale label Nov 1, 2024
Copy link
Contributor

This PR has had no activity for 9 days. It will be automatically closed in 2 days if there is no activity.

@github-actions github-actions bot added the stale label Nov 11, 2024
@sambhavnoobcoder
Copy link
Author

@sshane could you review this please ?

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 stale tools
2 participants