Wednesday, December 7, 2022

Programming Autonomous - OnBot Java

Each motor designed by REV has an encoder built into it that keeps 
track of its rotation. you can direct the Control Hub to use the encoder values to 
maintain a motor’s speed, or maintain a particular position.

You do this by changing the motor’s mode.

STOP_AND_RESET_ENCODER Mode
Place a motor in this mode when you want to set its encoder position back to 0. The motor will stop. To start it again, you need to place the motor into one of the other three modes. It is recommended to place each motor you will be using encoders with into this mode at the start of each program, so that you know what position the motor is starting out in.

RUN_WITHOUT_ENCODER Modes Use this mode when you don’t want the Control Hub to attempt to use the encoders to maintain a constant speed. You can still access the encoder values, but your actual motor speed will vary more based on external factors such as battery life and friction. In this mode, you provide a power level in the -1 to 1 range, where -1 is full speed backwards, 0 is stopped, and 1 is full speed forwards. Reducing the power reduces both torque and speed. This mode is a good choice for drivetrain motors driven by joysticks on the gamepad.

RUN_USING_ENCODER Mode In this mode, the Control Hub will use the encoder to take an active role in managing the motor’s speed. Rather than directly applying a percentage of the available power, RUN_USING_ENCODER mode targets a specific velocity (speed). This allows the motor to account for friction, battery voltage, and other factors.

This mode is a good choice for operations, like a flywheel, that require a specific speed and can use buttons on a gamepad for control.

RUN_TO_POSITION Mode In this mode, the Control Hub will target a specific position, rather than a specific velocity. You still set a velocity, but it is only used as the maximum velocity. The motor will continue to hold its position even after it has reached its target.

This mode is a good choice for operations, like an arm, that require a specific position and can use buttons on a gamepad for control.

Encoder Navigation - OnBot


No comments:

Post a Comment

We are the Winner at the regional tournament !

  https://youtu.be/mseGfEwSrX4