Skip to main content
Version: 3.2.2

3.1.0 -> 3.2.x

note

There are no breaking changes between 3.1.0 and 3.2.x.

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.x 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 horiz_tracker(8, 2.75, 4.0);  // This tracking wheel is perpendicular to the drive wheels
ez::tracking_wheel vert_tracker(-9, 2.75, 4.0); // This tracking wheel is parallel to the drive wheels

You'll now need to tell EZ-Template what tracking wheels to use.

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

// Look at your horizontal tracking wheel and decide if it's in front of the midline of your robot or behind it
// - change `back` to `front` if the tracking wheel is in front of the midline
// - ignore this if you aren't using a horizontal tracker
chassis.odom_tracker_back_set(&horiz_tracker);
// Look at your vertical tracking wheel and decide if it's to the left or right of the center of the robot
// - change `left` to `right` if the tracking wheel is to the right of the centerline
// - ignore this if you aren't using a vertical tracker
chassis.odom_tracker_left_set(&vert_tracker);

// . . .
}

Making Sure Tracking Wheels are Reversed Correctly​

The 3.2.x 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.