Swerve Drive Auto Balance

Hi again, my team is trying to engage with the charge station in autonomous, but we are having some issues. I am mainly wondering if the way I have this command set up is a valid way to control our swerve modules.

The setDesiredState method is the same one that is called when driving in teleop, but all that happens when enabling the code is a slight lurch forward. This happens a few times before the timer ends the command. I think the navX pitch based speed control will work, but I am unsure of how to proceed with getting the robot to move forward.

Any suggestions or example code would be appreciated. Thanks!

1 Like

You can do that I think but if you don’t want to use some more advanced way to follow a trajectory (e.g. pathplanner), I would probably use your swerve subsystem’s drive method.

2 Likes

I don’t know what’s wrong with your code but here’s what I would do to find out:

  • add a bunch of print statements
  • increase the speed from 0.1 (not enough power to get up the angle?)
  • remove the delay(0.5) (that one holds up all processing - use hasElapsed like the other one)
  • make sure the sign of the pitch is right for the side of the robot and Charge Station in use.

Balancing shouldnt need a trajectory… My team just uses a Profiled PID controller hooked up to our angle.

1 Like

Lol honestly for auto you can just full send it without even that and it works really well most of the time (e.g. drive forward for 2 seconds)

depends how much precision you need :man_shrugging:

True, but when I did drive forward for 2 seconds it balanced 7/7 times at comp. It’s scuffed but it works.

1 Like

If it aint broke dont fix it

1 Like

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