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

Misc math, geometry, and unit-conversion helpers. More...

Functions

int places_after_decimal (double input, int min=0)
 Returns the amount of places after a decimal, maxing out at 6.
 
std::string to_string_with_precision (double input, int n=2)
 Returns a string with a specific number of decimal points.
 
int sgn (double input)
 Returns 1 if input is positive and -1 if input is negative.
 
bool reversed_active (double input)
 Returns true if the input is < 0.
 
double clamp (double input, double max, double min)
 Returns input restricted to min-max threshold.
 
double clamp (double input, double max)
 Returns input restricted to min-max threshold.
 
double to_deg (double input)
 Converts radians to degrees.
 
double to_rad (double input)
 Converts degrees to radians.
 
double absolute_angle_to_point (pose itarget, pose icurrent)
 Returns the angle between two points.
 
double distance_to_point (pose itarget, pose icurrent)
 Returns the distance between two points.
 
double wrap_angle (double theta)
 Constrains an angle between 180 and -180.
 
float wrap_rad (float a)
 Wraps an angle in radians to the half-open interval (-pi, pi].
 
pose vector_off_point (double added, pose icurrent)
 Returns a new pose that is projected off of the current pose.
 
double turn_shortest (double target, double current, bool print=false)
 Returns the shortest angle for the robot to turn to in order to get to target.
 
double turn_longest (double target, double current, bool print=false)
 Returns the farthest away angle for the robot to turn to in order to get to target.
 
pose united_pose_to_pose (united_pose input)
 Converts pose with okapi units to a pose without okapi units.
 
std::vector< odomunited_odoms_to_odoms (std::vector< united_odom > inputs)
 Converts vector of poses with okapi units to a vector of poses without okapi units.
 
odom united_odom_to_odom (united_odom input)
 Converts odom movement with united pose to an odom movement without united pose.
 

Variables

bool AUTON_RAN
 Set true once any autonomous routine has run this match.
 
const bool SD_CARD_ACTIVE = pros::usd::is_installed()
 True if an SD card is currently inserted.
 
const int DELAY_TIME = 10
 Default loop period for LightLib background tasks, in milliseconds.
 

Detailed Description

Misc math, geometry, and unit-conversion helpers.

Function Documentation

◆ absolute_angle_to_point()

double light::util::absolute_angle_to_point ( pose  itarget,
pose  icurrent 
)

Returns the angle between two points.

Parameters
itargettarget position
icurrentcurrent position

◆ clamp() [1/2]

double light::util::clamp ( double  input,
double  max 
)

Returns input restricted to min-max threshold.

The minimum used is negative max.

Parameters
inputyour input value
maxthe absolute value maximum input can be

◆ clamp() [2/2]

double light::util::clamp ( double  input,
double  max,
double  min 
)

Returns input restricted to min-max threshold.

Parameters
inputyour input value
maxthe maximum input can be
minthe minimum input can be

◆ distance_to_point()

double light::util::distance_to_point ( pose  itarget,
pose  icurrent 
)

Returns the distance between two points.

Parameters
itargettarget position
icurrentcurrent position

◆ places_after_decimal()

int light::util::places_after_decimal ( double  input,
int  min = 0 
)

Returns the amount of places after a decimal, maxing out at 6.

Parameters
inputyour input value with decimals
minminimum number of decimal places to print, this is defaulted to 0

◆ reversed_active()

bool light::util::reversed_active ( double  input)

Returns true if the input is < 0.

Parameters
inputyour input value

◆ sgn()

int light::util::sgn ( double  input)

Returns 1 if input is positive and -1 if input is negative.

Parameters
inputyour input value

◆ to_deg()

double light::util::to_deg ( double  input)

Converts radians to degrees.

Parameters
inputyour input radian

◆ to_rad()

double light::util::to_rad ( double  input)

Converts degrees to radians.

Parameters
inputyour input degree

◆ to_string_with_precision()

std::string light::util::to_string_with_precision ( double  input,
int  n = 2 
)

Returns a string with a specific number of decimal points.

Parameters
inputyour input value
nthe amount of decimals you want to display

◆ turn_longest()

double light::util::turn_longest ( double  target,
double  current,
bool  print = false 
)

Returns the farthest away angle for the robot to turn to in order to get to target.

Parameters
targettarget value in degrees
currentcurrent value in degrees
print= false will print the new value if this is true, defaults to false

◆ turn_shortest()

double light::util::turn_shortest ( double  target,
double  current,
bool  print = false 
)

Returns the shortest angle for the robot to turn to in order to get to target.

Parameters
targettarget value in degrees
currentcurrent value in degrees
print= false will print the new value if this is true, defaults to false

◆ united_odom_to_odom()

odom light::util::united_odom_to_odom ( united_odom  input)

Converts odom movement with united pose to an odom movement without united pose.

Parameters
inputodom movement with units

◆ united_odoms_to_odoms()

std::vector< odom > light::util::united_odoms_to_odoms ( std::vector< united_odom inputs)

Converts vector of poses with okapi units to a vector of poses without okapi units.

Parameters
inputsposes with units

◆ united_pose_to_pose()

pose light::util::united_pose_to_pose ( united_pose  input)

Converts pose with okapi units to a pose without okapi units.

Parameters
inputa pose with units

◆ vector_off_point()

pose light::util::vector_off_point ( double  added,
pose  icurrent 
)

Returns a new pose that is projected off of the current pose.

Parameters
addedhow far to project a new point
icurrentpoint to project off of

◆ wrap_angle()

double light::util::wrap_angle ( double  theta)

Constrains an angle between 180 and -180.

Parameters
thetainput angle in degrees

◆ wrap_rad()

float light::util::wrap_rad ( float  a)
inline

Wraps an angle in radians to the half-open interval (-pi, pi].

Uses atan2(sin, cos) rather than a while-loop normalization: branch-free and stable across very large inputs.

Parameters
ainput angle in radians

Definition at line 291 of file util.hpp.

Variable Documentation

◆ AUTON_RAN

bool light::util::AUTON_RAN
extern

Set true once any autonomous routine has run this match.

◆ DELAY_TIME

const int light::util::DELAY_TIME = 10

Default loop period for LightLib background tasks, in milliseconds.

Definition at line 236 of file util.hpp.

◆ SD_CARD_ACTIVE

const bool light::util::SD_CARD_ACTIVE = pros::usd::is_installed()

True if an SD card is currently inserted.

Captured at program start.

Definition at line 233 of file util.hpp.