Changes between Version 13 and Version 14 of ControlSystems/SoftwareTeam/Training/GettingStarted/IntroRobotJava
- Timestamp:
- Oct 15, 2019, 7:51:33 PM (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ControlSystems/SoftwareTeam/Training/GettingStarted/IntroRobotJava
v13 v14 131 131 m_rearLeft = new WPI_TalonSRX(4); // CAN Talon ID 4 132 132 }}} 133 * in teleopPeriodic() read the xbox controller and adjust the servomotor accordingly133 * in teleopPeriodic() read the xbox controller and adjust the DC motor accordingly 134 134 {{{ 135 // Read xbox controller left joystick x axis 136 // value returned is between -1.0 and 1.0 137 double x = xbox.getX(Hand.kLeft); 138 // Servo motors are controlled on a scale of 0.0 to 1.0 139 // so re-scale the X value to that range (-1.0->0, 0->0.5, 1.0->1.0) 140 x = (x + 1.0) / 2; 141 // Set motor speed based on joystick 142 m_rearLeft.set(x); 135 // Read xbox controller left joystick x axis 136 // value returned is between -1.0 and 1.0 137 double x = xbox.getX(Hand.kLeft); 138 // DC Motor controllers apply between -1.0 (full reverse) 139 // 0=stop and +1.0 (full forward) power 140 // Set motor speed based on joystick 141 m_rearLeft.set(x); 143 142 }}} 144 143 145 You'll need to press the Enable button on the driver station to put the robot in Teleop mode so that teleopPeriodic() is called repeatedly.144 Note: you'll need to press the Enable button on the driver station to put the robot in Teleop mode so that teleopPeriodic() is called repeatedly. 146 145 147 146