mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
[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:
@@ -30,6 +30,7 @@ import org.wpilib.networktables.DoubleArrayEntry;
|
||||
import org.wpilib.networktables.DoubleArrayTopic;
|
||||
import org.wpilib.simulation.DifferentialDrivetrainSim;
|
||||
import org.wpilib.simulation.EncoderSim;
|
||||
import org.wpilib.simulation.OnboardIMUSim;
|
||||
import org.wpilib.smartdashboard.Field2d;
|
||||
import org.wpilib.smartdashboard.SmartDashboard;
|
||||
import org.wpilib.system.RobotController;
|
||||
@@ -253,8 +254,7 @@ public class Drivetrain {
|
||||
leftEncoderSim.setRate(drivetrainSimulator.getLeftVelocity());
|
||||
rightEncoderSim.setDistance(drivetrainSimulator.getRightPosition());
|
||||
rightEncoderSim.setRate(drivetrainSimulator.getRightVelocity());
|
||||
// gyroSim.setAngle(-drivetrainSimulator.getHeading().getDegrees()); // TODO(Ryan): fixup
|
||||
// when sim implemented
|
||||
OnboardIMUSim.setYaw(-drivetrainSimulator.getHeading().getRadians());
|
||||
}
|
||||
|
||||
/** This function is called periodically, no matter the mode. */
|
||||
|
||||
Reference in New Issue
Block a user