We have a mecanum bot using Talons, but odometry is driving us nuts. The raw distance traveled on the sensors when we drive forward works but the pose is constantly about 1.4x too high.
public void periodic() {
double[] speeds = getWheelSpeeds();
double frontLeftSpeed = speeds[0];
double rearLeftSpeed = speeds[1];
double frontRightSpeed = speeds[2];
double rearRightSpeed = speeds[3];
var wheelspeeds = new MecanumDriveWheelSpeeds(frontLeftSpeed, frontRightSpeed,
rearLeftSpeed, rearRightSpeed);
var m_pose = m_odometry.update(getGyroHeading(), wheelspeeds);
We are getting speeds and distances with
public double getSpeedMetersPerSecond(WPI_TalonSRX talon) {
return (double) (talon.getSelectedSensorVelocity(0)) / 1536.0 * TrajectoryConstants.kDriveWheelCircumferenceMeters * 10.0;
}
public double getPositionMeters(WPI_TalonSRX talon) {
return (double) talon.getSelectedSensorPosition(0) / 1536.0 * TrajectoryConstants.kDriveWheelCircumferenceMeters;
}
Where 1536 is the number of ticks we get off the encoder (384 encoder setting * 4 ticks per pulse) and it’s being read right off the Talon. We’re sending both the getPositionMeters and pose.getX(), but the pose is constantly 1.4x ahead of the raw sensor position, which we’ve measured to be correct.
It’s driving us nuts. The wheel circumference is correct and the encoders are reporting distance correctly. I’ve got no way of measuring velocity, but it’s coming from the same sensor with the same settings.
Any thoughts on where to look next?