All pages
Powered by GitBook
1 of 5

Loading...

Loading...

Loading...

Loading...

Loading...

Setting Velocity

Setting Velocity in our Program

Velocity is a closed loop control within the SDK that uses the encoder counts to determine the approximate power/speed the motors need to go in order to meet the set velocity.

To set a velocity, its important to understand the maximum velocity in RPM your motor is capable of. For the Class Bot V2 the motors are capable of a maximum RPM of 300. With a drivetrain, you are likely to get better control by setting velocity lower than the maximum. In this case, lets set the velocity to 175 RPM!

Since RPM is the amount of revolutions per minute, a conversion needs to be made from RPM to ticks per second (TPS). To do this, divide the RPM by 60 to get the amount of rotations per second.

Rotations per second can then be multiplied by COUNTS_PER_WHEEL_REV, to get the amount of ticks per second.

TPS=17560∗CPWRTPS = \frac{175}{60} * CPWRTPS=60175​∗CPWR

Adding Ticks per Second as a Variable

Create a new double variable called TPS. AddTPS the to the OpMode under where rightTarget is defined:

Exchange the setPower();functions for setVelocity();

Add TPS as the parameter for setVelocity();

With the velocity set, let's give our program a test run after building!

With the current state of the code you are likely to get errors similar to the ones pictured below:

This is because the setVelocity();function is a function of theDcMotorEx Interface. The DcMotorEx Interface is an extension of the DcMotor Interface, that provides enhanced motor functionality, such as access to closed loop control functions.

To use setVelocity(); the motor variables need to be changed to DcMotorEx as seen below:

Turning the Drivetrain Using RUN_TO_POSITION

Often times, like in the program created during Part 2: Robot Control, we use setPower(); to set the drivetrain motors to a set power or power based on a joystick's inputs. The combined power going to both motors help to determine the direction the robot moves or turns.

However, in RUN_TO_POSITION mode the encoder counts are used instead to dictate directionality of the motor.

Since speed an directionality impacts how a robot turns, target position and velocity need to be edited to get the robot to turn. Consider the following code:

The rightTarget has been changed to be a negative target position. Assuming that the encoder starts at zero due to STOP_AND_RESET_ENCODER this causes the robot to turn to the right.

Notice the velocity is the same for both motors. If you try running this code, you can see that the robot pivots along its center of rotation.

To get a wider turn, try changing the velocity so that the right motor is running at a lower velocity than the left motor. Adjust the velocity and target position as needed to get the turn you need.

Changing from Power to Velocity

DcMotor vs. DcMotorEx

Since DcMotorEx is an extension of DcMotor, DcMotor specific functions can be used by variables defined as DcMotorEx.

Full Program

int leftTarget = (int)(610 * COUNTS_PER_MM);
int rightTarget = (int)(-610 * COUNTS_PER_MM);
double TPS = (100/ 60) * COUNTS_PER_WHEEL_REV;
       
        
waitForStart();
        
        
leftmotor.setTargetPosition(leftTarget);
rightmotor.setTargetPosition(rightTarget);
        
leftmotor.setMode(DcMotor.RunMode.RUN_TO_POSITION);
rightmotor.setMode(DcMotor.RunMode.RUN_TO_POSITION);
        
