New To Swerve, Match Play Question with Field Oriented Drive

Our team is working with Mk4 SDS Swerve modules and have been enjoying using field oriented drive with them. One question we have is that when we start up our robot on the field prior to the match our robot wouldn’t be facing the correct “home” direction for heading. How have swerve teams using field oriented drive set their heading before/after autonomous? I understand turning the robot and manually re-zeroing it, but is there an automatic way to do this? I figured hard-coding an offset based on the autonomous starting position would not be the correct approach but maybe I’m wrong.

4 Likes

We set the pose at the beginning of an autonomous command to that of the pose of the pathplanner trajectory, this also allows us to adjust our path if needed without having to remember to change the value in the code.

new InstantCommand(() -> drivetrain.resetOdometry(move11.getInitialPose()))

6 Likes

For each auto routine, we place the robot in a fixed position and orientation on the field. The angle of that orientation (relative to our field X and Y axes) is then part of the definition of that particular auto routine and is used to initialize the gyro angles in the code to account for this starting angle.

7 Likes

If you’re concerned about being able to set up your robot for auto with a specific position and orientation, some teams use wooden or cardboard forms intended to align the robot with respect to field elements. This is legal provided it does not cause delay (H301d), so be sure to look efficient while you’re using them. Remember that fields are not laid out with perfect consistency.

3 Likes

Obviously, in this case we are talking about angle to set the gyro. For 2022, we used the tape lines for reference and, while the position of those varied from field to field, the angle was pretty consistent (since they are long pieces of tape, if the end points move a little, it has very little change on the angle). Also, your gyro can be off by a little bit and it will not affect your ability to drive teleop in field orient.

We did not do this, but you could check the angles (and positions) of each of the landmarks that you intend to use to orient your robot during the field calibration time and then adjust your code accordingly. I know that when we were laying out some tape lines in a practice space, we used the compass app on the iphone to measure first the wall and then the angle of the tape lines. I’m not sure I trust that compass app (I believe it is a flux gate compass and could be affected by metal in the vicinity of your measurements), but it seemed to work pretty well to get the practice field set up. What would be more clever would be to have your robot on the field tethered to your laptop and move it around to each of the starting locations and read the angle of each using the gyro (after initializing it by aligning the robot with the wall). Make sure you do it for both the red and blue side of the field.

2 Likes

Similarly to @Emerson1706, when we ran full matches we reset our gyro odometry based on our initial auto pose and angle but we kept the option for manual realignment in case we started slightly off or if the gyro drifted.

We found that it was fast enough to jam the robot against something to quickly align it at the start of teleop too so we didn’t worry too much.

2 Likes

All of the posts above offer good advice. I’ll add in that in most years, this is issue is a lot simpler to deal with, because the rules allow/enforce you to start with your bumpers flush against the alliance wall, so you know that your robot is facing straight ahead. This year’s starting position rules were pretty atypical.

Well, that was true in 2017 and 2018.

In 2016, the spy robot could start in the courtyard in contact with the wall, but all other robots started near the middle of the field with the only requirement that they were breaking the plane of the auto line

In 2019 you had to have your robot on the HAB platform (and since you either had the alliance wall or the edge of the HAB upper levels to use, many teams did align their robot using those walls.

In 2020 you had to start with your at least part of you bumper intersecting the initiation line, but the orientation could be anything you wanted.

But, in general, I agree with your point that in past years you almost always had a reference line or wall that was aligned with the field’s X or Y axes that you could use to align your robot with the orientation of the field if you wanted to (and many teams did). 2022 is the first time that the reference lines available for you to use were at angles to the field orientation and, except for a few starting locations, there was not a line available to use to orient your robot that was perfectly aligned with either the field’s X or Y axes.

Like others said, you know what angle your robot starts in auto, so you can set gyro to that as your first auto command.

1 Like

You can use a tape measure but be ready to defend that with the rules.

An essential point in our experience. The students including their backups have to practice the setup to be quick, accurate, and smooth not to draw attention to themselves.

2 Likes

Are you allowed to turn on the robot when you are touching a specific point such as the hub and reset the angle there and then move it to the auto start position. This would make it so you don’t need to be as precise with the angle. Just make sure the bot is in coast mode on startup/disable.

As long as you don’t take too long (H301) and keep the robot disabled (H302) you should be okay.

1 Like

This is kinda what we did this season. Had a jumper that zeroed the gyro and just set it up in the proper orientation for field oriented drive (eyeballed) zeroed it and then set it up for auto. Definitely wasn’t the best solution and probably took to long.

Over the weekend we tried the method of setting the heading to a measured angle that we found during the calibration period. This wasn’t quite as good as I hoped I still believe our driver had to manually reorient the robot most of the time to get the field orientation working correctly. Now this could be partially because we couldn’t always get the field placement exactly the same but we tried our best based on field based markings but I wonder if there’s a better approach.

1 Like

The rules allow you to bring an aligning guide on the field as long as it’s not too big and it doesn’t unnecessarily slow down the match flow. I saw some teams use wood cutouts to place against the hub and line up with the bumpers.

It almost sounds like it’s something else. Our driver is just fine with the orientation being off 5 or 10 or even 15 degrees. You just sort of adjust to it. More practice perhaps?

2 Likes

Yea I think we only had practice in the shop with perfect orientation, but no doubt more practice could be the answer.

We used the side of the hub as an alignment guide at the start of matches, so the robot would be pushed flush against the wall to its exact angle each time. This meant we didn’t need any guides and setup was really simple.

1 Like

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