[wpilib][sim] Add Onboard IMU Sim (#8855)

This provides the ability to simulate parts of the Onboard IMU at the
HAL level. This allows team to use and simulate the IMU in code, and a
follow up PR could be made to the halsim_gui to add a new widget to view
and modify the data graphically.

Since the C++ IMU uses radians for angles that is what I did for the
simulator.

Partially deals with #8845
This commit is contained in:
PJ Reiniger
2026-05-07 13:01:26 -04:00
committed by GitHub
parent 3d4cabfbc9
commit 4c07aedd91
23 changed files with 713 additions and 15 deletions

View File

@@ -0,0 +1,30 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include "wpi/units/acceleration.hpp"
#include "wpi/units/angle.hpp"
#include "wpi/units/angular_velocity.hpp"
namespace wpi::sim {
class OnboardIMUSim {
public:
void SetAngleX(wpi::units::radian_t angle);
void SetAngleY(wpi::units::radian_t angle);
void SetAngleZ(wpi::units::radian_t angle);
void SetGyroRateX(wpi::units::radians_per_second_t rate);
void SetGyroRateY(wpi::units::radians_per_second_t rate);
void SetGyroRateZ(wpi::units::radians_per_second_t rate);
void SetAccelX(wpi::units::meters_per_second_squared_t accel);
void SetAccelY(wpi::units::meters_per_second_squared_t accel);
void SetAccelZ(wpi::units::meters_per_second_squared_t accel);
void SetYaw(wpi::units::radian_t angle);
};
} // namespace wpi::sim