Context: Our team has finally received our Swerve X modules, we hooked up 2 NEO’s w/ SparkMax, using CANCoders. We don’t have an actual chassis, so we propped up the modules on wood I copied and modified some code from FRC 0 to Autonomous (source code for that video)
Our CANCoders are connected to our turning motors’ SparkMax, so that we didn’t have to connect them into our DIO ports on the RIO (We’re reserving them for other things like limit switches).
Our Swerve code lives in this repo, more specifically, the code is divided into SwerveModule, SwerveDrive, and finally a ControlSwerve command that drives it.
In RobotContainer, we’ve created an instance of our swerve drive and then set the ControlSwerve as the default command:
private final SwerveDrive swerveDrive = new SwerveDrive();
/** The container for the robot. Contains subsystems, OI devices, and commands. */
public RobotContainer() {
// Configure the trigger bindings
configureBindings();
swerveDrive.setDefaultCommand(new ControlSwerve(swerveDrive,
() -> controller.getRawAxis(1)*-1,
() -> controller.getRawAxis(2),
() -> controller.getRawAxis(4),
() -> true));
}
... rest of the code ...
Now, the problem is that when I run this code, I can drive forward and back on the left axis, and rotate using the right axis. But I can’t strafe at all.
At first I thought this was a code error, but I could not identify any problems. So, I asked the electrical group of my team to see if anything was wrong, however they hadn’t noticed anything.
I was 80% sure that my code was correct, so I decided to try and run the turning motor automatically in code. Here is what I did:
At the top of my Robot class: I declared a CANSparkMax and set the id to one of the turning motors
CANSparkMax testingMotor = new CANSParkMax(2, MotorType.kBrushless);
then in teleopPeriodic() i just run the motor at .5 speed forever:
@Override
public void teleopPeriodic() {
testingmotor.set(.5);
}
However, when I run this motor does not move, however our SparkMax does get the signal because it “blinks”, so then I tried changing the id in the constructor to 1 (drive motor), and then our drive motor moves perfectly.
So why does the turning motor not move? Even if the SparkMax connected to it can clearly get the signal? I even checked REV Hardware client, yet I don’t see any issues there either.
So now I’m certain that this is a problem with electrical, but we are unsure as to what is causing this.
here is what our swerve electrical board looks like [Imgur album]
I got these photos before I left our robotics lab today, if anyone needs better pictures, I will update this tommorow