LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
subsystems.hpp File Reference

Robot subsystem declarations: motors, sensors, and pistons. More...

#include "LightLib/lib.hpp"
#include "LightLib/util/rotational_snap.hpp"
#include "pros/motors.hpp"

Go to the source code of this file.

Functions

Motors

Syntax:

inline pros::Motor name(PORT); // forward
inline pros::Motor name(-PORT); // negative port = reversed
inline pros::MotorGroup name({A, -B}); // group multiple motors

Useful methods:

  • name.move(speed) run at -127 … 127
  • name.move_voltage(mV) run at -12000 … 12000 mV
  • name.get_temperature() degrees C (>55 = hot, >70 = thermal limit)
  • name.get_actual_velocity() measured RPM
pros::Motor Top (7)
 
pros::Motor Bottom (17)
 
pros::MotorGroup Score ({17, 7})
 Top + Bottom together.
 
pros::Motor turret (0)
 Set port to 0 if not installed.
 
pros::Optical optical (15)
 Optical sensor for color sorting.
 

Variables

Drive chassis
 The drive chassis, configured in main.cpp and used everywhere else.
 
Pistons (ADI / 3-wire)

Syntax: ‘inline light::Piston name('PORT’); PORT` is the letter A–H matching the 3-wire port on the brain or expander.

light::Piston tracks toggle state and supports:

  • name.set(true / false) extend / retract
  • name.button_toggle(btn) toggle state when btn is newly pressed
light::Piston Wings ('A')
 Intake wings / expander.
 
light::Piston Loader ('C')
 Ball loader / indexer.
 
light::Piston MidGoal ('D')
 Mid-goal clamp or mechanism.
 
light::Piston Hood ('E')
 Scoring hood.
 

Alliance color

Set allianceColor at the start of autonomous (in user_autonomous() or your auton routine) to control color-sort behavior:

  • allianceColor = RED; sort out blue rings
  • allianceColor = BLUE; sort out red rings
  • allianceColor = NEUTRAL; sort nothing
enum  Colors { BLUE = 0 , NEUTRAL = 1 , RED = 2 }
 Alliance color enum used by the color-sort logic. More...
 
Colors allianceColor
 Currently active alliance color.
 

Lift with rotational snapping

A motor + rotation sensor pair that snaps to the nearest preset angle when the operator stops driving it.

While DIGITAL_UP / DIGITAL_DOWN is held — or the right joystick is deflected — the motor moves manually. As soon as the operator releases, the lift latches the closest snap angle and runs a P controller to it, then holds (motor brake mode is set to HOLD in main.cpp).

To use: replace port 0 with your real motor / rotation-sensor ports, then edit the snap angles (degrees) to match your mechanism's rest stops.

light::RotationalSnap Lift (LiftMotor, LiftRot, {0.0, 45.0, 90.0, 135.0, 180.0}, 1.5, 1.0, 80)
 Lift assembly: snaps to {0, 45, 90, 135, 180}° at rest.
 
pros::Motor LiftMotor (0)
 0 = disabled until you set the port.
 
pros::Rotation LiftRot (0)
 Rotation sensor on the lift axis.
 

Detailed Description

Robot subsystem declarations: motors, sensors, and pistons.

Everything declared inline here is available in every .cpp file that includes this header — no extern declarations needed elsewhere.

The drive chassis is declared in main.cpp (built from the #defines at the top of that file) and re-exposed here as extern Drive chassis.

Definition in file subsystems.hpp.

Enumeration Type Documentation

◆ Colors

enum Colors

Alliance color enum used by the color-sort logic.

Enumerator
BLUE 
NEUTRAL 
RED 

Definition at line 96 of file subsystems.hpp.

Function Documentation

◆ Bottom()

pros::Motor Bottom ( 17  )
inline

◆ LiftMotor()

pros::Motor LiftMotor ( )
inline

0 = disabled until you set the port.

◆ LiftRot()

pros::Rotation LiftRot ( )
inline

Rotation sensor on the lift axis.

◆ optical()

pros::Optical optical ( 15  )
inline

Optical sensor for color sorting.

◆ Score()

pros::MotorGroup Score ( {17, 7}  )
inline

Top + Bottom together.

◆ Top()

pros::Motor Top ( )
inline

◆ turret()

pros::Motor turret ( )
inline

Set port to 0 if not installed.

Variable Documentation

◆ allianceColor

Colors allianceColor
extern

Currently active alliance color.

◆ chassis

Drive chassis
extern

The drive chassis, configured in main.cpp and used everywhere else.

◆ Hood

light::Piston Hood( 'E') ( 'E'  )
inline

Scoring hood.

◆ Lift

light::RotationalSnap Lift(LiftMotor, LiftRot, {0.0, 45.0, 90.0, 135.0, 180.0}, 1.5, 1.0, 80) ( LiftMotor  ,
LiftRot  ,
{0.0, 45.0, 90.0, 135.0, 180.0}  ,
1.  5,
1.  0,
80   
)
inline

Lift assembly: snaps to {0, 45, 90, 135, 180}° at rest.

◆ Loader

light::Piston Loader( 'C') ( 'C'  )
inline

Ball loader / indexer.

◆ MidGoal

light::Piston MidGoal( 'D') ( 'D'  )
inline

Mid-goal clamp or mechanism.

◆ Wings

light::Piston Wings( 'A') ( 'A'  )
inline

Intake wings / expander.