RaidZeroLib
Coroutine robot framework for VEX V5
Loading...
Searching...
No Matches
rz Namespace Reference

Classes

struct  ArcadeConfig
class  Component
 Anything with a loop that runs for the whole program: devices, estimators, mechanisms, loggers. More...
class  Controller
 A V5 controller (the handheld joystick). More...
class  CubicBezier
 Cubic Bézier parametric path segment. More...
class  Device
 Base for anything plugged into a V5 smart port. The only layer that talks to hardware. More...
class  DiscretePath
 Immutable sequence of 2D waypoints with unit-safe geometry. More...
class  DriveController
 Drives a skid-steer robot straight for a distance, with a PID on the distance and another holding the heading it started at. More...
struct  GearRatio
 A gear reduction, from the tooth counts as you would read them off the robot. More...
class  InertialSensor
 V5 Inertial Sensor, read as a heading, counterclockwise positive seen from above (ENU). More...
class  Log
 Logging. Messages are stamped with the runtime time and tick number they were logged in. More...
class  Motor
 Something that turns a voltage into motion: a V5 motor, a motor group, a simulated motor, a power-takeoff port, or a test mock. More...
class  MotorDevice
 V5 Smart Motor. Its built-in encoder is exposed as sensors on the same snapshot. More...
class  MotorFeedforward
 The voltage a motor needs to hold a velocity and acceleration, from characterization: staticFriction * sign(velocity) + velocity gain * velocity + acceleration gain * acceleration. More...
class  MotorGroup
 Several motors driving one mechanism, used as a single Motor. More...
class  Odometry
 Tracks the robot's pose on the field from its sensors. More...
class  ParametricPath
 Differentiable 2D path over a unit-interval parameter t ∈ [0, 1]. More...
class  Pid
 A PID controller from an error to an output, e.g. Pid<Angle, Voltage> for a turn. More...
class  PiecewiseCubicBezier
 Piecewise cubic Bézier path over t ∈ [0, 1] with segment-uniform parameterization. More...
class  Platform
 What the runtime needs from the outside world: a clock, a way to wait, and the competition mode. More...
class  Point
 Immutable 2D point / vector with unit-safe Cartesian coordinates. More...
class  Pose
 Rigid-body pose in SE(2) with unit-safe position and rotation. More...
class  ProsController
 The master or partner V5 controller, read through PROS. More...
class  ProsPlatform
 Platform backed by the PROS clock, scheduler and competition status. More...
struct  RobotConfig
 Everything that makes up a robot program. More...
class  Rotation
 Immutable planar rotation about the Z axis. More...
class  RotationSensor
 V5 Rotation Sensor. Reads continuous (multi-turn) angle. More...
class  Runtime
 The single-threaded tick loop that drives every coroutine. More...
class  Sensor
 A reading from hardware, or computed from other sensors. More...
class  SensorView
 One consumer's zero on a shared sensor. Resetting it affects nobody else. More...
class  Settled
 Whether an error has stayed within a tolerance for long enough, e.g. Settled<Angle> to end a turn. More...
class  SimulationController
 A controller whose sticks and buttons are set by a test or simulation. Read like a real one, each tick. More...
class  SimulationMotor
 A first-order motor model: speed approaches (voltage / 12 V) × free speed with a time constant. More...
class  SimulationPlatform
 Fake clock for host tests: sleeping jumps time forward, so runs are instant and deterministic. More...
class  SimulationSensor
 A sensor whose reading and connection are set directly, for tests. More...
class  SkidSteerChassis
 A drivetrain with a left and a right side, each driven as one motor (usually a MotorGroup). More...
class  SleepAwaiter
 Awaiter that resumes at the first tick at or after a deadline. More...
struct  TankConfig
class  ThreeEncoderOdometry
 Left and right wheels that roll forward give the heading; a wheel that rolls sideways adds sideways motion. More...
class  TickAwaiter
 Awaiter for the next occurrence of a tick stage. Always suspends. More...
class  TrackingWheel
 How far a wheel has rolled, from the encoder measuring it: an unpowered tracking wheel on a rotation sensor, or a drive wheel read through its motor's encoder (motor.encoder(), which already accounts for the cartridge). More...
class  Transform
 Rigid-body transform in SE(2): translation (meters) + rotation (radians). More...
class  TurnController
 Turns a skid-steer robot in place to face a heading, with a PID on the heading error. More...
class  Twist
 Differential motion (twist) in SE(2) space. More...
class  TwoEncoderImuOdometry
 A wheel that rolls forward and one that rolls sideways, with the heading from an inertial sensor. More...
class  TwoEncoderOdometry
 Left and right wheels that roll forward. Assumes the robot never slides sideways. More...
class  Watchdog
 Detects when the runtime stops ticking because a coroutine is blocking the loop. More...

Typedefs

