/*----------------------------------------------------------------------------*/
/* 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.XboxController;
import edu.wpi.first.wpilibj.GenericHID.Hand;
import com.ctre.phoenix.motorcontrol.can.*;
/**
* 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 XboxController xbox;
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() {
xbox = new XboxController(0); // Xbox controller on port 0
m_Left = new WPI_TalonSRX(4); // CAN Talon ID 4
}
/**
* 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.
*
* <p>This runs after the mode specific periodic functions, but before
* LiveWindow and SmartDashboard integrated updating.
*/
@Override
public void robotPeriodic() {
}
@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() {
// Read xbox controller left joystick Y axis
// value returned is between -1.0 and 1.0
// For xbox controller, uncomment the following line
// double x = xbox.getY(Hand.kLeft);
// For Logitech F310 controller, uncomment the following line
double x = -xbox.getRawAxis(1);
// DC Motor controllers apply between -1.0 (full reverse)
// 0=stop and +1.0 (full forward) power
// Set motor speed based on joystick
m_Left.set(x);
}
/**
* This function is called periodically during test mode.
*/
@Override
public void testPeriodic() {
}
}