I have done quite a bit of searching and have found examples for Swerve Drive code but they all point to Command Based programming. I have seen teams reference using timed based programming for swerve bots but can’t find any code to get me moving in the right direction. We are using the M4Ki swerve modules with NEO’s, Spark Max Motor Controllers and Cancoders. Any help would be much appreciated as this is the teams first swerve bot and the primary coder graduated last year. In addition, both of the coaches are fairly new and want to at least be able to point the coders in somewhat of a right direction.
Just out of curiosity, is there a reason you want to use a time based project as opposed to command based?
There are many frameworks out there to help you generate code like YAGSL, but I’m pretty sure it does command-based.
YAGSL does not exclusively support command based but i only test command based. It should work as long as WPILib Notifiers
work!
Good to know!
You can take most of the methods from command based swerve subsystems and run the actual swerve drive command in like, TeleopPeriodic
One of the swerve example projects should be a timed robot.
Take this with a grain of salt but it’s the best I’ve got:
Here is a project I wrote in timedrobot that hasn’t been tested on a robot but displays the implementation: GitHub - PaarkG/2024Swerve-2
Here is our team’s 2023 YAGSL implementation, please do not mind the messy code but the YAGSL is created in timedrobot so I hope that it helps: GitHub - FIRST-Team-1699/2023Swerve
The pathplanner branch is the most up to date.
We use state machines with update methods for all of our subsystems and the drive subsystem is updated in teleopperiodic. By default in teleop this will run drive with an Xbox controller.
We are a timed robot team - since 2019, our swerve code has been with TimedRobot. This is our outreach bot using MK4i modules, NEOs and CANCoders, otherwise this is our season code with Falcons. Everything is custom-built, including our super very WIP trajectory system that’ll be outlined in our Open Alliance thread here. Should be relatively friendly to get up and running. Let me know if you have any questions!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.