Talon FX not running constantly after set()

So I am using two Talon FX’s to run a flywheel, and when I use an InstantComma d that runs both flywheels with the set() methods with ControlType.PercentOutput, the flywheels run for a split second and stop. This did not happen last year however, as the flywheels actually stayed running, so was there a change to how the set() method works?

1 Like

Nope. Can we see some code?

1 Like
public void flywheelOut() {
    leftFlywheelMotor.set(ControlMode.PercentOutput, FLYWHEEL_MOTOR_PERCENT);
    rightFlywheelMotor.set(ControlMode.PercentOutput, FLYWHEEL_MOTOR_PERCENT);
}

public static Command flywheelOutCommand() {
    return new InstantCommand(
        () -> Robot.shooter.flywheelOut(),
        Robot.shooter
    );
}

Here it is.

“The InstantCommand class (Java, C++) executes a single action on initialization, and then ends immediately:”

So if you have a defaultCommand for your Robot.shooter that stops the motors, they will stop immediately after the instant commands. Using a RunCommand instead of an InstantCommand should solve this problem.

I don’t have a default command that does that for the shooter subsystem, and I don’t think I can use a run command because I’m using this command in a sequential command group and the command wouldn’t terminate, so the next command wouldn’t be run.

Make sure the motors aren’t opposing each other, and check the current limits.

2 Likes

Put the Run command parallel to the next set of commands

Might look like this

parallel(new spinflyWheel_Command(flywheel_Subsystem),
              sequential(new waitcommand(3), new IndexCargo_Command(cargoIndexer_Subsystem)
              )
         )

I think it’s fine because we have the same command running for teleop constantly, we just can’t for this situation

If you share the github link to the entire code it would be easier for us to help!

1 Like

Here’s the code.

Are you in a specific branch? Your main errors out because both your left drive motor and elevator motor are using ID 4.

What are you doing (button press?) to induce the problem?

Edit. If I fix that when I press and hold the Left bumper I see the flywheel motors spin, is that not as intended? You should probably also remove the print bombing the log.

The one-time set is used for autonomous, and I can’t necessarily use too many run commands in autonomous due to them never ending. The one time set should be in the shooter commands file as a basic command

I think it might have something with our motors bot being able to overcome their static friction in just one set. I’m going to try to use while loops that run the set command until it overcomes the static friction by checking velocity

Okay so this doesn’t seem like it could have been the code you were using to test that because your auto just does driveOffTarmac. I changed it to twoBallAutoTopBlue and in simulation it turns on both the shoot motors. So I really need to know EXACTLY how you were testing this.

I disagree about static friction. The motor is being set to 90% that is way about the point where friction matters.

You can decorate a RunCommand to have it end. For example you turn on the shooter and wait 3 seconds. This could be new RunCommand(() -> Robot.shooter.flywheelOut(), Robot.shooter).withTimeout(3));

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