Skip to main content

Motion Functions

JAR Template provides a multitude of ways to control the chassis using PID and odometry.

note

Each movement function includes a basic and an advanced prototype and example. Most of the time, the basic prototype will be suitable for your need. But JAR Template movement functions are overloaded, which means that you can provide extra information to the function on the fly, depending on the movement you want to make. And although only a "basic" and an "advanced" function are included here, most of the movement functions are overloaded even more, allowing for more flexibility.

info

On units in JAR Template: all functions take angles in degrees, distances in inches, times in milliseconds, and voltages in volts, with a maximum voltage of 12.

Non-Odometry Functions

turn_to_angle();

void Drive::turn_to_angle(float angle);
note

In JAR Template, turns are field-centric, meaning that using chassis.turn_to_angle(0); will always bring the robot to the same orientation in which it began the autonomous function.

drive_distance();

void Drive::drive_distance(float distance);

left_swing_to_angle();

void Drive::left_swing_to_angle(float angle);

right_swing_to_angle();

void Drive::right_swing_to_angle(float angle);

Odometry Functions

drive_to_point();

void Drive::drive_to_point(float X_position, float Y_position);

turn_to_point();

void Drive::turn_to_point(float X_position, float Y_position);

note

float extra_angle_deg is used to specify some deviation from the front of the robot and the desired point. Specifically, the controller will make the robot overshoot by that amount of degrees. So an extra_angle_deg value of 90 will make the robot turn its left side toward the desired point.

holonomic_drive_to_point();

void Drive::holonomic_drive_to_point(float X_position, float Y_position);

note

When the value of angle is specified, the controller will attempt to drive the robot to the desired point and turn it to the desired angle simultaneously. When it is left unspecified, the robot will maintain its orientation throughout the movement.