acmerobotics / road-runner

Wheeled mobile robot motion planning library designed for FTC
MIT License
209 stars 75 forks source link

Starting Yaw needs to be reset? #96

Closed Vector5233 closed 5 months ago

Vector5233 commented 5 months ago

So we have a Control Hub (different from Mr "Invalid Quaternion" Control Hub that we are grumpy with) that starts life with an offset most of the time. That makes it unusable. When running LocalizationTest, the initial heading is a random angle. BUT, if we turn the bot, the headings are correct relative to the initial offset.

Then today when we installed an Adafruit IMU, it also starts with an offset. In particular, it starts the LocalizationTest OpMode showing -5 deg. If we stop the OpMode, turn the bot 90 deg, and restart the OpMode, it shows an initial heading of 85 deg. If we restart the robot, the offset returns to -5 deg regardless of physical orientation. Similar results occur with different turns of the bot. Once the OpMode begins, the measured angles are correct relative to the offset.

I went poking around in the IMU API and behold, there is a resetYaw() method. I added that method call at line 217 of MecanumDrive, right after imu.initialize(), and it makes the offset go away for both devices. Initial heading is 0.0 deg regardless of physical orientation or robot reset history.

(1) Is there any reason not to do that? (2) Should that line become a permanent part of the MecanumDrive class?

rbrott commented 5 months ago

Discussion moved to https://github.com/acmerobotics/road-runner-quickstart/issues/346