leftmotor.setVelocity(TPS);
rightmotor.setVelocity(TPS);
public void runOpMode() {
        leftmotor = hardwareMap.get(DcMotor.class, "leftmotor");
        rightmotor = hardwareMap.get(DcMotor.class, "rightmotor");
        
        rightmotor.setDirection(DcMotor.Direction.REVERSE);
        
        leftmotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
        rightmotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
        
        int leftTarget = (int)(610 * COUNTS_PER_MM);
        int rightTarget = (int)(610 * COUNTS_PER_MM);
        double TPS = (175/60) * COUNTS_PER_WHEEL_REV;
        
        waitForStart();
waitForStart();

leftmotor.setTargetPosition(leftTarget);
rightmotor.setTargetPosition(rightTarget);

leftmotor.setMode(DcMotor.RunMode.RUN_TO_POSITION);
rightmotor.setMode(DcMotor.RunMode.RUN_TO_POSITION);

leftmotor.setVelocity(TPS);
rightmotor.setVelocity(TPS);

while (opModeIsActive() && (leftmotor.isBusy() && rightmotor.isBusy())){
        
        }
public class HelloRobot_Encoder extends LinearOpMode {
    private DcMotorEx leftmotor;
    private DcMotorEx rightmotor;
public void runOpMode() {
        leftmotor = hardwareMap.get(DcMotorEx.class, "leftmotor");
        rightmotor = hardwareMap.get(DcMotorEx.class, "rightmotor");
@Autonomous

public class HelloRobot_Encoder extends LinearOpMode {
    private DcMotorEx leftmotor;
    private DcMotorEx rightmotor;
    
    static final double     COUNTS_PER_MOTOR_REV    = 28.0; 
    static final double     DRIVE_GEAR_REDUCTION    = 30.24;   
    static final double     WHEEL_CIRCUMFERENCE_MM  = 90.0 * 3.14;
    
    static final double     COUNTS_PER_WHEEL_REV    = COUNTS_PER_MOTOR_REV * DRIVE_GEAR_REDUCTION;
    static final double     COUNTS_PER_MM           = COUNTS_PER_WHEEL_REV / WHEEL_CIRCUMFERENCE_MM;
    
    @Override
    public void runOpMode() {
        leftmotor = hardwareMap.get(DcMotorEx.class, "leftmotor");
        rightmotor = hardwareMap.get(DcMotorEx.class, "rightmotor");
        
        rightmotor.setDirection(DcMotor.Direction.REVERSE);

        leftmotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
        rightmotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
        
        
        int leftTarget = (int)(610 * COUNTS_PER_MM);
        int rightTarget = (int)(610 * COUNTS_PER_MM);
        double TPS = (175/ 60) * COUNTS_PER_WHEEL_REV;
        
        waitForStart();
        
        
        leftmotor.setTargetPosition(leftTarget);
        rightmotor.setTargetPosition(rightTarget);
        
        leftmotor.setMode(DcMotor.RunMode.RUN_TO_POSITION);
        rightmotor.setMode(DcMotor.RunMode.RUN_TO_POSITION);
        
        leftmotor.setVelocity(TPS);
        rightmotor.setVelocity(TPS);
        
        while (opModeIsActive() && (leftmotor.isBusy() && rightmotor.isBusy())) {
        }
    }
}

Moving to a Target Distance

Now that you have created the constant variables needed to calculate the amount of ticks per mm moved, you can use this to set a target distance. For instance, if you would like to have the robot move forward two feet, converting from feet to millimeters and multiplying by the COUNTS_PER_MM will give you the amount of counts (or ticks) needed to reach that distance!

Create two more variables called leftTarget andrightTarget.

These variables can be fluctuated and edited in your code to tell the motors what positions to go to, rather than place them with the constant variables, create these variables within the OpMode but above the waitForStart(); command.

public void runOpMode() {
        leftmotor = hardwareMap.get(DcMotor.class, "leftmotor");
        rightmotor = hardwareMap.get(DcMotor.class, "rightmotor");
        
        rightmotor.setDirection(DcMotor.Direction.REVERSE);
        
        leftmotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
        rightmotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
        
        int leftTarget;
        int rightTarget;
        
        waitForStart();

The setTargetPosition();function takes in a integer (or int) data type as its parameter, rather than a double. Since both the leftTarget and rightTargetwill be used to set the target position, create both variables as int variables.

Converting from mm to Feet

Right now the main distance factor is COUNTS_PER_MM , however you may want to go a distance that is in the imperial system, such as 2 feet (or 24 inches). The target distance in this case will need to be converted to mm.

To convert from feet to millimeters use the following formula:

If you convert 2 feet to millimeters, it comes out the be 609.6 millimeters. For the purpose of this guide, lets go ahead an round this to be 610 millimeters.

Next, multiply 610 millimeters by the COUNTS_PER_MM variable to get the number of ticks needed to move the robot 2 feet. Since the intent is to have the robot move in a straight line, set both the leftTarget and rightTarget, to be equal to 610 * COUNTS_PER_MM

As previously mentioned the setTargetPosition(); function requires that its parameter must be an integer data type. The leftTargetand rightTargetvariables have been set to be integers, however theCOUNTS_PER_MM variable is a double. Since these are two different data types, a conversion of data types needs to be done.

In this case the COUNTS_PER_MM needs to be converted to an integer. This is as simple as adding the line (int) in front of the double variable. However, you need to be cautious of potential rounding errors. Since COUNTS_PER_MM is part of an equation it is recommended that you convert to an integer AFTER the result of the equation is found.

Lastly, edit the setTargetPosition(); lines so that both motors are set to the appropriate target position. To do this add the leftTarget and rightTarget variables to their respective motor:

Drivetrain Encoders - OnBot Java

Moving the motors to a specific position, using the encoders, removes any potential inaccuracies or inconsistencies from using Elapsed Time. The focus of this section is to move the robot to a target position using encoders.

The OpMode structure below is simplified and only includes the necessary components needed to create the encoder based code.

Before diving in too far, recall that for certain , like the , one of the motors needs to be reversed as the motors are mirrored.

In our example, we are addingrightmotor.setDirection(DcMotor.Direction.REVERSE); to the code as seen below:

As introduced in , using RUN_TO_POSITION mode requires a three step process.

The first step is setting target position. To do so, add the lines leftmotor.setTargetPosition(1000);

d(mm)=d(ft)×304.8d_{(mm)} = d_{(ft)} × 304.8d(mm)​=d(ft)​×304.8

Converting Feet to Ticks

int leftTarget = (int)(610 * COUNTS_PER_MM);
int rightTarget = (int)(610 * COUNTS_PER_MM);
leftmotor.setTargetPosition(leftTarget);
rightmotor.setTargetPosition(rightTarget);
and
rightmotor.setTargetPosition(1000);
to the OpMode after the
waitForStart();
command.

If we want our robot to travel a specific distance we will need to do a bit of math beforehand to calculate the TargetPosition. But for now let's start simple by setting the target position to 1000 ticks.

The next step is to set both motors to the RUN_TO_POSITIONmode. Add the lines leftmotor.setMode(DcMotor.RunMode.RUN_TO_POSITION);and rightmotor.setMode(DcMotor.RunMode.RUN_TO_POSITION);to your code, beneath the setTargetPosition code lines.

As mentioned, normally there would be more math involved to help determine how fast the motors should move to reach the desired position. But for testing purposes, we are going to start by keeping it simple! Since the setPower function was covered in and will communicate to the system what relative speed (or in this case duty cycle) is needed to get to the target, this can be used in the place of setVelocity for now.

Add the lines to set the power of both motors to 80% of duty cycle.

Build your OpMode and give it a test. What happens once you press play? What happens if you stop the program then start it again?

For our demo code we will want to request our motors reset their encoders during the initialization process of the program.

Right before waitForStart(); we can add leftmotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER); and rightmotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER); to our OpMode.

Let's say we want our program to run only for however long it takes for the motors to reach designated position. Or maybe we intend for the robot to do something else after reaching the destination. For this we will need to edit our whileLoop block!

To the whileLoop let's add the leftmotor.isBusy() and righmotor.isBusy()functions. This will check if the left motor and right motor are busy running to a target position. Once either motor reaches the target position the program will stop.

Build your OpMode and give it a try!

As soon as the motors hit the desired position the program will end instead of continuously run in the event they do not perfectly hit the position.

package org.firstinspires.ftc.teamcode;

import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.DcMotorSimple;

@Autonomous //sets the op mode as an autonomous op mode 

public class HelloRobot_Encoder extends LinearOpMode {
    private DcMotor leftmotor;
    private DcMotor rightmotor;
    
    @Override
    public void runOpMode() {
        leftmotor = hardwareMap.get(DcMotor.class, "leftmotor");
        rightmotor = hardwareMap.get(DcMotor.class, "rightmotor");
        
        // Wait for the game to start (driver presses PLAY)
        waitForStart();

        // run until the end of the match (driver presses STOP)
        while (opModeIsActive()){
        
        }
    }
}
public void runOpMode() {
        leftmotor = hardwareMap.get(DcMotor.class, "leftmotor");
        rightmotor = hardwareMap.get(DcMotor.class, "rightmotor");
        
        rightmotor.setDirection(DcMotor.Direction.REVERSE);
        
        waitForStart();

Setting up the Drivetrain Encoders

For this tutorial, our OpMode is named HelloRobot_Encoder!

RUN_TO_POSITION

drivetrains
Class Bot V2
Using Encoders

Order matters! The TargetPosition block must come before RUN_TO_POSITION mode is set or it will result in an error.

Quick Check!

What happens when testing?

Likely your motors turned on when testing out the code to spin until they've reached the set position.

Some may have turned off once the position was reached, but you may also experience the motors twitching or making small adjustments in an attempt to reach the position. Then when starting the code again, the motor either continued twitching or did not move at all.

Recall we may need to reset our encoder to zero before running a program! The motor will continuously try to adjust until it hits the set position, but if it's already there it won't move!

Adjusting the power may help prevent the motor from overshooting the position and needing to repeatedly adjust.

STOP_AND_RESET_ENCODERS

Setting up the whileLoop

Recall that, within a linear OpMode, a whileLoop must always have the opModeIsActive() Boolean as a condition. This condition ensures that the whileLoop will terminate when the stop button is pressed.

Right now the whileLoop is waiting for either motor to reach the target. There may be occasions when you want to wait for both motors to reach their target position. In this case the following loop can be used:

while (opModeIsActive() && (leftmotor.isBusy() || rightmotor.isBusy()))

previous sections
waitForStart();

leftmotor.setTargetPosition(1000);
rightmotor.setTargetPosition(1000);

while (opModeIsActive()){
        
        }
waitForStart();

leftmotor.setTargetPosition(1000);
rightmotor.setTargetPosition(1000);

leftmotor.setMode(DcMotor.RunMode.RUN_TO_POSITION);
rightmotor.setMode(DcMotor.RunMode.RUN_TO_POSITION);

while (opModeIsActive()){
        
        }
waitForStart();

leftmotor.setTargetPosition(1000);
rightmotor.setTargetPosition(1000);

leftmotor.setMode(DcMotor.RunMode.RUN_TO_POSITION);
rightmotor.setMode(DcMotor.RunMode.RUN_TO_POSITION);

leftmotor.setPower(0.8);
rightmotor.setPower(0.8);

while (opModeIsActive()){
        
        }
public void runOpMode() {
        leftmotor = hardwareMap.get(DcMotor.class, "leftmotor");
        rightmotor = hardwareMap.get(DcMotor.class, "rightmotor");
        
        rightmotor.setDirection(DcMotor.Direction.REVERSE);
        
        leftmotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
        rightmotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
        
        waitForStart();
while (opModeIsActive() && (leftmotor.isBusy() && rightmotor.isBusy())) {

}

Converting Encoder Ticks to a Distance

In the previous section, the basic structure needed to use RUN_TO_POSITIONwas created. The placement of leftmotor.setTargetPosition(1000); and rightmotor.setTargetPosition(1000); within the code, set the target position to 1000 ticks.

But how far is a tick and how can we use them to help our robot navigate an area? We could attempt to estimate the distance the robot moves per tick or we can convert the amount of ticks per revolution of the encoder into a unit like millimeters or inches! For instance, if you work through the conversion process and find out that a drivetrain takes 700 ticks to move an inch, this can be used to find the total number of ticks need to move the robot 24 inches.

Reminder that the basis for this guide is the . The REV DUO Build System is a metric system. Since part of the conversion process references the diameter of the wheels, this section will convert to ticks per mm.

What's Needed for the Conversion

This process will take a bit of math to achieve so let's break it down.

When using encoders built into motors, converting from ticks per revolution to ticks per unit of measure moved requires the following information:

The amount of ticks per revolution of the encoder shaft is dependent on the motor and encoder. Manufacturers of motors with built-in encoders will have information on the amount of ticks per revolution.

For HD Hex Motors the encoder counts 28 ticks per revolution of the motor shaft.

Since ticks per revolution of the encoder shaft is before any gear reduction calculating the total gear reduction is needed. This includes the gearbox and any addition reduction from motion transmission components. To find the total gear reduction use the .

For the Class Bot V2 there are two UltraPlanetary Cartridges, 4:1 and 5:1, and an additional gear reduction from the UltraPlanetary Output to the wheels, 72T:45T ratio.

Using the compound gearing formula for the Class Bot V2 the total gear reduction is:

The Class Bot V2 uses the 90mm Traction Wheels. 90mm is the diameter of the wheel. To get the appropriate circumference use the following formula

You can calculate this by hand, but for the purpose of this guide, this can be calculated within the code.

To summarize, for the Class Bot V2 the following information is true:

Each of these pieces of information will be used to find the number of encoder ticks (or counts) per mm that the wheel moves. Rather than worry about calculating this information by hand, these values can be added to the code as constant variables. To do this create three variables:

  • COUNTS_PER_MOTOR_REV

  • DRIVE_GEAR_REDUCTION

  • WHEEL_CIRCUMFERENCE_MM

We'll add the to the initialization section of the OpMode:

To ensure variables are referenceable they are set as static final double variables. Static allows references to the variables anywhere within the class. Final dictates that these variables are constant and unchanged elsewhere within the code.

Since these variables are not integers they are classified as double variables.

Now that these three variables have been defined, we can use them to calculate two other variables: the amount of encoder counts per rotation of the wheel and the number of counts per mm that the wheel moves.

To calculate counts per wheel revolution multiple COUNTS_PER_MOTOR_REV by DRIVE_GEAR_REDUCTION Use the following formula:

Where:

  • = COUNTS_PER_MOTOR_REV

  • = DRIVE_GEAR_REDUCTION

  • = COUNTS_PER_WHEEL_REV

Once COUNTS_PER_WHEEL_REV is calculated, use it to calculate the counts per mm that the wheel moves. To do this divide the COUNTS_PER_WHEEL_REV by the WHEEL_CIRCUMFERENCE_MM. Use the following formula.

Where,

  • = COUNTS_PER_MOTOR_REV

  • = DRIVE_GEAR_REDUCTION

  • = WHEEL_CIRCUMFERENCE_MM

= COUNTS_PER_WHEEL_REV

  • = COUNTS_PER_MM

  • 3.611∗5.231∗7245=30.21\frac{3.61}{1} * \frac{5.23}{1} * \frac{72}{45} = 30.2113.61​∗15.23​∗4572​=30.21
    circumference=diameter∗πcircumference = diameter * \pi circumference=diameter∗π

    Ticks per revolution

    28 ticks

    Total gear reduction

    30.21

    Circumference of the wheel

    public class HelloRobot_EncoderAuton extends LinearOpMode {
        private DcMotor leftmotor;
        private DcMotor rightmotor;
        
        static final double     COUNTS_PER_MOTOR_REV    = 28.0; 
        static final double     DRIVE_GEAR_REDUCTION    = 30.21;   
        static final double     WHEEL_CIRCUMFERENCE_MM  = 90.0 * Math.PI;
    public class HelloRobot_EncoderAuton extends LinearOpMode {
        private DcMotor leftmotor;
        private DcMotor rightmotor;
        
        static final double     COUNTS_PER_MOTOR_REV    = 28.0; 
        static final double     DRIVE_GEAR_REDUCTION    = 30.24;   
        static final double     WHEEL_CIRCUMFERENCE_MM  = 90.0 * 3.14;
        
        static final double     COUNTS_PER_WHEEL_REV    =
        static final double     COUNTS_PER_MM =
    y=a∗by = a *by=a∗b
    aa a
    bbb
    yyy
    public class HelloRobot_EncoderAuton extends LinearOpMode {
        private DcMotor leftmotor;
        private DcMotor rightmotor;
        
        static final double     COUNTS_PER_MOTOR_REV    = 28.0; 
        static final double     DRIVE_GEAR_REDUCTION    = 30.24;   
        static final double     WHEEL_CIRCUMFERENCE_MM  = 90.0 * 3.14;
        
        static final double     COUNTS_PER_WHEEL_REV    = COUNTS_PER_MOTOR_REV * DRIVE_GEAR_REDUCTION
        static final double     COUNTS_PER_MM = 
    x=(a∗b)c=ycx = \frac{(a*b)}{c} = \frac{y}{c}x=c(a∗b)​=cy​
    aa a
    bbb
    ccc
    public class HelloRobot_EncoderAuton extends LinearOpMode {
        private DcMotor leftmotor;
        private DcMotor rightmotor;
        
        static final double     COUNTS_PER_MOTOR_REV    = 28.0; 
        static final double     DRIVE_GEAR_REDUCTION    = 30.24;   
        static final double     WHEEL_CIRCUMFERENCE_MM  = 90.0 * 3.14;
        
        static final double     COUNTS_PER_WHEEL_REV    = COUNTS_PER_MOTOR_REV * DRIVE_GEAR_REDUCTION;
        static final double     COUNTS_PER_MM           = COUNTS_PER_WHEEL_REV / WHEEL_CIRCUMFERENCE_MM;
    package org.firstinspires.ftc.teamcode;
    
    import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
    import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
    import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
    import com.qualcomm.robotcore.eventloop.opmode.Disabled;
    import com.qualcomm.robotcore.hardware.DcMotor;
    import com.qualcomm.robotcore.hardware.DcMotorSimple;
    
    @Autonomous //sets the op mode as an autonomous op mode 
    
    public class HelloWorld_Encoder extends LinearOpMode {
        private DcMotor leftmotor;
        private DcMotor rightmotor;
        
        static final double     COUNTS_PER_MOTOR_REV    = 28.0; 
        static final double     DRIVE_GEAR_REDUCTION    = 30.24;   
        static final double     WHEEL_CIRCUMFERENCE_MM  = 90.0 * 3.14;
        
        static final double     COUNTS_PER_WHEEL_REV    = COUNTS_PER_MOTOR_REV * DRIVE_GEAR_REDUCTION;
        static final double     COUNTS_PER_MM           = COUNTS_PER_WHEEL_REV / WHEEL_CIRCUMFERENCE_MM;
       
         @Override
        public void runOpMode() {
            leftmotor = hardwareMap.get(DcMotor.class, "leftmotor");
            rightmotor = hardwareMap.get(DcMotor.class, "rightmotor");
            
            rightmotor.setDirection(DcMotor.Direction.REVERSE);
            
            leftmotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
            rightmotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
            
            // Wait for the game to start (driver presses PLAY)
            waitForStart();
            
            leftmotor.setTargetPosition(1000);
            rightmotor.setTargetPosition(1000);
            
            leftmotor.setMode(DcMotor.RunMode.RUN_TO_POSITION);
            rightmotor.setMode(DcMotor.RunMode.RUN_TO_POSITION);
            
            leftmotor.setPower(0.8);
            rightmotor.setPower(0.8);
    
            // run until the end of the match (driver presses STOP)
            while (opModeIsActive() && (leftmotor.isBusy() && rightmotor.isBusy())) {
    
    }
        }
    }

    Ticks per Revolution

    Visit the manufacturers website for your motor or encoders for more information on encoder counts. For HD Hex Motors or Core Hex Motors visit our documentation.

    Total Gear Reduction

    The UltraPlanetary Cartridges use the nominal gear ratio as a descriptor. The actual gear ratios can be found in the .

    Unlike the the spur gears used to transfer motion to the wheels, the UltraPlanetary Gearbox Cartridges are planetary gear systems. To make calculations easier the gear ratios for the Cartridges are already reduced.

    Circumference of the Wheel

    Due to wear and manufacturing tolerances, the diameter of some wheels may be nominally different. For the most accurate results consider measuring your wheel to confirm that the diameter is accurate.

    Translating the Conversion to Code

    Setting up Variables

    The common naming convention for constant variables is known as CONSTANT_CASE, where the variable name is in all caps and words are separated by and underscore.

    Calculating COUNTS_PER_WHEEL_REV

    Calculating COUNTS_PER_MM

    COUNTS_PER_WHEEL_REVwill be created as a separate variable fromCOUNTS_PER_MM as it is used in calculating a target velocity.

    Program thus far:

    Compound Gearing formula
    variables
    Class Bot V2
    yyy
    xxx
    90mm∗π90mm * \pi90mm∗π
    Motor
    UltraPlanetary Users Manual's Cartridge Details