Skip to content
This repository was archived by the owner on Sep 12, 2023. It is now read-only.

Commit f29b4c5

Browse files
committed
Merge remote-tracking branch 'origin/master'
# Conflicts: # TechnoOneCode/src/main/java/org/firstinspires/ftc/teamcode/Hardware.java
2 parents 96d5fa0 + e20ff8e commit f29b4c5

26 files changed

+418
-42
lines changed

TechnoOneCode/src/main/java/org/firstinspires/ftc/teamcode/Hardware.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.technototes.library.hardware.motor.EncodedMotor;
55
import com.technototes.library.hardware.motor.Motor;
66
import com.technototes.library.hardware.sensor.IMU;
7+
import com.technototes.library.hardware.sensor.RangeSensor;
78
import com.technototes.library.hardware.servo.Servo;
89
import com.technototes.vision.hardware.Webcam;
910

@@ -29,9 +30,9 @@ public class Hardware {
2930

3031
public static Webcam camera;
3132

33+
public static RangeSensor intakeDistSensor;
3234

33-
34-
35+
public static Servo capServo;
3536

3637
static {
3738
if(LIFT_CONNECTED) {
@@ -55,7 +56,11 @@ public class Hardware {
5556
camera = new Webcam("webcam1");
5657
}
5758
if(INTAKE_CONNECTED){
58-
intakeMotor = new Motor<>("lift");
59+
intakeMotor = new Motor<>("carousel");
60+
intakeDistSensor = new RangeSensor("distanceSensor");
61+
}
62+
if(CAP_CONNECTED){
63+
capServo = new Servo("cap");
5964
}
6065
}
6166
}

TechnoOneCode/src/main/java/org/firstinspires/ftc/teamcode/Robot.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.technototes.library.logger.Log;
66
import com.technototes.library.logger.Loggable;
77

8+
import org.firstinspires.ftc.teamcode.subsystems.CapSubsystem;
89
import org.firstinspires.ftc.teamcode.subsystems.CarouselSubsystem;
910
import org.firstinspires.ftc.teamcode.subsystems.DepositSubsystem;
1011
import org.firstinspires.ftc.teamcode.subsystems.DrivebaseSubsystem;
@@ -23,6 +24,7 @@ public static class RobotConstants {
2324
public static boolean CAROUSEL_CONNECTED = true;
2425
public static boolean INTAKE_CONNECTED = true;
2526
public static boolean VISION_CONNECTED = false;
27+
public static boolean CAP_CONNECTED = false;
2628
}
2729

2830
@Log.NumberBar(name = "Lift", min = 0, max = 1100, scale = 100, completeBarColor = Color.PURPLE)
@@ -43,6 +45,8 @@ public static class RobotConstants {
4345
@Log.Number(name = "Vision", color = Color.GREEN)
4446
public VisionSubsystem visionSubsystem;
4547

48+
public CapSubsystem capSubsystem;
49+
4650
public Robot(){
4751
if(LIFT_CONNECTED) liftSubsystem = new LiftSubsystem(Hardware.liftMotor);
4852

@@ -52,8 +56,10 @@ public Robot(){
5256

5357
if(CAROUSEL_CONNECTED) carouselSubsystem = new CarouselSubsystem(Hardware.carouselMotor);
5458

55-
if(INTAKE_CONNECTED) intakeSubsystem = new IntakeSubsystem(Hardware.intakeMotor);
59+
if(INTAKE_CONNECTED) intakeSubsystem = new IntakeSubsystem(Hardware.intakeMotor, Hardware.intakeDistSensor);
5660

5761
if(VISION_CONNECTED) visionSubsystem = new VisionSubsystem(Hardware.camera);
62+
63+
if(CAP_CONNECTED) capSubsystem = new CapSubsystem(Hardware.capServo);
5864
}
5965
}

TechnoOneCode/src/main/java/org/firstinspires/ftc/teamcode/commands/carousel/CarouselLeftCommand.java

+1-11
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
public class CarouselLeftCommand implements Command {
88

9-
public CarouselSubsystem subsystem;
9+
CarouselSubsystem subsystem;
1010

1111
public CarouselLeftCommand(CarouselSubsystem s){
1212
subsystem = s;
@@ -17,15 +17,5 @@ public CarouselLeftCommand(CarouselSubsystem s){
1717
public void execute(){
1818
subsystem.left();
1919
}
20-
21-
@Override
22-
public boolean isFinished() {
23-
return false;
24-
}
25-
26-
@Override
27-
public void end(boolean cancel) {
28-
if(cancel) subsystem.stop();
29-
}
3020
}
3121

TechnoOneCode/src/main/java/org/firstinspires/ftc/teamcode/commands/carousel/CarouselRightCommand.java

+1-10
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
public class CarouselRightCommand implements Command {
88

9-
public CarouselSubsystem subsystem;
9+
CarouselSubsystem subsystem;
1010

1111
public CarouselRightCommand(CarouselSubsystem s){
1212
subsystem = s;
@@ -17,13 +17,4 @@ public CarouselRightCommand(CarouselSubsystem s){
1717
public void execute(){
1818
subsystem.right();
1919
}
20-
@Override
21-
public boolean isFinished() {
22-
return false;
23-
}
24-
25-
@Override
26-
public void end(boolean cancel) {
27-
if(cancel) subsystem.stop();
28-
}
2920
}

TechnoOneCode/src/main/java/org/firstinspires/ftc/teamcode/commands/deposit/ArmRetractCommand.java

+1
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ public boolean isFinished() {
2121
return getRuntime().seconds()>1;
2222
}
2323
}
24+

TechnoOneCode/src/main/java/org/firstinspires/ftc/teamcode/commands/deposit/CarryCommand.java

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
public class CarryCommand extends DumpVariableCommand {
66
public CarryCommand(DepositSubsystem s){
7+
78
super(s, DepositSubsystem.DepositConstants.CARRY);
89
}
910
@Override

TechnoOneCode/src/main/java/org/firstinspires/ftc/teamcode/commands/deposit/DumpCommand.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ public DumpCommand(DepositSubsystem s){
1010
}
1111
@Override
1212
public boolean isFinished() {
13-
return getRuntime().seconds()>0.5;
13+
return getRuntime().seconds() > 0.5;
1414
}
1515
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.firstinspires.ftc.teamcode.subsystems;
2+
3+
import com.technototes.library.hardware.servo.Servo;
4+
import com.technototes.library.subsystem.Subsystem;
5+
6+
import java.util.function.Supplier;
7+
8+
public class CapSubsystem implements Subsystem, Supplier<Double> {
9+
public static class CapConstant{
10+
public static final double DEADZONE = 0.1;
11+
}
12+
13+
public Servo capServo;
14+
15+
public CapSubsystem(Servo s){
16+
capServo = s;
17+
}
18+
19+
public void goto_position(double pos){
20+
capServo.setPosition(pos);
21+
}
22+
23+
@Override
24+
public Double get() {
25+
return null;
26+
}
27+
}

TechnoOneCode/src/main/java/org/firstinspires/ftc/teamcode/subsystems/CarouselSubsystem.java

+20
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515

1616
public class CarouselSubsystem implements Subsystem, Supplier<Double> {
1717

18+
/**
19+
* Carousel Constants for measuring speed of carousel motor
20+
*/
21+
1822
@Config
1923
public static class CarouselConstants{
2024
public static double CAROUSEL_RIGHT_SPEED = 1;
@@ -28,11 +32,27 @@ public static class CarouselConstants{
2832

2933
public void right(){motor.setSpeed(CAROUSEL_RIGHT_SPEED);}
3034

35+
/**
36+
* when called by Carousel Right Command, sets motor to turn carousel right
37+
*/
38+
3139
public void left(){motor.setSpeed(CarouselConstants.CAROUSEL_LEFT_SPEED);}
3240

41+
/**
42+
* when called by Carousel Left Command, sets motor to turn carousel left
43+
*/
44+
3345
public void stop(){motor.setSpeed(CAROUSEL_STOP_SPEED);}
46+
47+
/**
48+
* when called by Carousel Stop Command, stops carousel motor
49+
*/
50+
3451
@Override
3552
public Double get() {
3653
return motor.getSpeed();
54+
/**
55+
* gets current motor speed
56+
*/
3757
}
3858
}

TechnoOneCode/src/main/java/org/firstinspires/ftc/teamcode/subsystems/DepositSubsystem.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
package org.firstinspires.ftc.teamcode.subsystems;
22

3+
import static org.firstinspires.ftc.teamcode.subsystems.DepositSubsystem.DepositConstants.CARRY;
4+
import static org.firstinspires.ftc.teamcode.subsystems.DepositSubsystem.DepositConstants.COLLECT;
5+
import static org.firstinspires.ftc.teamcode.subsystems.DepositSubsystem.DepositConstants.DUMP;
6+
import static org.firstinspires.ftc.teamcode.subsystems.DepositSubsystem.DepositConstants.IN;
7+
import static org.firstinspires.ftc.teamcode.subsystems.DepositSubsystem.DepositConstants.OUT;
8+
39
import com.acmerobotics.dashboard.config.Config;
410
import com.qualcomm.robotcore.util.Range;
511
import com.technototes.library.hardware.servo.Servo;
612
import com.technototes.library.subsystem.Subsystem;
713

814
import java.util.function.Supplier;
9-
10-
import static org.firstinspires.ftc.teamcode.subsystems.DepositSubsystem.DepositConstants.*;
1115
@SuppressWarnings("unused")
1216

1317
public class DepositSubsystem implements Subsystem, Supplier<String> {
@@ -29,6 +33,7 @@ public static class DepositConstants{
2933
public DepositSubsystem(Servo l, Servo r){
3034
dumpServo = l;
3135
armServo = r;
36+
// Don't need differentials
3237
// differential = new Differential(l::setPosition, r::setPosition, Differential.DifferentialPriority.DIFFERENCE)
3338
// .setLimits(MIN, MAX);
3439
}

TechnoOneCode/src/main/java/org/firstinspires/ftc/teamcode/subsystems/IntakeSubsystem.java

+20-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.acmerobotics.dashboard.config.Config;
44
import com.qualcomm.robotcore.hardware.DcMotorEx;
55
import com.technototes.library.hardware.motor.Motor;
6+
import com.technototes.library.hardware.sensor.RangeSensor;
67
import com.technototes.library.subsystem.Subsystem;
78

89
import java.util.function.Supplier;
@@ -20,11 +21,17 @@ public static class IntakeConstants{
2021
public static double INTAKE_IN_SPEED = 1;
2122
public static double INTAKE_OUT_SPEED = -1;
2223
public static double INTAKE_STOP_SPEED = 0;
24+
public static double ACCEPTABLE_DISTANCE = 5;
2325
}
2426

2527
public Motor<DcMotorEx> motor;
2628

27-
public IntakeSubsystem(Motor<DcMotorEx> m){motor = m;}
29+
public RangeSensor rangeSensor;
30+
31+
public IntakeSubsystem(Motor<DcMotorEx> m, RangeSensor rs){
32+
motor = m;
33+
rangeSensor = rs;
34+
}
2835

2936
/**
3037
* Set the intake motor to run in at a constant speed
@@ -46,6 +53,18 @@ public void out(){
4653
public void stop(){
4754
motor.setSpeed(INTAKE_STOP_SPEED);
4855
}
56+
57+
public double getSensorDistance(){
58+
return rangeSensor.getSensorValue();
59+
}
60+
61+
public boolean isNearTarget(){
62+
if (getSensorDistance() <= IntakeConstants.ACCEPTABLE_DISTANCE){
63+
return true;
64+
}
65+
return false;
66+
}
67+
4968
@Override
5069
public Double get() {
5170
return motor.getSpeed();

TechnoOneCode/src/main/java/org/firstinspires/ftc/teamcode/subsystems/LiftSubsystem.java

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public LiftSubsystem(EncodedMotor<DcMotorEx> l){
3636
pidController = new PIDFController(PID, 0, 0, 0, (x,y)->0.1);
3737
}
3838

39-
4039
public void setLiftPosition(double pos){
4140
pidController.setTargetPosition(Range.clip(pos, LIFT_LOWER_LIMIT, LIFT_UPPER_LIMIT));
4241
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,61 @@
11
package org.firstinspires.ftc.teamcode;
22

3+
import static org.firstinspires.ftc.teamcode.Robot.RobotConstants.CAROUSEL_CONNECTED;
4+
import static org.firstinspires.ftc.teamcode.Robot.RobotConstants.DEPOSIT_CONNECTED;
5+
import static org.firstinspires.ftc.teamcode.Robot.RobotConstants.DRIVE_CONNECTED;
6+
import static org.firstinspires.ftc.teamcode.Robot.RobotConstants.INTAKE_CONNECTED;
7+
import static org.firstinspires.ftc.teamcode.Robot.RobotConstants.LIFT_CONNECTED;
8+
import static org.firstinspires.ftc.teamcode.Robot.RobotConstants.VISION_CONNECTED;
9+
10+
import com.qualcomm.robotcore.hardware.DcMotorEx;
11+
import com.technototes.library.hardware.motor.EncodedMotor;
12+
import com.technototes.library.hardware.motor.Motor;
13+
import com.technototes.library.hardware.sensor.IMU;
14+
import com.technototes.library.hardware.servo.Servo;
15+
import com.technototes.vision.hardware.Webcam;
16+
317
public class Hardware {
4-
}
18+
public static EncodedMotor<DcMotorEx> liftMotor;
19+
20+
public static Servo leftDepositServo;
21+
public static Servo rightDepositServo;
22+
23+
public static EncodedMotor<DcMotorEx> flDriveMotor;
24+
public static EncodedMotor<DcMotorEx> frDriveMotor;
25+
public static EncodedMotor<DcMotorEx> rlDriveMotor;
26+
public static EncodedMotor<DcMotorEx> rrDriveMotor;
27+
public static IMU imu;
28+
29+
public static Motor<DcMotorEx> intakeMotor;
30+
31+
public static Motor<DcMotorEx> carouselMotor;
32+
33+
public static Webcam camera;
34+
35+
static {
36+
if(LIFT_CONNECTED) {
37+
liftMotor = new EncodedMotor<>("lift");
38+
}
39+
if(DEPOSIT_CONNECTED) {
40+
leftDepositServo = new Servo("leftDeposit").invert();
41+
42+
leftDepositServo = new Servo("rightDeposit");
43+
}
44+
if (DRIVE_CONNECTED) {
45+
flDriveMotor = new EncodedMotor<>("flMotor");
46+
frDriveMotor = new EncodedMotor<>("frMotor");
47+
rlDriveMotor = new EncodedMotor<>("rlMotor");
48+
rrDriveMotor = new EncodedMotor<>("rrMotor");
49+
}
50+
if(CAROUSEL_CONNECTED) {
51+
carouselMotor = new EncodedMotor<>("carouselMotor");
52+
}
53+
if(VISION_CONNECTED) {
54+
camera = new Webcam("webcam1");
55+
}
56+
if(INTAKE_CONNECTED) {
57+
intakeMotor = new Motor<>("intake");
58+
}
59+
60+
}
61+
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,38 @@
11
package org.firstinspires.ftc.teamcode;
22

3-
public class Robot {
3+
import com.acmerobotics.dashboard.config.Config;
4+
import com.technototes.library.logger.Loggable;
5+
6+
import org.firstinspires.ftc.teamcode.subsystems.DepositSubsystem;
7+
import org.firstinspires.ftc.teamcode.subsystems.DrivebaseSubsystem;
8+
import org.firstinspires.ftc.teamcode.subsystems.IntakeSubsystem;
9+
import org.firstinspires.ftc.teamcode.subsystems.LiftSubsystem;
10+
import org.firstinspires.ftc.teamcode.subsystems.CarouselSubsystem;
11+
import org.firstinspires.ftc.teamcode.subsystems.VisionSubsystem;
12+
import static org.firstinspires.ftc.teamcode.Robot.RobotConstants.*;
13+
14+
public class Robot implements Loggable {
15+
@Config
16+
public static class RobotConstants {
17+
public static boolean LIFT_CONNECTED = false;
18+
public static boolean DEPOSIT_CONNECTED = false;
19+
public static boolean DRIVE_CONNECTED = true;
20+
public static boolean CAROUSEL_CONNECTED = false;
21+
public static boolean INTAKE_CONNECTED = false;
22+
public static boolean VISION_CONNECTED = false;
23+
}
24+
public LiftSubsystem liftSubsystem;
25+
public DepositSubsystem depositSubsystem;
26+
public DrivebaseSubsystem drivebaseSubsystem;
27+
public CarouselSubsystem carouselSubsystem;
28+
public IntakeSubsystem intakeSubsystem;
29+
public VisionSubsystem visionSubsystem;
30+
public Robot() {
31+
if (LIFT_CONNECTED) liftSubsystem = new LiftSubsystem(Hardware.liftMotor);
32+
if (DEPOSIT_CONNECTED) depositSubsystem = new DepositSubsystem(Hardware.leftDepositServo, Hardware.rightDepositServo);
33+
if (DRIVE_CONNECTED) drivebaseSubsystem = new DrivebaseSubsystem(Hardware.flDriveMotor, Hardware.frDriveMotor, Hardware.rlDriveMotor, Hardware.rrDriveMotor, Hardware.imu);
34+
if (CAROUSEL_CONNECTED) carouselSubsystem = new CarouselSubsystem(Hardware.carouselMotor);
35+
if (INTAKE_CONNECTED) intakeSubsystem = new IntakeSubsystem(Hardware.intakeMotor);
36+
if (VISION_CONNECTED) visionSubsystem = new VisionSubsystem(Hardware.camera);
37+
}
438
}

0 commit comments

Comments
 (0)