Skip to main content
Version: 4.0.0-beta.3

General

Tracking Wheels​

For a more in depth guide to Tracking Wheels look at this guide.

odom_tracker_left_set()​

Sets the parallel left tracking wheel for odometry.

input an ez::tracking_wheel

void odom_tracker_left_set(tracking_wheel* input);

odom_tracker_right_set()​

Sets the parallel right tracking wheel for odometry.

input an ez::tracking_wheel

void odom_tracker_right_set(tracking_wheel* input);

odom_tracker_front_set()​

Sets the perpendicular front tracking wheel for odometry.

input an ez::tracking_wheel

void odom_tracker_front_set(tracking_wheel* input);

odom_tracker_back_set()​

Sets the perpendicular back tracking wheel for odometry.

input an ez::tracking_wheel

void odom_tracker_back_set(tracking_wheel* input);

Custom Tracking​

By default, position is computed by tracking_wheels_tracking(), using whatever tracking wheels or drive encoders you configured. odom_tracking_set() lets you replace that entirely, for example to fuse in a camera or a different sensor.

odom_tracking_set()​

Sets a new task to use for tracking.

In the function you pass in, you must set odom_current.x, odom_current.y, and odom_current.theta. x and y are in inches and theta is in degrees. The function does not need to loop, that is done for you by EZ-Template.

EZ-Template calls your function about every 10 ms from its background task, while that task holds the drive lock. Setters like pid_drive_set() wait for that lock, so don't call pros::delay() or anything else that blocks in your function, or every setter will wait on it.

tracking_task new function for tracking

void odom_tracking_set(std::function<void(void)> tracking_task);

tracking_wheels_tracking()​

The default tracking task, used unless odom_tracking_set() is called. Documented here for reference - most users will never call this directly.

void tracking_wheels_tracking();

Pose​

odom_enable()​

Enables / disables tracking.

input true enables tracking, false disables tracking

void odom_enable(bool input);

odom_enabled()​

Returns whether the bot is tracking with odometry.

True means tracking is enabled, false means tracking is disabled.

bool odom_enabled();

odom_x_set()​

Sets the current x position of the robot.

x new x coordinate in inches

void odom_x_set(double x);

odom_x_set()​

Sets the current X coordinate of the robot.

p_x new x coordinate as a unit

void odom_x_set(ez::QLength p_x);

odom_y_set()​

Sets the current Y coordinate of the robot.

y new y coordinate in inches

void odom_y_set(double y);

odom_y_set()​

Sets the current Y coordinate of the robot.

p_y new y coordinate as a unit

void odom_y_set(ez::QLength p_y);

odom_theta_set()​

Sets the current Theta of the robot.

a new angle in degrees

void odom_theta_set(double a);

odom_theta_set()​

Sets the current angle of the robot.

p_a new angle as a unit

void odom_theta_set(ez::QAngle p_a);

odom_xy_set()​

Sets the current X and Y coordinate for the robot.

x new x value, in inches
y new y value, in inches

void odom_xy_set(double x, double y);

odom_xy_set()​

Sets the current X and Y coordinate for the robot.

p_x new x value, in units
p_y new y value, in units

void odom_xy_set(ez::QLength p_x, ez::QLength p_y);

odom_xyt_set()​

Sets the current X, Y, and Theta values for the robot.

x new x value, in inches
y new y value, in inches
t new theta value, in degrees

void odom_xyt_set(double x, double y, double t);

odom_xyt_set()​

Sets the current X, Y, and Theta values for the robot.

p_x new x value, in units
p_y new y value, in units
p_t new theta value, in units

void odom_xyt_set(ez::QLength p_x, ez::QLength p_y, ez::QAngle p_t);

odom_pose_set()​

Sets the current pose of the robot.

itarget {x, y, t} units in inches and degrees

void odom_pose_set(pose itarget);

odom_pose_set()​

Set the current pose of the robot.

itarget {x, y, t} as a unit

void odom_pose_set(united_pose itarget);

odom_x_get()​

Returns the current x position of the robot in inches.

double odom_x_get();

odom_y_get()​

Returns the current Y coordinate of the robot in inches.

double odom_y_get();

odom_theta_get()​

Returns the current Theta of the robot in degrees.

double odom_theta_get();

odom_pose_get()​

Returns the current pose of the robot.

pose odom_pose_get();

Movement Constants​

pid_odom_angular_constants_set()​

Set the odom angular pid constants object.

