Skip to content

Elevator

The elevator subsystem is for a single elevator. It can be used to move to a position and respond to manual commands.

To create an elevator subsystem, you can use the following code:

wom::Elevator *elevator = new wom::Elevator("elevator path (in nt tables)", config) // config is a ElevatorConfig

Parameters

TypeNameDescriptionSee Also
wom::ElevatorConfigconfigThe configuration for the elevator

Config

TypeNameDescriptionSee Also
std::stringpathThe path to the elevator in the NT tables
wom::GearboxleftGearboxThe left gearbox for the elevator
wom::GearboxrightGearboxThe right gearbox for the elevator
wom::CANSparkMaxEncoderencoderThe encoder for the elevator
frc::DigitalInput*topSensorThe top sensor for the elevator
frc::DigitalInput*bottomSensorThe bottom sensor for the elevator
units::meter_tradiusThe radius of the elevator
units::kilogram_tmassThe mass of the elevator
units::meter_tmaxHeightThe maximum height of the elevator
units::meter_tminHeightThe minimum height of the elevator
units::meter_tinitialHeightThe initial height of the elevator
wom::PIDConfig<units::meter, units::volt>pidThe PID configuration for the elevatorPID Config
wom::PIDConfig<units::meters_per_second, units::volt>velocityPIDThe velocity PID configuration for the elevatorPID Config

States

wom::ElevatorState is an enum of states for the elevator.

NameValueDescription
kIdle0The elevator is idle
kPID1The elevator is in PID mode
kManual2The elevator is in manual mode
kVelocity3The elevator is in velocity mode

Methods

SetManual

Sets the elevator to manual mode.

void SetManual(units::volt_t voltage)

Usage

elevator->SetManual(12_V)

SetPID

Sets the elevator to PID mode.

void SetPID(units::meter_t height)

Usage

elevator->SetPID(1_m)

SetState

Sets the state of the elevator.

void SetState(wom::ElevatorState state)

See States for the possible states.

Usage

elevator->SetState(wom::ElevatorState::kPID)

SetVelocity

Sets the elevator to velocity mode.

void SetVelocity(units::meters_per_second_t velocity)

Usage

elevator->SetVelocity(1_mps)

GetElevatorEncoderPos

Returns the elevator encoder position.

double GetElevatorEncoderPos()

Usage

double pos = elevator->GetElevatorEncoderPos()

SetElevatorSpeedLimit

Sets the elevator speed limit.

void SetElevatorSpeedLimit(double limit)

Usage

elevator->SetElevatorSpeedLimit(1_mps)

GetConfig

Gets the config of the elevator.

Returns wom::ElevatorConfig (see above)

Usage

wom::ElevatorConfig config = elevator->GetConfig()

IsStable

Returns whether the elevator is stable.

bool IsStable()

Usage

bool stable = elevator->IsStable()

GetState

Returns the state of the elevator.

wom::ElevatorState GetState()

Usage

wom::ElevatorState state = elevator->GetState()

GetHeight

Returns the height of the elevator.

units::meter_t GetHeight()

Usage

units::meter_t height = elevator->GetHeight()

MaxSpeed

Returns the maximum speed of the elevator.

units::meters_per_second_t MaxSpeed()

Usage

units::meters_per_second_t maxSpeed = elevator->MaxSpeed()

GetElevatorVelocity

Returns the elevator velocity.

units::meters_per_second_t GetElevatorVelocity()

Usage

units::meters_per_second_t velocity = elevator->GetElevatorVelocity()