What is your take having both drive and angle motors of swerve on Coast while driving? Does one really have an advantage over the other, and if so how can we ensure the modules return to Coast mode when the chassis stops but the default drive command is still running in teleop?
When I hit e-stop, I want the robot to stop. Not continue to roll. For that reason my drivetrain is always on brake mode.
While actually driving, your steer motors are PiDing, so brake mode really doesn’t come into play. And you should be using velocity control on the wheels. Velocity control will try to keep the wheel speed zero when it doesn’t see a command, which is de-facto brake mode.
You should look at what YAGSL-Example does. It turns on brake-mode for when the Robot gets disabled, and for the first 10 seconds of being disabled. Afterwards, it switches to coast mode to allow it to be pushed easily.
/**
* This function is called once each time the robot enters Disabled mode.
*/
@Override
public void disabledInit()
{
m_robotContainer.setMotorBrake(true);
disabledTimer.reset();
disabledTimer.start();
}
@Override
public void disabledPeriodic()
{
if (disabledTimer.hasElapsed(Constants.DrivebaseConstants.WHEEL_LOCK_TIME))
{
m_robotContainer.setMotorBrake(false);
disabledTimer.stop();
}
}
As someone who has setup robots on the field, swerve in coast doesn’t help with alignment, it just has hard to move and requires a lift. One wheel twisted stops all movement. It’s not like tank/mecanum drives.
And I wouldn’t recommend coast while disabled either, we were trying a balance auto in 2023, the robot ran off the back; we slammed e-stop, but the robot still had enough momentum to put a hole in drywall 10’ away…
From a competition standpoint the typical end game timer to hold position is 5 secs, which is why it’s that in YAGSL-Example
Actually, you, you want the motors to be on brake mode when using PID or really almost any form of feedback control. The models used to model motor behavior assume the phases are always closed, which is brake mode. Using coast mode adds a discontinuity to the system which can cause unexpected behaviors.
We use brake mode but have a button on the joystick to swap the drive motors into coast mode. It even works when the robot is disabled.
this match is why i’ll never recommend coast on swerve. If you do run coast, make sure to have the swerve brake once the robot is disabled.
Just curious why do you want that?
Sorry first year here, what am I supposed to be seeing in this clip?
6369 (immeasurably underrated team, check them out) barely hits 5431 in the stage in our first playoff match. the two tech fouls gave the other alliance enough points to win the match.
having less control with coast, especially at the end of the match, can be dangerous for last-second cycling/movement.
enjoy your rookie season!
Why?
Consider that each wheel on a swerve drive is given a direction and a magnitude vector. Simply sending a motor voltage introduces variability, because a given voltage to one wheel will not result in the same velocity as a voltage given to another wheel: motor differences, friction, voltage sag, and other effects will change the actual resultant velocity of the wheel. Sending a velocity command and allowing the motor controller to close the loop to give you the actual magnitude that was commanded will result in more accuracy, in both teleop and auto. You will see less drift, less scrub, and better odometetry as a result.
In a tank drive, closing the loop on velocity is a great help in having your drive train drive straight, because the left and right sides will actually go the velocity you’ve commanded.
To expand on this a bit further, in closed-loop controllers outputting Voltage and DutyCycle, ideally you should keep the motors in brake mode. Coast won’t completely break system behavior because it only takes effect when motor output (after any configured deadband) is exactly 0, which is rare, but it is still possible.
On the other hand, in closed-loop controllers outputting TorqueCurrentFOC, you actually want to put the motors in coast mode; brake mode introduces a discontinuity point. 0 A torque current is supposed to correspond to 0 acceleration, which matches coast behavior. In velocity control in particular, it’s not uncommon for TorqueCurrentFOC PID gains to output 0, which causes poor behavior in brake mode.
Thank you all. We are using the Advantage Kit Talon FX Swerve template and by default it uses Voltage control for closed loop. What I intended to ask at the beginning was whether using swerve on coast or brake would make a difference in the stress it causes to the motors and modules. In other words, would anything change significantly in the stopping behavior of the modules?
Sorry for pulling this thread off-topic, maybe it’s worth getting it split out.
I am aware of these benefits, but given how many teams - including top teams with lots of automation - say it’s more of a driver preference thing under driver control, I wonder how large those benefits actually are. The argument for open loop is generally driver intuition; drivers naturally expect controller stick throw to translate to effort from the robot, not to maintain a specific speed.
For auto, yes, I absolutely agree. But I’ve seen enough arguments against it in teleop that I don’t think there’s necessarily a right answer here. There was a thread on it a couple years ago that didn’t seem to come to a conclusion (beyond ‘do what your drivers are better at’): Swerve Open Loop vs Closed Loop - Technical / Programming - Chief Delphi
A simple heading controller on the turning input will do the same, and is what we used to do in teleop with a tank drive.