Odometry
package com.seattlesolvers.solverslib.kinematics
Pose Exponential
Offsets and Trackwidth
Creating the Odometry
Using the Odometry Class
// define our trackwidth
static final double TRACKWIDTH = 13.7;
// convert ticks to inches
static final double TICKS_TO_INCHES = 15.3;
// create our encoders
MotorEx encoderLeft, encoderRight;
encoderLeft = new MotorEx(hardwareMap, "left_encoder");
encoderRight = new MotorEx(hardwareMap, "right_encoder");
// create our odometry
DifferentialOdometry diffOdom = new DifferentialOdometry(
() -> encoderLeft.getCurrentPosition() * TICKS_TO_INCHES,
() -> encoderRight.getCurrentPosition() * TICKS_TO_INCHES,
TRACKWIDTH
);
// update the initial position
diffOdom.updatePose(new Pose2d(1, 2, 0));
// control loop
while (!isStopRequested()) {
/* implementation */
// update the position
diffOdom.updatePose();
}