Sorry, don't know why I didn't.
Spoiler for isthisatitle?:
Code:
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. 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 edu.wpi.first.wpilibj.templates;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.Watchdog;
import edu.wpi.first.wpilibj.AnalogChannel;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
/**
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the SimpleRobot
* 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 team4692robot extends SimpleRobot
{
RobotDrive drive=new RobotDrive(2, 1);
Joystick left=new Joystick(1);
Joystick right=new Joystick(2);
Compressor airCompressor=new Compressor(1, 1);
Solenoid launchopen=new Solenoid(1);
Solenoid launchclose=new Solenoid(2);
Joystick gamepad=new Joystick(3);
Talon winch=new Talon(3);
Talon ballpickup=new Talon(4);
DigitalInput winchstopper=new DigitalInput(2);
DigitalInput winchstarter=new DigitalInput(3);
AnalogChannel distance=new AnalogChannel(1);
Solenoid extendor1open=new Solenoid(3);
Solenoid extendor1close=new Solenoid(4);
Solenoid extendor2open=new Solenoid(5);
Solenoid extendor2close=new Solenoid(6);
DigitalInput pistonstopper=new DigitalInput(4);
/**
* This function is called once each time the robot enters autonomous mode.
*/
public void autonomous()
{
int autotimer=0; int pistontimer=0;
airCompressor.start();
while(true && isAutonomous() && isEnabled())
{
dashboard();
if(distance.getAverageVoltage()/.0098>144 && autotimer==0)
{
drive.tankDrive(-.5, -.5);
}
else if(autotimer==0)
{
drive.tankDrive(0, 0);
launchopen.set(true);
launchclose.set(false);
autotimer++;
}
else if(autotimer>0 && autotimer<200)
{
autotimer++;
}
else if(autotimer==200 && pistontimer==2000)
{
launchopen.set(false);
launchclose.set(true);
autotimer++; pistontimer++;
}
if(pistontimer<1000)
{
extendor1open.set(true);
extendor1close.set(false);
pistontimer++;
}
else if(pistontimer<2000)
{
extendor2open.set(true);
extendor2close.set(false);
pistontimer++;
}
Timer.delay(.005);
}
}
/**
* This function is called once each time the robot enters operator control.
*/
public void operatorControl()
{
boolean winching=false;
int launchtimer=0; int reversewincher=0;
airCompressor.start();
while(true && isOperatorControl() && isEnabled())
{
double leftpow=left.getY(); double rightpow=right.getY();
double powermod=.3;
if(left.getTrigger())
{
powermod+=.2;
}
if(right.getTrigger())
{
powermod+=.5;
}
leftpow*=powermod; rightpow*=powermod;
drive.tankDrive(leftpow, rightpow);
if(gamepad.getRawButton(1) && winching==false && winchstarter.get())
{
winching=true;
reversewincher=0;
}
else if(winching==true)
{
winch.set(1);
if(winchstopper.get())
{
winching=false;
winch.set(-.5);
reversewincher=50;
}
}
if(reversewincher>0)
{
winch.set(-.5);
reversewincher--;
}
else if(winching==false)
{
winch.set(0);
}
if(gamepad.getRawButton(2) && launchtimer==0 && winching==false)
{
launchopen.set(true);
launchclose.set(false);
launchtimer=200;
}
if(launchtimer>1)
{
launchtimer--;
}
else
{
launchopen.set(false);
launchclose.set(true);
}
if(launchtimer==1 && !gamepad.getRawButton(2))
{
launchtimer--;
}
if(gamepad.getRawButton(5))
{
extendor1open.set(false);
extendor1close.set(true);
}
if(gamepad.getRawAxis(3)>0)
{
extendor1open.set(true);
extendor1close.set(false);
}
if(gamepad.getRawButton(6))
{
extendor2open.set(false);
extendor2close.set(true);
}
if(gamepad.getRawAxis(3)<0)
{
extendor2open.set(true);
extendor2close.set(false);
}
if(left.getRawButton(2))
{
ballpickup.set(-1);
}
if(right.getRawButton(2))
{
ballpickup.set(1);
}
if(!right.getRawButton(2) && !left.getRawButton(2))
{
ballpickup.set(0);
}
dashboard();
Timer.delay(.005);
}
}
/**
* This function is called once each time the robot enters test mode.
*/
public void test()
{
}
public void robotInit()
{
drive.setSafetyEnabled(false);
Watchdog.getInstance().kill();
}
public void dashboard()
{
SmartDashboard.putNumber("VOLTER", distance.getAverageVoltage()/.0098);
SmartDashboard.putBoolean("SHOOTERFAR", distance.getAverageVoltage()/.0098>52);
SmartDashboard.putBoolean("SHOOTERNEAR", distance.getAverageVoltage()/.0098<44);
}
}
/*
double left=y; double right=y;
if(x>0)
{
left+=x;
}
if(x<0)
{
right+=x;
}
drive.tankDrive(left, right);
*/
This code is working, but we want to move the buttons to run it from joysticks to the gamepad:
Code:
if(left.getRawButton(2))
{
ballpickup.set(-1);
}
if(right.getRawButton(2))
{
ballpickup.set(1);
}
Tried gamepad.getRawbutton(3), and gampepad.getRawButton(4), also tried left.getRawButton(3) and left.getRawButton(4), along with just setting ballpickup to one outside of that code, and setting it to gamepad.getRawAxis(1)... ...none of that could get more than jerky movements, rapidly turning on and off.