Changes between Initial Version and Version 1 of ControlSystems/SoftwareTeam/Training/GettingStarted/Encoders/CANCode


Ignore:
Timestamp:
Nov 8, 2019, 11:20:11 PM (6 years ago)
Author:
David Albert
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ControlSystems/SoftwareTeam/Training/GettingStarted/Encoders/CANCode

    v1 v1  
     1{{{
     2/*----------------------------------------------------------------------------*/
     3/* Copyright (c) 2017-2018 FIRST. All Rights Reserved.                        */
     4/* Open Source Software - may be modified and shared by FRC teams. The code   */
     5/* must be accompanied by the FIRST BSD license file in the root directory of */
     6/* the project.                                                               */
     7/*----------------------------------------------------------------------------*/
     8
     9package frc.robot;
     10
     11import edu.wpi.first.wpilibj.TimedRobot;
     12import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
     13import com.ctre.phoenix.motorcontrol.can.*;
     14import com.ctre.phoenix.motorcontrol.FeedbackDevice;
     15
     16/**
     17 * The VM is configured to automatically run this class, and to call the
     18 * functions corresponding to each mode, as described in the TimedRobot
     19 * documentation. If you change the name of this class or the package after
     20 * creating this project, you must also update the build.gradle file in the
     21 * project.
     22 */
     23public class Robot extends TimedRobot {
     24  private WPI_TalonSRX m_Left;
     25
     26  /**
     27   * This function is run when the robot is first started up and should be
     28   * used for any initialization code.
     29   */
     30  @Override
     31  public void robotInit() {
     32      // TalonSRX is configured with CAN bus address 3
     33    m_Left = new WPI_TalonSRX(3);
     34    // Clear any non default configuration/settings
     35    m_Left.configFactoryDefault();
     36    // A quadrature encoder is connected to the TalonSRX
     37    m_Left.configSelectedFeedbackSensor(FeedbackDevice.QuadEncoder);
     38  }
     39
     40  /**
     41   * This function is called every robot packet, no matter the mode. Use
     42   * this for items like diagnostics that you want ran during disabled,
     43   * autonomous, teleoperated and test.
     44   *
     45   * <p>This runs after the mode specific periodic functions, but before
     46   * LiveWindow and SmartDashboard integrated updating.
     47   */
     48  @Override
     49  public void robotPeriodic() {
     50    SmartDashboard.putNumber("Encoder value", m_Left.getSelectedSensorPosition());
     51  }
     52
     53  @Override
     54  public void autonomousInit() {
     55  }
     56
     57  /**
     58   * This function is called periodically during autonomous.
     59   */
     60  @Override
     61  public void autonomousPeriodic() {
     62  }
     63
     64  /**
     65   * This function is called periodically during operator control.
     66   */
     67  @Override
     68  public void teleopPeriodic() {
     69  }
     70
     71  /**
     72   * This function is called periodically during test mode.
     73   */
     74  @Override
     75  public void testPeriodic() {
     76  }
     77}
     78}}}