p proportional term
i integral term
d derivative term
p_start_i error threshold to start integral

void pid_odom_angular_constants_set(double p, double i = 0.0, double d = 0.0, double p_start_i = 0.0);

odom_turn_bias_set()​

A proportion of how prioritized turning is during odometry motions.

Turning is prioritized so the robot "applies brakes" while turning. Lower number means more braking.

Values below 1 make the robot stop driving once turning has gone past a certain angle error, and the robot will never drive backwards to reach the point. The internal scale factor is clamped between 0 and 1.

Non-positive values are rejected, a message is printed to the terminal, and the previous value is kept.

bias a positive number, default is 0.9

void odom_turn_bias_set(double bias);

pid_odom_drive_exit_condition_set()​

Set's constants for odom driving exit conditions.

p_small_exit_time time to exit when within small_error, in units
p_small_error small timer will start when error is within this, in units
p_big_exit_time time to exit when within big_error, in units
p_big_error big timer will start when error is within this, in units
p_velocity_exit_time time, in units, for velocity to be 0 after the robot has moved (or after 1 second if it never moves)
p_mA_timeout mA timer will start when the first motor on the side(s) being driven is over its current limit, in units
use_imu true adds a second velocity exit timer based on the imu's acceleration (exits if either the main sensor or the imu reports no movement for p_velocity_exit_time), false uses only the main sensor

void pid_odom_drive_exit_condition_set(ez::QTime p_small_exit_time, ez::QLength p_small_error, ez::QTime p_big_exit_time, ez::QLength p_big_error, ez::QTime p_velocity_exit_time, ez::QTime p_mA_timeout, bool use_imu = true);

pid_odom_drive_exit_condition_set()​

Set's constants for odom driving exit conditions.

p_small_exit_time time to exit when within small_error, in ms
p_small_error small timer will start when error is within this, in inches
p_big_exit_time time to exit when within big_error, in ms
p_big_error big timer will start when error is within this, in inches
p_velocity_exit_time velocity timer will start when velocity is 0 after the robot has moved (or after 1 second if it never moves), in ms
p_mA_timeout mA timer will start when the first motor on the side(s) being driven is over its current limit, in ms
use_imu true adds a second velocity exit timer based on the imu's acceleration (exits if either the main sensor or the imu reports no movement for p_velocity_exit_time), false uses only the main sensor

void pid_odom_drive_exit_condition_set(int p_small_exit_time, double p_small_error, int p_big_exit_time, double p_big_error, int p_velocity_exit_time, int p_mA_timeout, bool use_imu = true);

pid_odom_turn_exit_condition_set()​

Set's constants for odom turning exit conditions.

p_small_exit_time time to exit when within small_error, in units
p_small_error small timer will start when error is within this, in units
p_big_exit_time time to exit when within big_error, in units
p_big_error big timer will start when error is within this, in units
p_velocity_exit_time time, in units, for velocity to be 0 after the robot has moved (or after 1 second if it never moves)
p_mA_timeout mA timer will start when the first motor on the side(s) being driven is over its current limit, in units
use_imu true adds a second velocity exit timer based on the imu's acceleration (exits if either the main sensor or the imu reports no movement for p_velocity_exit_time), false uses only the main sensor

void pid_odom_turn_exit_condition_set(ez::QTime p_small_exit_time, ez::QAngle p_small_error, ez::QTime p_big_exit_time, ez::QAngle p_big_error, ez::QTime p_velocity_exit_time, ez::QTime p_mA_timeout, bool use_imu = true);

pid_odom_turn_exit_condition_set()​

Set's constants for odom turning exit conditions.

p_small_exit_time time to exit when within small_error, in ms
p_small_error small timer will start when error is within this, in degrees p_big_exit_time time to exit when within big_error, in ms p_big_error big timer will start when error is within this, in degrees p_velocity_exit_time velocity timer will start when velocity is 0 after the robot has moved (or after 1 second if it never moves), in ms p_mA_timeout mA timer will start when the first motor on the side(s) being driven is over its current limit, in ms
use_imu true adds a second velocity exit timer based on the imu's acceleration (exits if either the main sensor or the imu reports no movement for p_velocity_exit_time), false uses only the main sensor

void pid_odom_turn_exit_condition_set(int p_small_exit_time, double p_small_error, int p_big_exit_time, double p_big_error, int p_velocity_exit_time, int p_mA_timeout, bool use_imu = true);

