Changes between Version 20 and Version 21 of ControlSystems/SoftwareTeam/Training/GettingStarted/IntroRobotJava
- Timestamp:
- Oct 28, 2019, 10:58:21 PM (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ControlSystems/SoftwareTeam/Training/GettingStarted/IntroRobotJava
v20 v21 34 34 * In the Robot class definition where variables are defined, add {{{ XboxController xbox; }}} 35 35 * In the function robotInit() add: {{{ xbox = new XboxController(0); }}} 36 * In the function robotPeriodic() add d: {{{ SmartDashboard.putNumber("Left Joystick X", xbox.getX(Hand.kLeft)); }}}36 * In the function robotPeriodic() add: {{{ SmartDashboard.putNumber("Left Joystick X", xbox.getX(Hand.kLeft)); }}} 37 37 38 38 Your program should look like [wiki://ControlSystems/SoftwareTeam/Training/IntroRobotJava/XboxExample this] … … 173 173 * • In robotInit() instantiate the Encoder object and reset it 174 174 {{{ 175 // Quadrature encoder has A and B channels connected to DIO0, DIO1 175 176 leftEncoder = new Encoder(0, 1); 177 // Peanut wheels are 7.5" in diameter 178 // Encoders provide 1 count per degree of rotation 179 leftEncoder.setDistancePerPulse((3.141592*7.5)/360); 180 // reset encoder counts to 0 176 181 leftEncoder.reset(); 177 182 }}} … … 179 184 {{{ 180 185 int encoderValue = leftEncoder.getRaw(); 186 double distance = leftEncoder.getDistance(); 181 187 SmartDashboard.putNumber("Encoder Value", encoderValue); 188 SmartDashboard.putNumber("Encoder Distance", distance); 182 189 }}} 183 190