Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field element test #3

Open
wants to merge 5 commits into
base: two-motor-solenoid
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions src/main/java/org/usfirst/frc4904/robot/RobotMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ public static class HumanInput {
}

public static class CANMotor {
public static int RIGHT_DRIVE_A = 2;
public static int RIGHT_DRIVE_B = 3;
public static int RIGHT_DRIVE_A = 3;
public static int LEFT_DRIVE_A = 4;
public static int LEFT_DRIVE_B = 5;
public static int EXTRA_MOTOR = -1; // TODO: set port
}

public static class PWM {
Expand Down Expand Up @@ -87,12 +86,11 @@ public static class Component {
public static EncoderPair chassisTalonEncoders;
public static EncoderPair chassisCANCoders;
public static Motor rightWheelA;
public static Motor rightWheelB;
public static Motor leftWheelA;
public static Motor leftWheelB;
public static SolenoidSubsystem solenoid;
public static TankDrive chassis;
public static CustomPIDController drivePID;
public static Motor extraMotor;
}

public static class Input {
Expand Down Expand Up @@ -120,12 +118,11 @@ public RobotMap() {

// Wheels
CANTalonFX leftWheelATalon = new CANTalonFX(Port.CANMotor.LEFT_DRIVE_A);
CANTalonFX rightWheelATalon = new CANTalonFX(Port.CANMotor.RIGHT_DRIVE_B);
CANTalonFX rightWheelATalon = new CANTalonFX(Port.CANMotor.RIGHT_DRIVE_A);

Component.rightWheelA = new Motor("rightWheelA", false, rightWheelATalon);
Component.rightWheelB = new Motor("rightWheelB", false, new CANTalonFX(Port.CANMotor.RIGHT_DRIVE_B));
Component.leftWheelA = new Motor("leftWheelA", true, leftWheelATalon);
Component.leftWheelB = new Motor("leftWheelB", true, new CANTalonFX(Port.CANMotor.LEFT_DRIVE_B));
Component.extraMotor = new Motor("extraMotor", false, new CANTalonFX(Port.CANMotor.EXTRA_MOTOR));

// Wheel Encoders
Component.leftWheelTalonEncoder = new CANTalonEncoder("Leftwheel", leftWheelATalon, true,
Expand All @@ -147,8 +144,8 @@ public RobotMap() {
Component.solenoid = new SolenoidSubsystem(Port.Pneumatics.SOLENOID.buildDoubleSolenoid());

// General Chassis
Component.chassis = new TankDrive("Blinky-Chassis", Component.leftWheelA, Component.leftWheelB,
Component.rightWheelA, Component.rightWheelB);
Component.chassis = new TankDrive("Blinky-Chassis", Component.leftWheelA,
Component.rightWheelA);
Component.chassis.setDefaultCommand(new ChassisMove(Component.chassis, new NathanGain()));
}
}
18 changes: 18 additions & 0 deletions src/main/java/org/usfirst/frc4904/robot/commands/Turn.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.usfirst.frc4904.robot.commands;

import org.usfirst.frc4904.standard.commands.motor.MotorConstant;
import org.usfirst.frc4904.standard.subsystems.motor.Motor;

/**
* Constantly turns motor at specified speed.
*/

public class Turn extends MotorConstant {
public Turn(String name, Motor motor, double motorSpeed) {
super(name, motor, motorSpeed);
}

public Turn(Motor motor, double motorSpeed) {
super(motor, motorSpeed);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.List;

import org.usfirst.frc4904.robot.RobotMap;
import org.usfirst.frc4904.robot.commands.Turn;
import org.usfirst.frc4904.standard.LogKitten;
import org.usfirst.frc4904.standard.LogKitten.KittenLevel;
import org.usfirst.frc4904.standard.commands.Cancel;
Expand Down Expand Up @@ -39,6 +40,10 @@ protected double scaleGain(double input, double gain, double exp) {
public void bindCommands() {
RobotMap.HumanInput.Driver.xbox.a.whenPressed(new SolenoidExtend(RobotMap.Component.solenoid));
RobotMap.HumanInput.Driver.xbox.b.whenPressed(new SolenoidRetract(RobotMap.Component.solenoid));
RobotMap.HumanInput.Driver.xbox.dPad.down.whenPressed(new Turn(RobotMap.Component.extraMotor, 0.0/3.0)); // off
RobotMap.HumanInput.Driver.xbox.dPad.left.whenPressed(new Turn(RobotMap.Component.extraMotor, 1.0/3.0)); // slow
RobotMap.HumanInput.Driver.xbox.dPad.up.whenPressed(new Turn(RobotMap.Component.extraMotor, 2.0/3.0)); // medium
RobotMap.HumanInput.Driver.xbox.dPad.right.whenPressed(new Turn(RobotMap.Component.extraMotor, 3.0/3.0)); // max
}

@Override
Expand Down