Changes between Version 14 and Version 15 of ControlSystems/SoftwareTeam/Training/GettingStarted/IntroRobotJava


Ignore:
Timestamp:
Oct 15, 2019, 10:33:18 PM (6 years ago)
Author:
Danko Nebesh
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ControlSystems/SoftwareTeam/Training/GettingStarted/IntroRobotJava

    v14 v15  
    144144Note: 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.
    145145
     146== Fifth program: Encoder
     147Create another program using the !TimedRobot java template and name it !EncoderTest. Modify the generated code as follows:
     148
     149* Add the following imports:
     150{{{
     151import edu.wpi.first.wpilibj.Encoder;
     152}}}
     153*  Declare a variable for the Encoder in the Robot class
     154{{{
     155  private Encoder leftEncoder;
     156}}}
     157* •     In robotInit() instantiate the Encoder object and reset it
     158  {{{
     159    leftEncoder = new Encoder(0, 1);
     160    leftEncoder.reset();
     161  }}}
     162* In robotPeriodic() read and display the encoder valuey
     163  {{{
     164    int encoderValue = leftEncoder.getRaw();
     165    SmartDashboard.putNumber("Encoder Value", encoderValue);
     166  }}}
    146167 
     168Note: you'll need to manually turn the left wheel forward and backward to see the Encoder values change. Try turning the wheel 360 degrees to see what value is equivalent to a full revolution of the wheel.
     169
     170
    147171== Study some examples
    148172Learn more about robot programming by studying some simple example programs.  Run them, study what they do, and incrementally expand their functionality.  The WPILib software you installed includes example programs that you can compile and run on a RoboRIO.  Review [https://wpilib.screenstepslive.com/s/currentCS/m/79833/l/941601-vs-code-basics-and-wpilib-in-vs-code how to use VSCode] and then try [https://wpilib.screenstepslive.com/s/currentCS/m/79833/l/932465-creating-a-new-wpilib-project-in-vs-code creating a new robot project].