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

RAMSETE trajectory follower public API. More...

#include <functional>
#include <vector>
#include "LightLib/path/trajectory.hpp"

Go to the source code of this file.

Classes

struct  light::PathEvent
 Mid-path action triggered at a specific input waypoint. More...
 
struct  light::RamseteConfig
 RAMSETE controller and chassis-geometry config. More...
 
struct  light::DriveFF
 Per-wheel feedforward + simple velocity-loop gains. More...
 

Namespaces

namespace  light
 Public LightLib odometry / pose-estimation API.
 

Functions

void light::ramsete_configure (RamseteConfig rc, DriveFF ff, TrajConstraints defaultCons)
 Configure the RAMSETE follower.
 
bool light::followTrajectory (const Trajectory &traj, int timeoutMs=-1, float poseErrBailIn=8.0f)
 Follow a pre-generated Trajectory.
 
bool light::followTrajectory (const std::vector< Waypoint > &wps, const TrajConstraints &cons, bool reversed=false, int timeoutMs=-1, float poseErrBailIn=8.0f)
 Generate and follow a trajectory from waypoints.
 
bool light::followTrajectory (const std::vector< Waypoint > &wps, const TrajConstraints &cons, std::vector< PathEvent > events, bool reversed=false, int timeoutMs=-1, float poseErrBailIn=8.0f)
 Generate-and-follow variant with mid-path event triggers.
 
bool light::runJerryioPath (const char *csv, bool reversed=false, int timeoutMs=-1, float poseErrBailIn=8.0f)
 Run a waypoint path exported from path.jerryio.com (or any CSV-like text).
 
bool light::runJerryioPath (const char *csv, std::vector< PathEvent > events, bool reversed=false, int timeoutMs=-1, float poseErrBailIn=8.0f)
 Variant with mid-path event triggers.
 
bool light::runJerryioPathFromSD (const char *filePath, bool reversed=false, int timeoutMs=-1, float poseErrBailIn=8.0f)
 Read the CSV from the V5 SD card (e.g.
 
bool light::runJerryioPathFromSD (const char *filePath, std::vector< PathEvent > events, bool reversed=false, int timeoutMs=-1, float poseErrBailIn=8.0f)
 SD-card variant with mid-path event triggers.
 
void light::autotune_ekf_noise (int sampleMs=10, int durationMs=5000, int warmupMs=500)
 Stationary EKF process-noise calibration.
 
void light::autotune_mcl_noise (int sampleMs=20, int durationMs=4000, int warmupMs=300)
 Stationary MCL distance-sensor noise calibration.
 
Characterization routines

Each is meant to be run as its own selectable auton.

void light::characterize_kV_kA_kS (float maxVoltage=10.0f, float rampVps=0.25f)
 Identify kV / kA / kS by ramping voltage and recording velocity.
 
float light::characterize_track_width (int rotations=10)
 Identify the effective track width by spinning in place.
 
float light::characterize_a_lat_max ()
 Identify the maximum sustainable lateral acceleration.
 
void light::characterize_friction (float maxVoltage=10.0f, float stepV=0.5f)
 Friction-FF auto-ID for the non-trajectory PID controllers.
 
Relay-feedback (Åström–Hägglund) PID auto-tune

Each routine runs a bang-bang oscillation around the current pose, measures the steady-state amplitude a and period Tu, computes

Ku = 4·h/(π·a), Pu = Tu,
kP = 0.6·Ku, kI = 2·kP/Pu, kD = kP·Pu/8 (Z-N classic PID)
Discrete PID controller with rich exit-condition support.
Definition pid.hpp:30

then printfs the result AND calls the matching EZ pid_*_constants_set so the tune is live on the chassis immediately. You still need to transcribe the printout into default_constants() for it to survive a program restart.

Common parameters
  • reliefV — relay voltage amplitude (volts, ±). Must exceed kS — if the robot never moves, the tune times out and aborts without overwriting the previous PID values.
  • cycles — total number of full oscillation cycles to average.
  • timeoutMs — active-time bail (cooldowns don't count against this).
  • chunkCycles — cycles per chunk before a motor cooldown kicks in. 0 = no cooldowns (legacy continuous behavior).
  • coolMs — motor-off pause between chunks. Wall time ≈ timeoutMs + (cycles/chunkCycles - 1)·coolMs.
Space requirements
  • turn / swing — about 2 ft² (in-place oscillation).
  • drive — ≥ 8 ft straight clear ahead.
  • heading — ≥ 8 ft straight lane; the robot drives forward at forwardV while the relay corrects heading around 0.
void light::autotune_turn_pid (float reliefV=4.0f, int cycles=6, int timeoutMs=15000, int chunkCycles=2, int coolMs=5000)
 
void light::autotune_drive_pid (float reliefV=6.0f, int cycles=5, int timeoutMs=15000, int chunkCycles=2, int coolMs=5000)
 
void light::autotune_swing_pid (float reliefV=4.0f, int cycles=6, int timeoutMs=15000, int chunkCycles=2, int coolMs=5000)
 
void light::autotune_heading_pid (float forwardV=3.0f, float reliefV=2.0f, int cycles=5, int timeoutMs=15000, int chunkCycles=2, int coolMs=5000)
 

Detailed Description

RAMSETE trajectory follower public API.

Time-parameterized path following on the VEX tankdrive. The follower owns the motor groups exclusively for the duration of the motion and pauses the EZ-Template drive PID task while it runs.

Typical usage
// In initialize():
{ 2.0f, 0.7f, 11.5f, 3.25f, 0.75f }, // RamseteConfig
{ 0.60f, 0.18f, 0.03f, 0.02f }, // DriveFF (kS, kV, kA, kP)
{ 48.0f, 60.0f, 60.0f, 60.0f }); // TrajConstraints
// In an auton:
std::vector<light::Waypoint> path = { {0,0}, {24,24,M_PI/2}, {48,0} };
light::followTrajectory(path, { 48, 60, 60, 40 });
void ramsete_configure(RamseteConfig rc, DriveFF ff, TrajConstraints defaultCons)
Configure the RAMSETE follower.
bool followTrajectory(const Trajectory &traj, int timeoutMs=-1, float poseErrBailIn=8.0f)
Follow a pre-generated Trajectory.

Definition in file ramsete.hpp.