Hello,
we are having trouble with our swerve drive actually steering. When the code is deployed it only spins the drive motors when either the y axis of the left stick or the x axis of the right stick is used. We have all our encoders working and all the can ID’s for the motor controllers are correct. Please help me identify our error. We are using neo’s, sparkmax’s , Cancoders, and a pigeon on our MK4i swerve modules. See Below for details:
Constants.java (7.3 KB)
SwerveSubsystem.java (7.6 KB)
DriveSubsystem.java (8.6 KB)
Having the file where drive()
is called, probably in Robot.java or RobotContainer.java would also be helpful to see how you are calling the main function for the drive.
You don’t have your code posted on a github by chance do you?
I think I did this correctly see if this helps make it easier
So on initial looks:
public void drive(double xSpeed, double ySpeed, double rot, boolean fieldRelative, boolean rateLimit
is the function you call to drive your robot around. In RobotContainer.java, you are making the call as:
new RunCommand(
() -> m_robotDrive.drive(
-MathUtil.applyDeadband(m_driverController.getLeftY(), OIConstants.kDriveDeadband),
-MathUtil.applyDeadband(m_driverController.getLeftX(), OIConstants.kDriveDeadband),
-MathUtil.applyDeadband(m_driverController.getRightX(), OIConstants.kDriveDeadband),
true, true),
m_robotDrive));
I believe you are wanting it to be:
new RunCommand(
() -> m_robotDrive.drive(
-MathUtil.applyDeadband(m_driverController.getLeftX(), OIConstants.kDriveDeadband),
-MathUtil.applyDeadband(m_driverController.getLeftY(), OIConstants.kDriveDeadband),
-MathUtil.applyDeadband(m_driverController.getRightX(), OIConstants.kDriveDeadband),
true, true),
m_robotDrive));
you might need to invert your Left X, so just put a “-” in front of it like:
-m_driverController.getLeftX()
It did not fix the issue When we move the right stick the drive motors only run
Update
We have seen now our problem is that either the turn id’s are not responding or the drive id’s are not responding to the drive comand. We’ve flipped the CAN ID’s and instead of driving it only turns so our issue has now been dumbed down to a drive or drive subsystem error on our end. We still do not know a solution to our issue, any help would be appreciated, thank you.