Hi Everyone,
if someone has time can you please take a look at our code. When we compile this the driver station shows no robot code. Currently we are only trying to use the drivetrain41 and the shootermotors. The other code is written so that we can test those items when they are ready. Do I need to comment them out when they are not connected? For example the servos are not plugged into the rio yet will that cause a problem?
Thank you very much
package org.usfirst.frc.team5676.robot;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.buttons.*;
import edu.wpi.first.wpilibj.Servo;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.DoubleSolenoid;
/**
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the IterativeRobot
* documentation. If you change the name of this class or the package after
* creating this project, you must also update the manifest file in the resource
* directory.
*/
public class Robot extends IterativeRobot {
RobotDrive DriveTrain41;
RobotDrive shootermotors;
Servo launchleft;
Servo launchright;
DoubleSolenoid pickerpiston;
DoubleSolenoid armpiston;
Joystick xboxcontroller;
JoystickButton abutton;
JoystickButton bbutton;
JoystickButton xbutton;
JoystickButton ybutton;
JoystickButton leftbumper;
JoystickButton rightbumper;
JoystickButton lefttrigger;
JoystickButton righttrigger;
int autoloopcounter;
/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
public void robotInit() {
DriveTrain41 = new RobotDrive(0,1,2,3);
shootermotors = new RobotDrive(4,5);
launchleft = new Servo(6);
launchright = new Servo(7);
xboxcontroller = new Joystick(0);
pickerpiston = new DoubleSolenoid(0,1);
armpiston = new DoubleSolenoid(2,3);
righttrigger = new JoystickButton(xboxcontroller,2);
lefttrigger = new JoystickButton(xboxcontroller,3);
abutton = new JoystickButton(xboxcontroller,6);
bbutton = new JoystickButton(xboxcontroller,7);
xbutton = new JoystickButton(xboxcontroller,8);
ybutton = new JoystickButton(xboxcontroller,9);
leftbumper = new JoystickButton(xboxcontroller,10);
rightbumper = new JoystickButton(xboxcontroller,11);
DriveTrain41.setInvertedMotor(RobotDrive.MotorType.kFrontRight, true);
DriveTrain41.setInvertedMotor(RobotDrive.MotorType.kRearRight, true);
DriveTrain41.setInvertedMotor(RobotDrive.MotorType.kFrontLeft, true);
DriveTrain41.setInvertedMotor(RobotDrive.MotorType.kRearLeft, true);
shootermotors.setInvertedMotor(RobotDrive.MotorType.kFrontRight, true);
}
/**
* This autonomous (along with the chooser code above) shows how to select between different autonomous modes
* using the dashboard. The sendable chooser code works with the Java SmartDashboard. If you prefer the LabVIEW
* Dashboard, remove all of the chooser code and uncomment the getString line to get the auto name from the text box
* below the Gyro
*
* You can add additional auto modes by adding additional comparisons to the switch structure below with additional strings.
* If using the SendableChooser make sure to add them to the chooser code above as well.
*/
public void autonomousPeriodic() {
if(autoloopcounter < 100) //Check if we've completed 100 loops (approximately 2 seconds)
{
DriveTrain41.drive(-0.5, 0.0); // drive forwards half speed
autoloopcounter++;
} else {
DriveTrain41.drive(0.0, 0.0); // stop robot
}
}
/**
* This function is called once each time the robot enters tele-operated mode
*/
public void teleopInit() {
}
/**
* This function is called periodically during operator control
*/
public void teleopPeriodic() {
DriveTrain41.arcadeDrive(xboxcontroller);
/**
* This will turn the shooter motors on and off
*/
if (xboxcontroller.getRawButton(8)) {
shootermotors.drive(1,0);}
else if (xboxcontroller.getRawButton(9)){
shootermotors.drive(0,0);}
/**
* This will control the left servo on the robot
*/
if (xboxcontroller.getRawButton(11)) {
launchleft.set(1.0);}
else if (xboxcontroller.getRawButton(2)){
launchleft.set(0.0);}
/**
* This will control the right servo on the robot
*/
if (xboxcontroller.getRawButton(10)) {
launchright.set(1.0);}
else if (xboxcontroller.getRawButton(3)){
launchright.set(0.0);}
/**
* This will control the piston on the ramp to pick up the ball
*/
if (xboxcontroller.getRawButton(6)) {
pickerpiston.set(DoubleSolenoid.Value.kForward);}
else if (xboxcontroller.getRawButton(7)) {
pickerpiston.set(DoubleSolenoid.Value.kReverse);}
else {pickerpiston.set(DoubleSolenoid.Value.kOff);}
if (xboxcontroller.getRawButton(12)) {
armpiston.set(DoubleSolenoid.Value.kForward);}
else if (xboxcontroller.getRawButton(13)) {
armpiston.set(DoubleSolenoid.Value.kReverse);}
else {armpiston.set(DoubleSolenoid.Value.kOff);}
}
}