Steps to Configuring the GyroDrive
Step 1: Configure the Robot Map - identify the port numbers or CAN address of the speed controllers and sensors
Step 2: Configure the Drive Subsystem - initialize the Speed Controllers, Encoders, Gyro, and Pneumatics used in the GyroDrive
Step 1: Configure the RobotMap for your robot
The RobotMap.java class is used to identify the ports where the Speed Controllers and Sensors are plugged into the RoboRio. Speed Controllers and sensors can be connected directly to the ports on the RoboRio or can be connected on the CAN bus interface.
Encoders and Limit switches can also be connected to a TalonSRX Speed Controller on the CAN bus.
The GyroDrive robot Framework uses two motors on the left/right differential drive and a gyro and a shifter pneumatic
Open the RobotMap.java class to configure the addresses of your devices.
Set the ports associated with the left/right speed controllers, and the types of the speed controllers. The framework has two examples, one where the speed controllers are attached to the CAN bus and in the other, they are attached to the PWM ports on the RoboRio. They are both functionally equivalent. A CAN configuration will allow an encoder to be plugged into the TalonSRX.
It is not necessary that the speed controllers are of the same type. This allows a VictorSPX to be used as a follower to a TalonSRX. The only constraint is that the framework assumes that both motors are on the same interface, CAN or PWM . In the example the motors are moving in the same direction in a primary/follower configuration.
- set the ports and types for the left and right drive.
NOTE: If using CAN addressed speed controllers, the configuration can be determined using the RoboRio dashboard. See NI Tools and Driver Station
Set the ports associated with the left/right speed encoders. If the encoders are connected to the TalonSRX devices, then the port number of the encoder is not required since it is known from the address of the SpeedController.
Connecting Encoders to the CAN TalonSRX
Depending on the encoder used, many different configurations are available for connecting a Quadrature encoder to the TalonSRX. One useful component is the TalonSRX Universal Breakout Board available at AndyMark. This allows a 5 pin quad encoder like the GreyHill 61R256 to be connected directly to a TalonSRX.
The example robot framework uses a pneumatic shifter. Configure the port that is used in the shifter. If not required, the pneumatic shifter can be removed from the chosen DriveSubsystem.
Step 2: Configure the DriveSubsystem
Choose a DriveSubsystem
The Drive Subsystem in the Gyro Drive framework defines how the Speed Controllers, Encoders, and Gyro are connected for a Gyro Drive. There are two options:
- CanDriveSubsystem - speed controllers are connected through the CAN bus and Encoders are connected either through the CAN bus or through the DIO (Digital I/O) ports on the RoboRio.
- PwmDriveSubsystem - speed controllers are connected through PWM ports on the RoboRio and Encoders are connected to DIO ports on the RoboRio.
Choose your type of DriveSubsystem in the Robot.java class
Examples of the Drive Subsystem
The example CanDriveSubsystem and PwmDrive Subsytem code shows how to declare the speed controllers and encoders and Gyro for the DriveSubsystem.