Skip to content

Commit 9927e5e

Browse files
authored
Merge pull request #81 from FRCteam4909/WIP
WIP: Testing from Saturday
2 parents 8292ec6 + d5cd73c commit 9927e5e

34 files changed

+796
-367
lines changed

src/main/java/frc/team4909/robot/LIDAR.java

Lines changed: 0 additions & 78 deletions
This file was deleted.

src/main/java/frc/team4909/robot/Robot.java

100755100644
Lines changed: 85 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,81 +4,133 @@
44
import edu.wpi.first.wpilibj.PowerDistributionPanel;
55
import edu.wpi.first.wpilibj.TimedRobot;
66
import edu.wpi.first.wpilibj.command.Scheduler;
7-
import frc.team4909.robot.subsystems.drivetrain.Linefollow;
8-
import frc.team4909.robot.subsystems.intake.CargoIntakeIn;
9-
import frc.team4909.robot.subsystems.intake.CargoIntakeOut;
10-
import frc.team4909.robot.subsystems.intake.HatchPanelIntakeOpen;
11-
import frc.team4909.robot.subsystems.intake.HatchPanelIntakeClose;
127
import frc.team4909.robot.operator.controllers.BionicF310;
13-
// import frc.team4909.robot.sensors.Stream;
8+
import frc.team4909.robot.sensors.LidarLitePWM;
9+
import frc.team4909.robot.sensors.Stream;
10+
import frc.team4909.robot.subsystems.climber.ClimberSubsystem;
11+
import frc.team4909.robot.subsystems.climber.commands.DriveStiltsBack;
12+
import frc.team4909.robot.subsystems.climber.commands.DriveStiltsForward;
13+
import frc.team4909.robot.subsystems.climber.commands.ExtendStilts;
14+
import frc.team4909.robot.subsystems.climber.commands.RetractStilts;
1415
import frc.team4909.robot.subsystems.drivetrain.DriveTrainSubsystem;
16+
import frc.team4909.robot.subsystems.drivetrain.Linefollow;
1517
import frc.team4909.robot.subsystems.drivetrain.commands.InvertDriveDirection;
18+
import frc.team4909.robot.subsystems.elevator.ElevatorSubsystem;
19+
import frc.team4909.robot.subsystems.elevator.commands.SetElevatorPosition;
20+
import frc.team4909.robot.subsystems.elevatorarm.ElevatorArmSubsystem;
1621
import frc.team4909.robot.subsystems.intake.IntakeSubsystem;
17-
import frc.team4909.robot.subsystems.elevator.ElevatorSubsystem;;
22+
import frc.team4909.robot.subsystems.intake.commands.CargoIntakeIn;
23+
import frc.team4909.robot.subsystems.intake.commands.CargoIntakeOut;
24+
import frc.team4909.robot.subsystems.intake.commands.HatchPanelIntakeOpen;
25+
26+
// Controls:
27+
//
28+
// Driver Gamepad (Port 0):
29+
// LY: Drive Speed
30+
// RX: Drive Rotation
31+
// LT: Retract Stilts
32+
// RT: Extend Stilts
33+
// LB: Drive Stilt Back
34+
// RB: Drive Stilt Forward
35+
// A: Invert Drive Direction
36+
// B: Line Follow
37+
//
38+
// Operator Gamped (Port 1):
39+
// RY: Elevator Arm Pivot
40+
// LY: Elevator Speed
41+
// RT: Cargo Intake In
42+
// RB: Cargo Intake Out
43+
// LT: Hatch Panel Intake In
44+
1845
public class Robot extends TimedRobot {
1946

20-
// Stream stream = new Stream();
47+
// Camera
48+
public static Stream stream;
49+
// public static GripPipeline grip;
2150
// Operator Input
2251
public static BionicF310 driverGamepad;
2352
public static BionicF310 manipulatorGamepad;
53+
public boolean StiltsStop;
2454

2555
// Subsystems
2656
public static PowerDistributionPanel powerDistributionPanel;
2757
public static DriveTrainSubsystem drivetrainSubsystem;
2858
public static IntakeSubsystem intakeSubsystem;
2959
public static ElevatorSubsystem elevatorSubsystem;
60+
public static ElevatorArmSubsystem elevatorArmSubsystem;
61+
public static ClimberSubsystem climberSubsystem;
3062
public static Compressor c;
3163

32-
3364
// Sensors
3465
public static LidarLitePWM lidar;
3566

67+
// SmartDashboard Buttons
68+
public boolean CargoIntake;
69+
public boolean CargoOuttake;
70+
3671
/**
3772
* This function is run when the robot is first started up and should be used
3873
* for any initialization code.
3974
*/
75+
4076
@Override
4177
public void robotInit() {
4278

43-
c = new Compressor(0); //Initialize Compressor
44-
c.setClosedLoopControl(true); // Start Compressor in Closed Loop Control
45-
79+
// Cameras (subsystem)
80+
stream = new Stream();
81+
// CameraServer.getInstance().startAutomaticCapture();
82+
stream.streamCamera();
83+
// grip = new GripPipeline();
4684

47-
// stream.streamCamera();
48-
// GripPipeline grip = new GripPipeline();
85+
// Compressor
86+
c = new Compressor(0); // Initialize Compressor
87+
c.setClosedLoopControl(true); // Start Compressor in Closed Loop Control
4988

5089
// Subsystems
5190
powerDistributionPanel = new PowerDistributionPanel();
5291
drivetrainSubsystem = new DriveTrainSubsystem();
5392
intakeSubsystem = new IntakeSubsystem();
5493
elevatorSubsystem = new ElevatorSubsystem();
94+
elevatorArmSubsystem = new ElevatorArmSubsystem();
95+
climberSubsystem = new ClimberSubsystem();
5596

5697
// Sensors
57-
lidar = new LidarLitePWM(4);
98+
lidar = new LidarLitePWM(RobotMap.lidarPort);
5899

59100
// Operator Input
60-
61-
driverGamepad = new BionicF310(RobotConstants.driverGamepadPort, // Port
62-
RobotConstants.driverGamepadDeadzone, // Deadzone
63-
RobotConstants.driverGamepadSensitivity // Gamepad sensitivity
101+
driverGamepad = new BionicF310(RobotMap.driverGamepadPort, // Port
102+
RobotConstants.driverGamepadDeadzone, // Deadzone
103+
RobotConstants.driverGamepadSensitivity // Gamepad sensitivity
64104
);
65105

66-
manipulatorGamepad = new BionicF310(RobotConstants.manipulatorGamepadPort, // Port
67-
RobotConstants.manipulatorGamepadDeadzone, // Deadzone
68-
RobotConstants.manipulatorGamepadSensitivity // Gamepad sensitivity
106+
manipulatorGamepad = new BionicF310(RobotMap.manipulatorGamepadPort, // Port
107+
RobotConstants.manipulatorGamepadDeadzone, // Deadzone
108+
RobotConstants.manipulatorGamepadSensitivity // Gamepad sensitivity
69109
);
110+
/* Drivetrain */
70111

71-
driverGamepad.buttonPressed(BionicF310.A, new Linefollow());
72-
driverGamepad.buttonPressed(BionicF310.X, new CargoIntakeIn());
73-
driverGamepad.buttonPressed(BionicF310.Y, new CargoIntakeOut());
74-
driverGamepad.buttonPressed(BionicF310.LB, new HatchPanelIntakeOpen());
75-
driverGamepad.buttonPressed(BionicF310.RB, new HatchPanelIntakeClose());
76-
driverGamepad.buttonPressed(BionicF310.Start, new InvertDriveDirection());
77-
}
112+
/* Intake */
113+
manipulatorGamepad.buttonHeld(BionicF310.RT, 0.2, new CargoIntakeIn());
114+
manipulatorGamepad.buttonHeld(BionicF310.RB, new CargoIntakeOut());
115+
manipulatorGamepad.buttonHeld(BionicF310.LT, 0.2, new HatchPanelIntakeOpen());
116+
117+
/* Climber */
118+
driverGamepad.buttonHeld(BionicF310.RT, 0.2, new ExtendStilts());
119+
driverGamepad.buttonHeld(BionicF310.LT, 0.2, new RetractStilts());
120+
driverGamepad.buttonHeld(BionicF310.LB, new DriveStiltsBack());
121+
driverGamepad.buttonHeld(BionicF310.RB, new DriveStiltsForward());
122+
123+
/* Elevator */
124+
manipulatorGamepad.buttonPressed(BionicF310.A, new SetElevatorPosition(-13000, 1));
125+
126+
/* Sensors/Misc. */
127+
driverGamepad.buttonPressed(BionicF310.A, new InvertDriveDirection());
128+
driverGamepad.buttonPressed(BionicF310.B, new Linefollow());
129+
}
78130

79131
/**
80-
* This function is called every robot packet, no matter the mode. Use this for
81-
* items like diagnostics that you want ran during disabled, autonomous,
132+
* '' This function is called every robot packet, no matter the mode. Use this
133+
* for items like diagnostics that you want ran during disabled, autonomous,
82134
* teleoperated and test.
83135
*
84136
* <p>
@@ -108,7 +160,7 @@ public void autonomousPeriodic() {
108160
*/
109161
@Override
110162
public void teleopPeriodic() {
111-
System.out.println("Distance is " + lidar.getDistance()); // Remove for competition (necessary only for testing)
163+
112164
}
113165

114166
/**
@@ -117,4 +169,4 @@ public void teleopPeriodic() {
117169
@Override
118170
public void testPeriodic() {
119171
}
120-
}
172+
}

src/main/java/frc/team4909/robot/RobotConstants.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,52 @@
44

55
public class RobotConstants {
66
/* Operator Input */
7-
public static final int driverGamepadPort = 0;
87
public static final double driverGamepadSensitivity = 0.6; // Value selected from 2018 code
9-
public static final int driverGamepadDeadzone = 0; // Value selected from 2018 code
8+
public static final double driverGamepadDeadzone = 0.05; // Value selected from 2018 code
109

11-
public static final int manipulatorGamepadPort = 1;
1210
public static final double manipulatorGamepadSensitivity = 0.6; // Value selected from 2018 code
13-
public static final int manipulatorGamepadDeadzone = 0; // Value selected from 2018 code
11+
public static final double manipulatorGamepadDeadzone = 0.05; // Value selected from 2018 code
1412

1513
/* Drivetrain */
16-
public static final double speedMultiplier = .7;
14+
public static final double speedMultiplier = .7;
15+
public static final double speedTurnMultiplier = .4;
16+
public static final double speedTurnPreciseMultiplier = .2;
1717

1818
/* Intake */
1919
public static final double cargoIntakeInSpeed = 1.0;
20-
public static final double cargoIntakeHoldSpeed = 0;
20+
public static final double cargoIntakeHoldSpeed = 0.0625;
2121
public static final double cargoIntakeOutSpeed = -1.0;
2222

23-
public static final double cargoIntakeCurrentLimit = 20;
23+
// public static final double cargoIntakeCurrentLimit = 0;
2424

2525
/* LIDAR */
26-
public static final int calibrationOffset = -2;
27-
public static final double lidarLimit = 20; // cm
26+
public static final int calibrationOffset = -9; // calibration constant used for Lidar
27+
public static final double lidarLimit = 30; // cm
2828

2929
/*
3030
* Sensor Threshold derived by testing the minimum voltage readouts when the
3131
* ball is placed LEFT, RIGHT, and CENTER. This value should then be compared to
3232
* when there is no cargo to ensure that the values do not overlap. The
3333
* distinguishing value is then denoted as the treshold.
3434
*/
35+
3536
/* Sensors */
3637
public static final double irSensorThreshold = 1.7;
3738

38-
3939
/* Elevator */
40-
public static final int elevatorSRXID = 7; //Master SRX ID
41-
public static final int elevatorSPX1ID = 4; //Slave 1 ID
42-
public static final int elevatorSPX2ID = 5; //Slave 2 ID
43-
public static final int elevatorSPX3ID = 6; //Slave 3 ID
44-
45-
public static final double elevatorSpeedMultiplier = 1.0; //Multiplier for elevator speed
46-
public static final double elevatorArmSpeedMultiplier = 1.0; //Multiplier for elevator arm speed
47-
48-
40+
public static final double elevatorSpeedMultiplier = 0.5; // Multiplier for elevator speed
41+
public static final double elevatorArmSpeedMultiplier = 0.75; // Multiplier for elevator arm speed
4942

5043
/* Linefollow */
5144
public static final double fastVelocity = 0.7;
5245
public static final double mediumVelocity = 0.5; // constant velocity given to both motors
5346
public static final double slowVelocity = 0.2; // value given to motor when trying to turn
5447

48+
/* Climber */
49+
public static final double climberStiltSpeed = 0.3;
50+
public static final double climberDriveSpeed = 0.3;
51+
public static final double elevatorClimbSpeed = 0.3;
52+
53+
/* Timeout */
54+
public static final int timeoutMs = 30; // milliseconds
5555
}

src/main/java/frc/team4909/robot/RobotMap.java

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,45 @@
1414
* floating around.
1515
*/
1616
public class RobotMap {
17-
/* The following variables are PWM slots, with the exception of
18-
* CAN: CAN Device IDs, need to be configured through respective tool
19-
* PDP: PDP Slot Number, corresponds to hardware
20-
* IR: Analog Sensor Input
21-
* Channel: PCM Solenoid Output
17+
/*
18+
* The following variables are PWM slots, with the exception of CAN: CAN Device
19+
* IDs, need to be configured through respective tool PDP: PDP Slot Number,
20+
* corresponds to hardware IR: Analog Sensor Input Channel: PCM Solenoid Output
2221
*/
2322

24-
/* Drivetrain */
23+
/* Gamepad */
24+
public static final int driverGamepadPort = 0;
25+
public static final int manipulatorGamepadPort = 1;
26+
27+
/* Drivetrain */
2528
public static final int driveFrontLeftSparkMaxCAN = 3;
2629
public static final int driveRearLeftSparkMaxCAN = 4;
2730
public static final int driveFrontRightSparkMaxCAN = 1;
2831
public static final int driveRearRightSparkMaxCAN = 2;
2932

3033
/* Intake */
31-
public static final int intakeForwardChannel = 1;
32-
public static final int intakeReverseChannel = 2;
33-
public static final int intakeMotorCAN = 1;
34-
public static final int intakeMotorPDP = 1;
34+
public static final int intakePCMChannelL = 0;
35+
public static final int intakePCMChannelR= 1;
36+
public static final int intakeMotorCAN = 9;
37+
public static final int intakeMotorPDP = 4;
3538
public static final int leftIRSensor = 0;
3639
public static final int rightIRSensor = 1;
37-
40+
41+
/* Elevator */
42+
public static final int elevatorSRXID = 7; // Master SRX ID Back left
43+
public static final int elevatorSPX1ID = 4; // Slave 1 ID FrontLeft ELevator Left
44+
public static final int elevatorSPX2ID = 5; // Slave 2 ID Bottom `Elevator Right
45+
public static final int elevatorSPX3ID = 6; // Slave 3 ID Back right Elevator right
46+
47+
public static final int elevatorArmSRXID = 8; // Front
3848
// If you are using multiple modules, make sure to define both the port
3949
// number and the module. For example you with a rangefinder:
40-
50+
51+
/* Climber */
52+
public static final int climberSRXID = 10;
53+
public static final int climberSPXID = 11;
54+
55+
/* Sensors */
56+
public static final int lidarPort = 4;
57+
4158
}

0 commit comments

Comments
 (0)