How to get CANSparkMax into LiveWindows

Is there a way to get a CANSparkMax into Livewindow so that we can fiddle with it in test mode? All the LiveWindow documentation seems out of date, and the SendableRegistry stuff doesn’t work (CANSparkMax does not implement the Sendable interface).

Can’t you make a wrapper class that implements Sendable? You’d also need to make a corresponding smartdashboard/shuffleboard widget.

I can… I just want to avoid it. I have a hard time believing that REV didn’t build it in, and that I am missing something.

What feature(s) did you want? For example, while CTRE implements sendable, it’s implementation limits it to that of a PWM Speed Controller (ie set/get percent output).

That’s exactly what I was after; we had a “dead” motor, wanted to run it in test mode.

I wrote a quick-and-dirty robot program as a workaround, but I really miss test mode. The wrapper can be an off-season project…

…but let me know if you catch wind of anyone else going down that road. Safety in numbers / burden halved, etc.

It should only a few lines of code in a wrapper.

You could always use the REV Hardware Client?

I suspected it would be simple. Thank you digging into it; I’ll get that integrated in this week (exam week, no student Tu-We-Th).

possibly. Had a lot of problems with it (“CAN bus already in use”?). Will double check.

Thank you.

https://docs.revrobotics.com/sparkmax/troubleshooting#rule-out-issues-by-isolation

Thanks. I suspect it will be a quick job.

The problem ended up being a code bug that set the P in the position PID for one swerve unit in our robot to 0. PID works lousy with P=0 (“works” being a generous term).

Thanks for the reminder that it could be simple; I’ll try to get it going in the next couple of days, and I would hope that REV would be happy to get it.

It ended up easy to do as a subclass.

package frc.robot.miscellaneous;

import com.revrobotics.CANSparkMax;
import edu.wpi.first.util.sendable.Sendable;
import edu.wpi.first.util.sendable.SendableBuilder;
import edu.wpi.first.util.sendable.SendableRegistry;

public class CANSparkMaxSendable extends CANSparkMax implements Sendable  {
    public CANSparkMaxSendable(int deviceId, MotorType motorType) {
        super(deviceId, motorType);
        SendableRegistry.addLW(this, "SparkMax", deviceId);
    }

    @Override
    public void initSendable(SendableBuilder builder) {
        builder.setSmartDashboardType("Motor Controller");
        builder.setActuator(true);
        builder.setSafeState(this::stopMotor);
        builder.addDoubleProperty("Value", this::get, this::set);
    }
}

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