using StickCurve = std::function<double(double)>
 Shapes a stick input. Takes and returns a value from -1 to 1, e.g. [](double x) { return x * x * x; } for finer control at low speeds.
template<class T = void>
using Task = corral::Task<T>
 Lazy: nothing runs until it is co_awaited.
Quantity types used across the library. Any au quantity of the same dimension converts implicitly,

e.g. au::inches(24.0) → Length, au::milli(au::seconds)(500.0) → Duration.

using Length = au::QuantityD<au::Meters>
using Area = au::QuantityD<au::Squared<au::Meters>>
using Curvature = au::QuantityD<au::Inverse<au::Meters>>
using LinearVelocity = au::QuantityD<au::UnitQuotientT<au::Meters, au::Seconds>>
using Angle = au::QuantityD<au::Radians>
using AngularVelocity = au::QuantityD<au::UnitQuotientT<au::Radians, au::Seconds>>
using Voltage = au::QuantityD<au::Volts>
using Duration = au::QuantityD<au::Seconds>
using Time = au::QuantityPointD<au::Seconds>

Enumerations

enum class  Direction { Direction::Clockwise , Direction::Counterclockwise }
 A way a shaft can turn, seen looking at the face the shaft comes out of. More...
enum class  CompetitionMode { CompetitionMode::Disabled , CompetitionMode::Autonomous , CompetitionMode::Driver }
 What field control (or a competition switch) currently allows the robot to do. More...
enum class  TickStage : std::uint8_t { TickStage::TickStarted , TickStage::SensorsUpdated , TickStage::EstimatorsUpdated , TickStage::ComponentsUpdated }
 Where in a tick a waiter is resumed, named after what has just finished. Ticks run the stages in this order. More...

Functions

Task arcade (SkidSteerChassis &chassis, const Controller &controller, ArcadeConfig config={})
 The left stick's vertical axis drives; the right stick's horizontal axis turns (pushing right turns clockwise).
Task tank (SkidSteerChassis &chassis, const Controller &controller, TankConfig config={})
 The left stick's vertical axis drives the left side; the right stick's vertical axis drives the right.
Length circumradius (const Point &A, const Point &B, const Point &C) noexcept
 Circumradius of the triangle defined by three points.
std::optional< double > circleLineIntersection (const Point &start, const Point &end, const Point &center, Length radius) noexcept
 Intersection of a circle with a line segment.
Curvature curvatureToPoint (const Pose &pose, const Point &point) noexcept
 Signed curvature needed to reach a point from a pose assuming an instantaneous circular arc.
DiscretePath::const_iterator closestPoint (DiscretePath::const_iterator begin, DiscretePath::const_iterator end, const Point &point)
 Iterator-based closest-point search by Euclidean distance.
Task robot (RobotConfig config)
 The whole robot program as one task. Never returns.
TickAwaiter tickStarted (std::source_location location=std::source_location::current()) noexcept
 Resumes at the start of the next tick, before anything else runs. For device loops.
TickAwaiter sensorsUpdated (std::source_location location=std::source_location::current()) noexcept
 Resumes in the next tick once every device has been polled. For estimators, and for code that only reacts to hardware. Estimates read here may still be from the previous tick.
TickAwaiter estimatorsUpdated (std::source_location location=std::source_location::current()) noexcept
 Resumes in the next tick once every estimator has run. For user code and mechanisms.
TickAwaiter componentsUpdated (std::source_location location=std::source_location::current()) noexcept
 Resumes in the next tick once every component that writes has run. For logging and telemetry.
SleepAwaiter sleepFor (Duration duration, std::source_location location=std::source_location::current()) noexcept
 Resumes at estimatorsUpdated in the first tick whose start time is at least duration from now.
template<std::predicate P>
Task< void > until (P pred)
 Waits until pred() is true, checking once per tick at estimatorsUpdated. Returns at once if already true.
Time now ()
 Time at the start of the current tick of the current runtime.
Duration dt ()
 Duration of the current tick of the current runtime.
template<typename T>
constexpr int sgn (T val) noexcept
 Sign of a value: 1 if positive, -1 if negative, 0 if zero.
double constrainAngle360 (double angle) noexcept
 Wraps an angle in degrees to [0, 360).
double constrainAngle180 (double angle) noexcept
 Wraps an angle in degrees to [-180, 180).
Angle constrainAngle360 (Angle angle) noexcept
 Wraps an angle to [0, 2π).
Angle constrainAngle180 (Angle angle) noexcept
 Wraps an angle to [-π, π).
double sinc (double x) noexcept
 sin(x) / x, numerically stable near zero.
std::optional< std::pair< double, double > > quadraticFormula (double a, double b, double c) noexcept
 Real roots of ax² + bx + c = 0, smallest first.
void start (RobotConfig config)
 Starts RaidZeroLib on the brain. Call once from initialize().