Setting gyro position after auto

This season was our first time using a swerve drive, and for some of our autos we started with the robot facing the backwards. We encountered the issue of the gyro orientation being backwards at the end of auto because of this. Our solution was to set the gyro position to 180 degrees, which worked most of the time, but if the robot ended at an angle, it would be off by that angle. I was wondering how other teams with autos that start backwards dealt with this.

1 Like

Reset your odometry to your auto path starting pose at the beginning of auto, whatever that pose is.

3 Likes

I think we tried this but it didn’t work. I’ll try it again. We use pathplanner for our autos as well if that helps

Relevant git repo and branch are here for anyone who is interested in taking a look. We didn’t dive into this issue in season due to time crunches between our rebuild and champs, and then…summer…

1 Like

We also assigned our gyro heading in the autonomousInit() method, depending on which autonomous program was selected. I am not familiar with pathplanner, but you may have to change your pathplanner path so it starts with your robot facing the opposite direction.

To be clear, never reset your actual gyro reading. Use the reset method of your odometry, which applies the change in gyro reading to its current estimate in order to update. The actual gyro reading doesn’t matter as long as it’s not suddenly jumping by resetting the gyro itself.

1 Like

Not an answer for having only some of your autos starting backwards, but for us we always had our auto start “backwards”, so we ended up redefining the front as far as the gyro was concerned to be the “back” of the robot.

We used path planner and also started backwards sometimes. In parallel to the path planner command, we ran a command that kept track of the correct initial angle based off of the initial pose. It kept track of the offset throughout the pathing and when the command ended, it set the gyro angle to the correct value.
A little bit complicated but it was done this way because our paths broke whenever we tried to set the angle at the start with the initial pose given by path planner.

All of the odometry and pose estimator classes store an internal offset so that the actual gyro reading doesn’t matter. If you want to change the position or angle the odometry reports, call resetPosition with the desired Pose2d and current sensor readings.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.