bovlb/frc-tips

Coast mode trigger

Closed this issue · 4 comments

For coast mode, it says:

Create trigger

In Robot.java, at the end of robotInit, add the following code:

new Trigger(this::isEnabled)
    .negate()
    .debounce(3)
    .whenActive(new SetCoastModeCommand(m_robotContainer.m_driveSubsystem));

Is there a reason that m_robotContainer.m_driveSubsystem.setBrakeMode(false); isn't added at disabledInit in Robot.java instead, similarly to how brake mode is enabled in autonomousInit, teleopInit, and testInit?

bovlb commented

Hi. There are reasons why we don't want to do this, and I tried to explain them under "Background". Essentially:

  • If you disable a robot that is moving at high speed, you don't want it to just keep going.
  • If a robot is on a ramp at the end of the match (e.g. 2012's Rebound Rumble), you don't want it to roll off before it gets scored.

It would be helpful if you let me know how I could communicate this better.

I see, so it is to ensure that there is a delay first, before setting coast mode?

bovlb commented

Right. I'm going to add some comments within the code.

Okay, that makes sense, thanks!