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

Custom movement primitives using LightLib's Drive and dual distance sensors. More...

#include "LightLib/lib.hpp"
#include "LightLib/main.h"

Go to the source code of this file.

Functions

void custom_move_init (light::Drive &chassis)
 Register the chassis used by the custom movement primitives.
 
void WallRide (pros::Distance *frontSensor, pros::Distance *leftSensor, double stopDistIn, double targetDistIn, int baseSpeed=80, int timeout=5000)
 Drive forward while wall-tracking on the left.
 

Detailed Description

Custom movement primitives using LightLib's Drive and dual distance sensors.

Dependencies
Setup
Two steps required before use:
  1. Call custom_move_init() once inside initialize() in main.cpp, passing your existing light::Drive chassis object:
    void custom_move_init(light::Drive &chassis)
    Register the chassis used by the custom movement primitives.
    Drive chassis
    The drive chassis, configured in main.cpp and used everywhere else.
  2. Declare two pros::Distance sensors — one on the front of the robot and one on the left side — and call WallRide():
    pros::Distance frontDist(PORT_A);
    pros::Distance leftDist(PORT_B);
    WallRide(&frontDist, &leftDist, 6.0, 4.0);
    void WallRide(pros::Distance *frontSensor, pros::Distance *leftSensor, double stopDistIn, double targetDistIn, int baseSpeed=80, int timeout=5000)
    Drive forward while wall-tracking on the left.
    Drives forward until front sensor reads ≤ 6 inches, maintaining 4 inches from the left wall throughout.
Motor control scale
All speed values use LightLib's -127..127 scale (not raw millivolts).
Note
The light::Drive reference is stored as a pointer at runtime inside custom_move_init(), avoiding the PROS cold/hot package linker constraint.

Definition in file custom_move.hpp.

Function Documentation

◆ custom_move_init()

void custom_move_init ( light::Drive chassis)

Register the chassis used by the custom movement primitives.

Must be called once in initialize() before WallRide().

Parameters
chassisthe user's Drive instance

◆ WallRide()

void WallRide ( pros::Distance *  frontSensor,
pros::Distance *  leftSensor,
double  stopDistIn,
double  targetDistIn,
int  baseSpeed = 80,
int  timeout = 5000 
)

Drive forward while wall-tracking on the left.

Combines two behaviors:

  1. Stops when the front distance sensor reads ≤ stopDistIn.
  2. Maintains targetDistIn from a left-side wall via a PD steering loop.

Pass nullptr for a sensor whose port is 0 (not installed). Returns immediately if frontSensor is nullptr. If leftSensor is nullptr, the robot drives straight with no wall correction.

Parameters
frontSensorfront-facing distance sensor (stop condition)
leftSensorleft-facing distance sensor (wall-tracking)
stopDistInfront threshold in inches — robot stops when front reads ≤ this
targetDistIndesired lateral distance from the left wall, inches
baseSpeedforward drive speed, 0–127
timeoutmax run duration in milliseconds before forced exit