{{{ /*----------------------------------------------------------------------------*/ /* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ /*----------------------------------------------------------------------------*/ package frc.robot; import edu.wpi.first.wpilibj.TimedRobot; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import com.ctre.phoenix.motorcontrol.can.*; import com.ctre.phoenix.motorcontrol.FeedbackDevice; /** * The VM is configured to automatically run this class, and to call the * functions corresponding to each mode, as described in the TimedRobot * documentation. If you change the name of this class or the package after * creating this project, you must also update the build.gradle file in the * project. */ public class Robot extends TimedRobot { private WPI_TalonSRX m_Left; /** * This function is run when the robot is first started up and should be * used for any initialization code. */ @Override public void robotInit() { // TalonSRX is configured with CAN bus address 3 m_Left = new WPI_TalonSRX(3); // Clear any non default configuration/settings m_Left.configFactoryDefault(); // A quadrature encoder is connected to the TalonSRX m_Left.configSelectedFeedbackSensor(FeedbackDevice.QuadEncoder); // Reset encoder count to 0 m_Left.setSelectedSensorPosition(0); } /** * This function is called every robot packet, no matter the mode. Use * this for items like diagnostics that you want ran during disabled, * autonomous, teleoperated and test. * *

This runs after the mode specific periodic functions, but before * LiveWindow and SmartDashboard integrated updating. */ @Override public void robotPeriodic() { SmartDashboard.putNumber("Encoder value", m_Left.getSelectedSensorPosition()); } @Override public void autonomousInit() { } /** * This function is called periodically during autonomous. */ @Override public void autonomousPeriodic() { } /** * This function is called periodically during operator control. */ @Override public void teleopPeriodic() { } /** * This function is called periodically during test mode. */ @Override public void testPeriodic() { } } }}}