This section describes the GyroDrive configuration and tuning practices so that the robot can travel in a straight line using the gyro.
This section contains:
After this step is completed, the robot can be successfully programmed for autonomous patterns.
Proportional, Integral, Differential control systems are used to control the output of a system, in our case a robot.
The GyroDrive example uses two types of PID controllers:
The TorontoCodingCollective does not recommend the use of derivative control since it is very susceptable to noise and difficult to tune, and is not required in the vast majority of cases. The SpeedPID and GyroPID classes are PI control classes and do not support differntial control.
The Shuffleboard dashboard takes more time to configure than the SmartDashboard, but the configuration of the dashboard can be saved. Unfortunately there are bugs in the SmartDashboard, and the save function does not work so you cannot properly save the layout.
It is highly recommended that teams use the Shuffleboard dashboard. TorontoCodingCollective provides a starter shuffleboard layout as part of the GyroDrive Project.
Use a radio connection or a USB cable to connect to the robot and start the DriverStation software
Ensure you are connected to the robot! When connected to the robot, the Communications light is green.
To start the shuffleboard dashboard, open the DriverStation software and Select Shuffleboard from the selection menu. This should open the Shuffleboard dashboard after the release in Jan, 2019. Currently it may not unless you have the 2018 developer tools installed.
Alternately download the 2018 Shuffleboard and Outline Viewer and unzip on the desktop. Double click the Shuffleboard.jar to start the Shuffleboard dashboard.
After connecting to the robot, and starting the shuffleboard dashboard, load the TorontoCodingCollective layout by opening the shuffleboard.json file that was downloaded with the GyroDrive project:
PID Controllers require that the motors and the encoders are moving in the same direction.
A PID Controller uses feedback from the sensors to control the motor speed. In order for the feedback to function correctly, the output from the PID must directly affect the output of the robot. When the controller senses that the wheel is spinning too slowly through the encoder feedback, it will try to increase the output to compensate for the slow wheel speed. The increase in output will ideally drive the robot faster, and the measured wheel speed will increase.
If the SpeedController output drives in the opposite direction to the robot, then the robot will run away because the desired wheel speed cannot be achieved
Did the encoders register a forward value?
If the encoders do not register in the forward direction:
If the motors do not move in the forward direction:
Why do I need this? The PID controller will translate the output from the joystick (0.0-1.0) into a rotational speed (0-330 in this case). In order to control the motors, the maximum rotation speed needs to be known... and at full output (1.0), the system must be able to attain the maximum speed (330). If the system cannot achieve the maximum speed, the controller will output full power, and the system will behave as if there is no PID control.
Run the robot on the ground at full speed and have a partner observe the max L and R encoder speeds under load. Ensure that the MAX_LOW_GEAR_SPEED is set to a value lower than the observed maximum loaded speed for both encoders.
Enable the loaded robot and test the the drive with the PIDs enabled. Adjust the gain of the PIDs in the dashboard as required. Enter any final adjusted values in the RobotConst.java file.
Once the speed PIDs are tuned, drive the loaded robot and measure the encoder counts/inch:
Rotate the robot by hand. Is the Gyro moving? Is the Gyro direction the same direction as the robot movement?
If the gyro is not reading in the same direction as the robot movement, then invert the gyro using the RobotMap.java GYRO_ISINVERTED flag and redeploy the code.
Set up the straight auto pattern distance in the AutoCommand.java to the distance that is available for the robot to drive SAFELY.
TUNING THE GYRO PID IS HAZARDOUS.
ENSURE THERE IS SUFFICIENT SPACE AND PEOPLE ARE CLEAR OF THE ROBOT.
Set the robot up in a space where there is sufficient room on either side for the robot to drive off course without hitting anything!!!
Be prepared to STOP the robot by pressing the space bar or enter key.
Repeat the above steps, increasing the gain until the robot is just unstable, and then select a value approximately 1/3 of the unstable value. The robot should not wiggle when it tracks the straight line. Adjust the Integral gain to approx 1/20 of the proportional gain and continue testing.
Once the robot is stable, run the straight line pattern and have someone push the back end of the robot from the side until it is out of alignment. The robot should auto-adjust to the straight line pattern. VERY COOL!
Remember to enter the final value in the RobotConst.java file DRIVE_GYRO_PID_KP.
Redeploy the code.
Enable the robot in Teleop and press any direction on the POV button on the controller.
The robot should rotate to that angle. Adjust the proportional gain if required.
Select the Auto Pattern -> box, and run the auto pattern. If the robot drives in a nice 3 ft box, you are ready to start developing a new auto pattern.