Decorator help

Trying to use the WithTimeout decorator using an inline declared command in my RobotContainer.

In RobotContainer.h
frc2::StartEndCommand m_ReleaseClimber{[this] {m_climber.WinchRetract();}, [this] {m_climber.WinchStop();}, {&m_climber}};

In RobotContainer.cpp in ConfigureButtonBindings
frc2::JoystickButton(&m_driver,5).WhenPressed(m_ReleaseClimber.WithTimeout(1.0_s));

Compile error saying Command::WithTimeout can’t be called on an lvaue, so I’m assuming decorator can’t be use the way I’m trying. (I suspected it was a problem because WhenPressed didn’t show up and an available method in the popup.

Found my issue. Found an example in HatchbotInline example project.

// The autonomous routines
frc2::ParallelRaceGroup m_simpleAuto =
frc2::StartEndCommand(
[this] { m_drive.ArcadeDrive(ac::kAutoDriveSpeed, 0); },
[this] { m_drive.ArcadeDrive(0, 0); }, {&m_drive})
.BeforeStarting([this] { m_drive.ResetEncoders(); })
.WithInterrupt([this] {
return m_drive.GetAverageEncoderDistance() >=
ac::kAutoDriveDistanceInches;
});

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