Okay, so obviously PID control is needed for the turning/steering motors on swerve modules, but what about for the drive velocity? I figured that most teams would want PID on the drive velocity as well rather than just setting power in % vbus mode, but that doesn’t seem to be the case from the code examples I’ve seen. Is PID control really unnecessary on the drive velocity?
It depends what you mean by “necessary.” What do you want to accomplish with the drive?
If you just want it to behave reasonably in response to manual control, open-loop velocity is fine.
Yeah, manual control, but also autonomous trajectory-following with PathPlanner paths. For some reason a lot of the tutorials/examples I’ve seen online for swerve code don’t use the “SimpleMotorFeedforward” ks, kv, ka constants, even in their autonomous code
Maybe it’s simply because these tutorials are just trying to stick with the basics?
Those are feedforward constants, not feedback constants. If a team is following a trajectory there is a feedback controller somewhere on the position signal - it may be closed on the robot odometry, which is calculated jointly from the encoders and gyro.
Ah okay, so that would be like the “xController”, “yController”, and “thetaController” objects right? The ones you have to pass in as parameters to the PPSwerveControllerCommand? Yeah we have those already, but for Rapid React we characterized our mecanum bot with SysID to get feedforward constants as well for calculating the setpoint voltage. So is this part not necessary for autonomous trajectory-following with swerve?
It’s not strictly necessary, but it will definitely help track the trajectories better if you use the constants correctly.
What I mean is how to actually set the module states, most of the examples I have seen just do something like this for setting the drive velocity: driveMotor.set(state.speedMetersPerSecond / RobotMap.kPhysicalMaxSpeedMetersPerSecond);
Is this enough, even for trajectory-following? I thought that using % vbus mode like this would negatively effect performance as the battery voltage drops?
It depends on how you calculated the voltage that you’re passing in through percent vbus mode.
Yes; you should have voltage compensation turned on to account for this.
Okay yeah, we’ll definitely turn on voltage compensation. I guess we can always just try what we have first, and then if we aren’t happy with the performance, we can try characterizing with SysID and using the feedforward constants
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.