added arm code. probably wont work

This commit is contained in:
Adam Long 2016-09-07 19:06:43 -04:00
parent 77ae642c9b
commit 1542373e40
13 changed files with 62 additions and 9 deletions

Binary file not shown.

Binary file not shown.

View File

@ -24,6 +24,7 @@ public class OI {
}
// Print log when button 1 pressed
joystickButtons[0][0].whenPressed(new LogEncoder());
// joystickButtons[1][0].whenPressed(new
}
public Joystick[] getJoysticks() {
return joysticks;

View File

@ -1,10 +1,10 @@
package org.usfirst.frc.team2059.robot;
public class RobotMap {
//Drive
public static int driveLeftMotorOne = 0;
public static int driveLeftMotorTwo = 1;
public static int driveRightMotorOne = 2;
public static int driveRightMotorTwo = 3;
public static int driveLeftMotorOne = 1;
public static int driveLeftMotorTwo = 2;
public static int driveRightMotorOne = 3;
public static int driveRightMotorTwo = 4;
public static int driveRightEncoder = 0;
public static int driveLeftEncoder = 1;
//Arm

View File

@ -1,13 +1,16 @@
package org.usfirst.frc.team2059.robot.commands;
import org.usfirst.frc.team2059.robot.subsystems.DriveBase;
import org.usfirst.frc.team2059.robot.subsystems.EncoderBase;
import org.usfirst.frc.team2059.robot.subsystems.MainArm;
import edu.wpi.first.wpilibj.command.Command;
public abstract class CommandBase extends Command {
protected static EncoderBase encoderBase;
protected static DriveBase driveBase;
protected static MainArm mainArm;
public static void init() {
encoderBase = new EncoderBase();
driveBase = new DriveBase();
mainArm = new MainArm();
}
}
// vim: sw=2:ts=2:sts=2

View File

@ -0,0 +1,32 @@
package org.usfirst.frc.team2059.robot.commands;
import org.usfirst.frc.team2059.robot.commands.CommandBase;
import org.usfirst.frc.team2059.robot.Robot;
/**
*
*/
public class MoveArm extends CommandBase {
double speed;
public MoveArm(double s) {
requires(mainArm);
speed=s;
}
// Called just before this Command runs the first time
protected void initialize() {
}
// Called repeatedly when this Command is scheduled to run
protected void execute() {
mainArm.moveArm(speed);
}
// Make this return true when this Command no longer needs to run execute()
protected boolean isFinished() {
return true;
}
// Called once after isFinished returns true
protected void end() {
}
// Called when another command which requires one or more of the same
// subsystems is scheduled to run
protected void interrupted() {
}
}
// vim: sw=2:ts=2:sts=2

View File

@ -2,12 +2,12 @@ package org.usfirst.frc.team2059.robot.subsystems;
import org.usfirst.frc.team2059.robot.RobotMap;
import org.usfirst.frc.team2059.robot.commands.Drive;
import edu.wpi.first.wpilibj.command.Subsystem;
import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.CANTalon;
public class DriveBase extends Subsystem {
Talon leftMotorOne = new Talon(RobotMap.driveLeftMotorOne);
Talon leftMotorTwo = new Talon(RobotMap.driveLeftMotorTwo);
Talon rightMotorOne = new Talon(RobotMap.driveRightMotorOne);
Talon rightMotorTwo = new Talon(RobotMap.driveRightMotorTwo);
CANTalon leftMotorOne = new CANTalon(RobotMap.driveLeftMotorOne);
CANTalon leftMotorTwo = new CANTalon(RobotMap.driveLeftMotorTwo);
CANTalon rightMotorOne = new CANTalon(RobotMap.driveRightMotorOne);
CANTalon rightMotorTwo = new CANTalon(RobotMap.driveRightMotorTwo);
public void initDefaultCommand() {
setDefaultCommand(new Drive());
}

View File

@ -0,0 +1,17 @@
package org.usfirst.frc.team2059.robot.subsystems;
import org.usfirst.frc.team2059.robot.RobotMap;
import org.usfirst.frc.team2059.robot.commands.Drive;
import edu.wpi.first.wpilibj.command.Subsystem;
import edu.wpi.first.wpilibj.CANTalon;
public class MainArm extends Subsystem {
CANTalon armMotorLeft = new CANTalon(RobotMap.armLeftMotor);
CANTalon armMotorRight = new CANTalon(RobotMap.armRightMotor);
public void initDefaultCommand() {
setDefaultCommand(new Drive());
}
public void moveArm(double speed){
armMotorLeft.set(speed);
armMotorRight.set(-speed);
}
}
// vim: sw=2:ts=2:sts=2