SwerveX drivingmotor doesn't move

Hello,

When trying to make an auto code that sets the location of a swerve module, I found that the turning motor would go to a set position, but the driving motor wouldn’t move at all. From the readong in the shuffleDashboard, it is being set to our correct speed value, before returning back to 0. The Auto being run is move1module Code is attached below, all help is appreciated.

Asher L
Team 4169

You need to set self.startTime in the initialize() function and not in the command constructor. When it is set in the constructor, the time is basically when the robot code starts so the command will mostly likely immediately finish.

after trying that, it still just stops. I found that even without anything in the isFinished, (just a return true) also results in the motor going to a certain location then no wheel rotation. I’m thinking it must have something to do with the setDesiredState function but I don’t know why it the speed value would be changing

You are setting the drive motor to 0 in end() by setting the desired state to 0 meters per second. If you comment that out, does the drive motor run continuously?

Even with all of the isfinished() commented out and the end() commented out, it still rotates and doens’t drive

Okay, just to clarify a bit - does your code work in teleOp?

We haven’t tested it yet. This was supposed to be a starting point (getting a module to go to a spicific location and rotate at a specific speed).

Okay, if you put self.swerve.frontRight.setDesiredState() in the execute() function instaed of the init() function and have the command run continuously, does the speed of the module print out in SmartDashboard? What is the printed speed?

Everything is the same. We’re getting some weird led signals from the other can spark maxes, but other than that, the speed still goes up to our expected value for a moment, then comes instantly back down

Are you able to use the REV Hardware Client to control the drive motor directly? Be aware you need to disconnect the SparkMAX from the roboRIO CAN bus and power cycle it to be able to control it through the hardware client.

You can also try calling self.driveMotor.restoreFactoryDefaults() on line 30 in swervemodule.py. If this SparkMAX was set to follower mode previously, it will not take direct commands from the set() function.

Everything seems okay in the Hardware client. Thanks for all your help. I decided to ignore this for now and get teleop to work. I may have to revisit this in the near future. Thanks again for trying to help us with this

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