How to Use the Slow Mode Manager
Introduction
The SlowModeManager
is a utility designed to manage slow mode configurations for an FTC robot, enabling dynamic speed adjustments using gamepad inputs. This allows for more precise control, particularly during delicate maneuvers.
Note: The slow mode factor is a DIVISION factor, meaning a factor of 2.0
will halve the speed.
Key Components
1. SlowModeManager
The SlowModeManager
class manages different slow modes based on a predefined mapping of keys to SlowModeMulti
instances.
Creating a SlowModeManager
There are multiple ways to initialize a SlowModeManager
:
Constructors
SlowModeManager(HashMap<Enum<?>, SlowModeMulti> slowModeDataList, GamepadPlus gamepad)
SlowModeManager(HashMap<Enum<?>, SlowModeMulti> slowModeDataList, Gamepad gamepad)
SlowModeManager(GamepadPlus gamepad)
SlowModeManager(List<Pair<Enum<?>, SlowModeMulti>> list, GamepadPlus gamepad)
Core Methods
double apply(double value)
- Adjusts a given value based on the currently active slow mode.DrivePowerCoefficients apply(DrivePowerCoefficients drivePowerCoefficients)
- Modifies drive power coefficients.void update()
- Updates the active slow mode based on gamepad input.void telemetry(Telemetry telemetry)
- Displays the current slow mode in telemetry.
2. SlowModeMulti
The SlowModeMulti
class defines an individual slow mode configuration, specifying activation and deactivation buttons.
Creating a SlowModeMulti
The Constructors
SlowModeMulti(SlowMode slowModeData, Button activeButton, Button deactiveButton)
SlowModeMulti(SlowMode slowModeData, Button activeButton)
Built-in Configurations
static SlowModeMulti basic()
- Returns a slow mode with a factor of2.0
, activated byButton.A
.
3. SlowMode
The SlowMode
class defines a slow mode with a configurable factor.
Creating a SlowMode
Singular Constructor
SlowMode(double slowModeFactor)
Predefined Modes
static SlowMode basic()
- A factor of2.0
.static SlowMode one()
- A factor of1.0
(no change).static SlowMode of(double slowModeFactor)
- Creates a custom slow mode factor.
Usage Example
This example demonstrates how to integrate SlowModeManager
with a gamepad.
Best Practices
Ensure
SlowModeManager
is initialized with a validslowModeDataList
.Call
update()
frequently to capture button state changes.Use telemetry to display the active slow mode for debugging.
With this setup, your FTC robot can dynamically adjust its movement speed based on gamepad input, providing better control during gameplay.