odom_look_ahead_set()​

Sets how far away the robot looks in the path during pure pursuits.

distance how long the "carrot on a stick" is, in inches. Must be greater than 0. Otherwise it is rejected, a message is printed to the terminal, and the previous value is kept.

void odom_look_ahead_set(double distance);

odom_look_ahead_set()​

Sets how far away the robot looks in the path during pure pursuits.

p_distance how long the "carrot on a stick" is, in units. Must be greater than 0. Otherwise it is rejected, a message is printed to the terminal, and the previous value is kept.

void odom_look_ahead_set(ez::QLength p_distance);

pid_odom_behavior_set()​

Sets the default behavior for turns in odom turning movements.

behavior ez::shortest, ez::longest, ez::ccw, ez::cw, ez::raw

void pid_odom_behavior_set(e_angle_behavior behavior);

pid_odom_behavior_get()​

Returns the turn behavior for odom turns.

e_angle_behavior pid_odom_behavior_get();

odom_path_spacing_set()​

Sets the spacing between points when points get injected into the path.

p_spacing a small number in units. Must be greater than 0. Otherwise it is rejected, a message is printed to the terminal, and the previous value is kept.

void odom_path_spacing_set(ez::QLength p_spacing);

odom_path_spacing_set()​

Sets the spacing between points when points get injected into the path.

spacing a small number in inches. Must be greater than 0. Otherwise it is rejected, a message is printed to the terminal, and the previous value is kept.

void odom_path_spacing_set(double spacing);

odom_turn_bias_get()​

Returns the proportion of how prioritized turning is during odometry motions.

double odom_turn_bias_get();

odom_look_ahead_get()​

Returns how far away the robot looks in the path during pure pursuits.

double odom_look_ahead_get();

odom_path_spacing_get()​

Returns the spacing between points when points get injected into the path.

double odom_path_spacing_get();

slew_odom_reenable()​

Allows slew to reenable when the new input speed is larger than the current speed during pure pursuits.

reenable true enables, false disables

void slew_odom_reenable(bool reenable);

slew_odom_reenabled()​

Returns if slew will reenable when the new input speed is larger than the current speed during pure pursuits.

bool slew_odom_reenabled();

odom_path_smooth_constants_set()​

Sets the constants for smoothing out a path.

Path smoothing based on https://medium.com/@jaems33/understanding-robot-motion-path-smoothing-5970c8363bc4

weight_smooth how much weight to smooth the coordinates, 0 or more and less than 1
weight_data how much weight to keep the coordinates near the original path, 0 or more
tolerance how much change per iteration is necessary to keep iterating, greater than 0

weight_data + 2 * weight_smooth must also be less than 2. Smoothing makes repeated passes over the points, and at 2 or more each pass moves them further from the path instead of settling, so it would never finish. With the defaults that's 1.53.

If any of these are out of range, all of the constants are rejected, a message is printed to the terminal naming the first one that is out of range, and the previous constants are kept.

void odom_path_smooth_constants_set(double weight_smooth, double weight_data, double tolerance);

odom_path_smooth_constants_get()​

Returns the constants for smoothing out a path.

In order of:

  • weight_smooth
  • weight_data
  • tolerance
std::vector<double> odom_path_smooth_constants_get();

odom_path_print()​

Prints the current path the robot is following.

void odom_path_print();

Boomerang Behavior​

pid_odom_boomerang_constants_set()​

Set the odom boomerang pid constants object.

p proportional term
i integral term
d derivative term
p_start_i error threshold to start integral

void pid_odom_boomerang_constants_set(double p, double i = 0.0, double d = 0.0, double p_start_i = 0.0);

odom_boomerang_dlead_set()​

Sets a new dlead.

Dlead is a proportional value of how much to make the robot curve during boomerang motions.

input a value between 0 and 1

void odom_boomerang_dlead_set(double input);

odom_boomerang_distance_set()​

Sets how far away the carrot point can be from the target point.

distance distance in inches

void odom_boomerang_distance_set(double distance);

odom_boomerang_distance_set()​

Sets how far away the carrot point can be from the target point.

p_distance distance as a unit

void odom_boomerang_distance_set(ez::QLength p_distance);

odom_boomerang_dlead_get()​

Returns the current dlead.

double odom_boomerang_dlead_get();

odom_boomerang_distance_get()​

Returns the maximum distance the carrot point can be away from the target point.

double odom_boomerang_distance_get();