Compare commits
1 Commits
9d71ef670c
...
Branch-Ash
Author | SHA1 | Date | |
---|---|---|---|
00fddffd32 |
@ -4,11 +4,14 @@ import com.qualcomm.robotcore.hardware.DcMotor;
|
||||
import com.qualcomm.robotcore.hardware.DcMotorSimple;
|
||||
|
||||
public class MovementLibrary {
|
||||
|
||||
|
||||
public static void setDirectionForward (DcMotor rhw, DcMotor rlw, DcMotor lhw, DcMotor llw) {
|
||||
rhw.setDirection(DcMotor.Direction.REVERSE);
|
||||
rlw.setDirection(DcMotor.Direction.FORWARD);
|
||||
lhw.setDirection(DcMotorSimple.Direction.FORWARD);
|
||||
llw.setDirection(DcMotorSimple.Direction.REVERSE);}
|
||||
llw.setDirection(DcMotorSimple.Direction.REVERSE);
|
||||
}
|
||||
|
||||
public static void setDirectionBackward (DcMotor rhw, DcMotor rlw, DcMotor lhw, DcMotor llw) {
|
||||
rhw.setDirection(DcMotor.Direction.FORWARD);
|
||||
@ -17,25 +20,26 @@ public class MovementLibrary {
|
||||
llw.setDirection(DcMotorSimple.Direction.FORWARD);
|
||||
}
|
||||
|
||||
public static void setSpeed (double speedValue,DcMotor rhw, DcMotor rlw, DcMotor lhw, DcMotor llw){
|
||||
rhw.setPower(speedValue);
|
||||
rlw.setPower(speedValue);
|
||||
llw.setPower(speedValue);
|
||||
lhw.setPower(speedValue);
|
||||
|
||||
|
||||
}
|
||||
public static void setDirectionRight(DcMotor rhw, DcMotor rlw, DcMotor lhw, DcMotor llw){
|
||||
public static void setDirectionLeft (DcMotor rhw, DcMotor rlw, DcMotor lhw, DcMotor llw) {
|
||||
rhw.setDirection(DcMotor.Direction.REVERSE);
|
||||
rlw.setDirection(DcMotor.Direction.REVERSE);
|
||||
lhw.setDirection(DcMotorSimple.Direction.FORWARD);
|
||||
llw.setDirection(DcMotorSimple.Direction.FORWARD);
|
||||
|
||||
}
|
||||
public static void setDirectionLeft(DcMotor rhw, DcMotor rlw, DcMotor lhw, DcMotor llw){
|
||||
|
||||
public static void setDirectionRight (DcMotor rhw, DcMotor rlw, DcMotor lhw, DcMotor llw) {
|
||||
rhw.setDirection(DcMotor.Direction.FORWARD);
|
||||
rlw.setDirection(DcMotor.Direction.FORWARD);
|
||||
lhw.setDirection(DcMotorSimple.Direction.REVERSE);
|
||||
llw.setDirection(DcMotorSimple.Direction.REVERSE);
|
||||
}
|
||||
|
||||
public static void setSpeed (double speedValue, DcMotor rhw, DcMotor rlw, DcMotor lhw, DcMotor llw) {
|
||||
rhw.setPower(speedValue);
|
||||
rlw.setPower(speedValue);
|
||||
lhw.setPower(speedValue);
|
||||
llw.setPower(speedValue);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -12,12 +12,8 @@ import com.qualcomm.robotcore.hardware.DcMotorSimple;
|
||||
import com.qualcomm.robotcore.hardware.DistanceSensor;
|
||||
import com.qualcomm.robotcore.hardware.TouchSensor;
|
||||
import org.firstinspires.ftc.teamcode.MovementLibrary;
|
||||
|
||||
import org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Autonomous(name="Name")
|
||||
public class Name extends LinearOpMode {
|
||||
private DcMotor rightHandWheel;
|
||||
@ -39,19 +35,8 @@ public class Name extends LinearOpMode {
|
||||
distanceSensor = hardwareMap.get(DistanceSensor.class , "distancesensor");
|
||||
colorSensor = hardwareMap.get(ColorSensor.class, "colorsensor");
|
||||
|
||||
DcMotor[] motors = {rightHandWheel, leftHandWheel, rightLegWheel, leftLegWheel};
|
||||
|
||||
MovementLibrary.setDirectionForward(rightHandWheel,rightLegWheel,leftHandWheel,leftLegWheel);
|
||||
|
||||
//from this
|
||||
DcMotor[] motors = {rightHandWheel, leftHandWheel, rightLegWheel, leftLegWheel};
|
||||
|
||||
//thismotors
|
||||
MovementLibrary.setDirectionForward(motors);
|
||||
|
||||
// Wait for the game to start (driver presses {Play
|
||||
waitForStart();
|
||||
|
||||
MovementLibrary.setSpeed(0.2,rightHandWheel,rightLegWheel,leftHandWheel,leftLegWheel);
|
||||
|
||||
// Wait for the game to start (driver presses PLAY)
|
||||
waitForStart();
|
||||
@ -83,15 +68,18 @@ public class Name extends LinearOpMode {
|
||||
double nicerValue = distanceSensor.getDistance(DistanceUnit.INCH);
|
||||
|
||||
telemetry.addData("you are this far (in inches) --> ", "%.2f", nicerValue);
|
||||
telemetry.addData("green color value",colorSensor.green());
|
||||
telemetry.addData("blue color value" ,colorSensor.blue());
|
||||
telemetry.update();
|
||||
telemetry.addData("Red: ", colorSensor.red());
|
||||
telemetry.addData("Green: ", colorSensor.green());
|
||||
telemetry.addData("Blue: ", colorSensor.blue());
|
||||
|
||||
if (colorSensor.blue() > 800 && colorSensor.green() > 1100) {
|
||||
if(colorSensor.green() > 1100 && colorSensor.blue() > 1000) {
|
||||
MovementLibrary.setSpeed(0.4,rightHandWheel,rightLegWheel,leftHandWheel,leftLegWheel);
|
||||
} else {
|
||||
MovementLibrary.setSpeed(0.2,rightHandWheel,rightLegWheel,leftHandWheel,leftLegWheel);
|
||||
}
|
||||
};
|
||||
|
||||
telemetry.update();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user