Review theDocumentations:
Expansion Hub with Android Device Robot Controller - DUO Control System (revrobotics.com)
Keep this diagram handy:
Wiring Diagram - DUO Control System (revrobotics.com)
- Programming
The FTC Robot controller library includes all the basic Java sample codes for the game.
Programming the basic robot components.
Watch the video Tutorials(one at a time). Follow the steps to create your own java program. The file name convention :
yourunique-prefix+originalfilename.Java.
For the FTC library name convention, please review this link.
2. Understand the code ( you might do 2,3,4 together)
A. Carefully Read instructional comments.
B. Understand the structure / components of the java program.
C. Make sure the names of the robot parts in the sample code are the same as the names in the controller. If not change your
code or change the configuration on the controller. ( be sure to create and save your robot configuration not to overwrite other’s configuration file)
Autonomous programming
- Use color sensors
- Use IMU
The REV Expansion Hub has a built-in IMU, or Inertial Measurement Unit. This is a sensor that can measure acceleration (movement) in several axes.
https://docs.revrobotics.com/duo-control/sensors/i2c/imu#how-to-use
http://192.168.43.1:8080
in a web browser on a laptop connected to the Control Hub's Wi-Fi network.IMU
interface for Blocks and Java programming, which supports both the BNO055 IMU and the BHI260AP IMU. The BNO055 IMU can also be used from the legacy BNO055IMU
interface.IMU
interface added in version 8.1 of the FTC Robot Controller app provides robot-centric orientation and angular velocity values. You can specify the exact orientation of the Control or Expansion Hub on your robot, and the interface will convert the raw values from the IMU into robot-centric values. This simplifies how you use the IMU's values, and prevents problems when the hub is not mounted with the REV Robotics logo facing upwards.IMU
interface are in the Robot Coordinate System, in which the origin is inside your robot, the Z axis points towards the ceiling, the Y axis points straight ahead through the front of your robot (whatever you define the front to be), and the X axis points out the right side of your robot. This coordinate system is right-handed, which means that if you point a typical right thumb in the same direction as the axis, rotation in the same direction that the fingers curl is considered positive.IMU.getRobotYawPItchRollAngles()
method on the IMU
interface provides the robot's orientation in a simplified format of yaw, pitch, and roll angles. Most teams should use this method to get the robot's orientation.- Yaw (also known as heading) is the measure of rotation along the robot's Z axis, or the side-to-side lateral rotation of the robot.
- Pitch is the measure of rotation along the robot's X axis, or the front-to-back rotation of the robot.
- Roll is the measure along the robot's Y axis, or the side-to-side tilt of the robot.
Yaw, Pitch and Roll of the robot
It can be used in place of an external gyro. The IMU is not used in quite the same way as the gyro but is similar. Note: you must configure the IMU on I2C channel 0, port 0. Here is the DriveAvoid example converted to use the IMU in place of the MR gyro.
- Use encoder:
- Set a target position (in ticks)
- Switch to RUN_TO_POSITION mode
- Set the maximum velocity// Set the motor's target position to 300 ticksmotor.setTargetPosition(300);// Switch to RUN_TO_POSITION modemotor.setMode(DcMotor.RunMode.RUN_TO_POSITION);// Start the motor moving by setting the max velocity to 200 ticks per secondmotor.setVelocity(200)
Basics of Programming with Encoders
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 Mode
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.