Skip to main content
Version: 3.2.1

3.1.0 -> 3.2.0

note

There are no breaking changes between 3.1.0 and 3.2.0.

You can safely upgrade your project without doing anything to it. To use odometry, follow this page to get your example project up to date!

Upgrading​

Follow this tutorial to upgrade your project to the latest EZ-Template version.

Default Constants​

There are additional constants for 3.2 for odometry.

chassis.pid_odom_angular_constants_set(6.5, 0.0, 52.5);
chassis.pid_odom_boomerang_constants_set(5.8, 0.0, 32.5);

chassis.pid_odom_turn_exit_condition_set(90_ms, 3_deg, 250_ms, 7_deg, 500_ms, 750_ms);
chassis.pid_odom_drive_exit_condition_set(90_ms, 1_in, 250_ms, 3_in, 500_ms, 750_ms);

chassis.odom_turn_bias_set(0.9);

chassis.odom_look_ahead_set(7_in);
chassis.odom_boomerang_distance_set(16_in);
chassis.odom_boomerang_dlead_set(0.625);

3.2 also introduces the option for turn behavior. In every previous version of EZ-Template, the raw IMU value was used for turning. This made it unintuitive on what angle to tell the robot to go to. If you already have existing autonomous routines with 3.1 and you want to leave your turns alone, you can choose to only set odometry to always take the shortest path with

chassis.pid_odom_behavior_set(ez::shortest);

If you'd like to default turns, swings, and odometry turns to always take the shortest path, you can with this function.

chassis.pid_angle_behavior_set(ez::shortest);

These are the 3.2.0 example project default constants.

void default_constants() {
// P, I, D, and Start I
chassis.pid_drive_constants_set(20.0, 0.0, 100.0); // Fwd/rev constants, used for odom and non odom motions
chassis.pid_heading_constants_set(11.0, 0.0, 20.0); // Holds the robot straight while going forward without odom
chassis.pid_turn_constants_set(3.0, 0.05, 20.0, 15.0); // Turn in place constants
chassis.pid_swing_constants_set(6.0, 0.0, 65.0); // Swing constants
chassis.pid_odom_angular_constants_set(6.5, 0.0, 52.5); // Angular control for odom motions
chassis.pid_odom_boomerang_constants_set(5.8, 0.0, 32.5); // Angular control for boomerang motions

// Exit conditions
chassis.pid_turn_exit_condition_set(90_ms, 3_deg, 250_ms, 7_deg, 500_ms, 500_ms);
chassis.pid_swing_exit_condition_set(90_ms, 3_deg, 250_ms, 7_deg, 500_ms, 500_ms);
chassis.pid_drive_exit_condition_set(90_ms, 1_in, 250_ms, 3_in, 500_ms, 500_ms);
chassis.pid_odom_turn_exit_condition_set(90_ms, 3_deg, 250_ms, 7_deg, 500_ms, 750_ms);
chassis.pid_odom_drive_exit_condition_set(90_ms, 1_in, 250_ms, 3_in, 500_ms, 750_ms);
chassis.pid_turn_chain_constant_set(3_deg);
chassis.pid_swing_chain_constant_set(5_deg);
chassis.pid_drive_chain_constant_set(3_in);

// Slew constants
chassis.slew_turn_constants_set(3_deg, 70);
chassis.slew_drive_constants_set(3_in, 70);
chassis.slew_swing_constants_set(3_in, 80);

// The amount that turns are prioritized over driving in odom motions
// - if you have tracking wheels, you can run this higher. 1.0 is the max
chassis.odom_turn_bias_set(0.9);

chassis.odom_look_ahead_set(7_in); // This is how far ahead in the path the robot looks at
chassis.odom_boomerang_distance_set(16_in); // This sets the maximum distance away from target that the carrot point can be
chassis.odom_boomerang_dlead_set(0.625); // This handles how aggressive the end of boomerang motions are

chassis.pid_angle_behavior_set(ez::shortest); // Changes the default behavior for turning, this defaults it to the shortest path there
}

Reset XYT​

At the start of autonomous there are a bunch of functions that reset everything on your robot so it starts fresh every time. We'll need to add a new line that resets the position of the robot to (0, 0). That can be done with this line of code.

chassis.odom_xyt_set(0_in, 0_in, 0_deg);

That makes the autonomous function look like this.

void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency

ez::as::auton_selector.selected_auton_call(); // Calls selected auton from autonomous selector
}

Create Tracking Wheels​

note

Tracking wheels are not required for EZ-Template! Read the installation page for more information.

You can create tracking wheels using ADI Encoders, ADI Encoders plugged into 3-wire Expanders, and Rotation Sensors.

2.75 is the wheel diameter, and 4.0 is the distance to the center of the robot. You can use a tape measure to find this value, or you can follow this tutorial.

ez::tracking_wheel right_tracker({-'A', -'B'}, 2.75, 4.0);  // ADI Encoders
ez::tracking_wheel left_tracker(1, {'C', 'D'}, 2.75, 4.0); // ADI Encoders plugged into a Smart port
ez::tracking_wheel horiz_tracker(1, 2.75, 4.0); // Rotation sensors

You can tell EZ-Template which trackers to use in initialize. Your constructor and initialize should look like this after.

// Chassis constructor
ez::Drive chassis(
// These are your drive motors, the first motor is used for sensing!
{-5, -6, -7, -8}, // Left Chassis Ports (negative port will reverse it!)
{11, 15, 16, 17}, // Right Chassis Ports (negative port will reverse it!)

21, // IMU Port
4.125, // Wheel Diameter (Remember, 4" wheels without screw holes are actually 4.125!)
420.0); // Wheel RPM = cartridge * (motor gear / wheel gear)

// Are you using tracking wheels? Comment out which ones you're using here!
// `2.75` is the wheel diameter
// `4.0` is the distance from the center of the wheel to the center of the robot
ez::tracking_wheel right_tracker({-'A', -'B'}, 2.75, 4.0); // ADI Encoders
ez::tracking_wheel left_tracker(1, {'C', 'D'}, 2.75, 4.0); // ADI Encoders plugged into a Smart port
ez::tracking_wheel horiz_tracker(1, 2.75, 4.0); // Rotation sensors

/**
* Runs initialization code. This occurs as soon as the program is started.
*
* All other competition modes are blocked by initialize; it is recommended
* to keep execution time for this mode under a few seconds.
*/
void initialize() {
// Print our branding over your terminal :D
ez::ez_template_print();

pros::delay(500); // Stop the user from doing anything while legacy ports configure

// Are you using tracking wheels? Comment out which ones you're using here!
chassis.odom_tracker_right_set(&right_tracker);
chassis.odom_tracker_left_set(&left_tracker);
chassis.odom_tracker_back_set(&horiz_tracker); // Replace `back` to `front` if your tracker is in the front!

// . . .

Making Sure Tracking Wheels are Reversed Correctly​

The 3.2.0 example project has a screen task that displays some data to the brain screen. This includes the robots position, tracking wheel values, and tracking wheel width. You can follow along with this tutorial to set this up in your project.

Ensure that your left/right tracking wheels increase positively when pushing the robot forward, and your front/back tracking wheels increase positively when pushing the robot to the right.

If any sensor is reading the wrong way, make the port negative in the constructor.