Package swervelib.imu
Class IMUVelocity
java.lang.Object
swervelib.imu.IMUVelocity
Generic IMU Velocity filter.
-
Constructor Summary
ConstructorDescriptionIMUVelocity
(SwerveIMU gyro, double periodSeconds, int averagingTaps) Constructor for the IMU Velocity. -
Method Summary
Modifier and TypeMethodDescriptionstatic IMUVelocity
createIMUVelocity
(SwerveIMU gyro) Static factory for IMU Velocity.double
Get the robot's angular velocity based on averaged meaasurements from the IMU.
-
Constructor Details
-
IMUVelocity
Constructor for the IMU Velocity.- Parameters:
gyro
- The SwerveIMU gyro.periodSeconds
- The rate to collect measurements from the gyro, in the form (1/number of samples per second), make sure this does not exceed the update rate of your IMU.averagingTaps
- The number of samples to used for the moving average linear filter. Higher values will not allow the system to update to changes in velocity, lower values may create a less smooth signal. Expected taps will probably be ~2-8, with the goal of having the lowest smooth value.
-
-
Method Details
-
createIMUVelocity
Static factory for IMU Velocity. Supported IMU rates will be as quick as possible but will not exceed 100hz and will use 5 taps (supported IMUs are listed in swervelib's IMU folder). Other gyroscopes will default to 50hz and 5 taps. For custom rates please use the IMUVelocity constructor.- Parameters:
gyro
- The SwerveIMU gyro.- Returns:
IMUVelocity
for the given gyro with adjusted period readings for velocity.
-
getVelocity
public double getVelocity()Get the robot's angular velocity based on averaged meaasurements from the IMU. Velocity is multiplied by 1e+6 (1,000,000) because the timestamps are in microseconds.- Returns:
- robot's angular velocity in rads/s as a double.
-