Compare commits
3 Commits
Branch-Ash
...
5d99d94430
Author | SHA1 | Date | |
---|---|---|---|
5d99d94430 | |||
d77067538a | |||
bf1b45618e |
@ -4,42 +4,38 @@ import com.qualcomm.robotcore.hardware.DcMotor;
|
|||||||
import com.qualcomm.robotcore.hardware.DcMotorSimple;
|
import com.qualcomm.robotcore.hardware.DcMotorSimple;
|
||||||
|
|
||||||
public class MovementLibrary {
|
public class MovementLibrary {
|
||||||
|
public static void setDirectionForward(DcMotor rhw, DcMotor rlw, DcMotor lhw, DcMotor llw){
|
||||||
|
|
||||||
public static void setDirectionForward (DcMotor rhw, DcMotor rlw, DcMotor lhw, DcMotor llw) {
|
|
||||||
rhw.setDirection(DcMotor.Direction.REVERSE);
|
rhw.setDirection(DcMotor.Direction.REVERSE);
|
||||||
rlw.setDirection(DcMotor.Direction.FORWARD);
|
rlw.setDirection(DcMotor.Direction.FORWARD);
|
||||||
lhw.setDirection(DcMotorSimple.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) {
|
public static void setDirectionBackward(DcMotor rhw, DcMotor rlw, DcMotor lhw, DcMotor llw){
|
||||||
rhw.setDirection(DcMotor.Direction.FORWARD);
|
rhw.setDirection(DcMotor.Direction.FORWARD);
|
||||||
rlw.setDirection(DcMotor.Direction.REVERSE);
|
rlw.setDirection(DcMotor.Direction.REVERSE);
|
||||||
lhw.setDirection(DcMotorSimple.Direction.REVERSE);
|
lhw.setDirection(DcMotorSimple.Direction.REVERSE);
|
||||||
llw.setDirection(DcMotorSimple.Direction.FORWARD);
|
llw.setDirection(DcMotorSimple.Direction.FORWARD);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setDirectionLeft (DcMotor rhw, DcMotor rlw, DcMotor lhw, DcMotor llw) {
|
public static void setSpeed (double speedValue,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 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);
|
rhw.setPower(speedValue);
|
||||||
rlw.setPower(speedValue);
|
rlw.setPower(speedValue);
|
||||||
lhw.setPower(speedValue);
|
|
||||||
llw.setPower(speedValue);
|
llw.setPower(speedValue);
|
||||||
|
lhw.setPower(speedValue);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public static void setDirectionRight(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){
|
||||||
|
rhw.setDirection(DcMotor.Direction.FORWARD);
|
||||||
|
rlw.setDirection(DcMotor.Direction.FORWARD);
|
||||||
|
lhw.setDirection(DcMotorSimple.Direction.REVERSE);
|
||||||
|
llw.setDirection(DcMotorSimple.Direction.REVERSE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import com.qualcomm.robotcore.hardware.DcMotorSimple;
|
|||||||
import com.qualcomm.robotcore.hardware.DistanceSensor;
|
import com.qualcomm.robotcore.hardware.DistanceSensor;
|
||||||
import com.qualcomm.robotcore.hardware.TouchSensor;
|
import com.qualcomm.robotcore.hardware.TouchSensor;
|
||||||
import org.firstinspires.ftc.teamcode.MovementLibrary;
|
import org.firstinspires.ftc.teamcode.MovementLibrary;
|
||||||
|
|
||||||
import org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit;
|
import org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit;
|
||||||
|
|
||||||
@Autonomous(name="Name")
|
@Autonomous(name="Name")
|
||||||
@ -33,10 +34,21 @@ public class Name extends LinearOpMode {
|
|||||||
leftLegWheel = hardwareMap.get(DcMotor.class, "left leg wheel");
|
leftLegWheel = hardwareMap.get(DcMotor.class, "left leg wheel");
|
||||||
touchSensor = hardwareMap.get(TouchSensor.class, "touchsensor");
|
touchSensor = hardwareMap.get(TouchSensor.class, "touchsensor");
|
||||||
distanceSensor = hardwareMap.get(DistanceSensor.class , "distancesensor");
|
distanceSensor = hardwareMap.get(DistanceSensor.class , "distancesensor");
|
||||||
colorSensor = hardwareMap.get(ColorSensor.class, "colorsensor");
|
colorSensor= hardwareMap.get(ColorSensor.class , "colorsensor");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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.setDirectionForward(rightHandWheel,rightLegWheel,leftHandWheel,leftLegWheel);
|
|
||||||
MovementLibrary.setSpeed(0.2,rightHandWheel,rightLegWheel,leftHandWheel,leftLegWheel);
|
|
||||||
|
|
||||||
// Wait for the game to start (driver presses PLAY)
|
// Wait for the game to start (driver presses PLAY)
|
||||||
waitForStart();
|
waitForStart();
|
||||||
@ -58,7 +70,7 @@ public class Name extends LinearOpMode {
|
|||||||
"O say, that star-spangled banner doesn't wave" +
|
"O say, that star-spangled banner doesn't wave" +
|
||||||
"Over the land of the enslaved and the home of the cowardly");*/
|
"Over the land of the enslaved and the home of the cowardly");*/
|
||||||
|
|
||||||
MovementLibrary.setSpeed(0.2,rightHandWheel,rightLegWheel,leftHandWheel,leftLegWheel);
|
MovementLibrary.setSpeed(0.2, rightHandWheel, rightLegWheel,leftHandWheel,leftLegWheel);
|
||||||
|
|
||||||
if(touchSensor.isPressed()) {
|
if(touchSensor.isPressed()) {
|
||||||
telemetry.speak("Ouchie that hurt me and my feelings");
|
telemetry.speak("Ouchie that hurt me and my feelings");
|
||||||
@ -68,18 +80,15 @@ public class Name extends LinearOpMode {
|
|||||||
double nicerValue = distanceSensor.getDistance(DistanceUnit.INCH);
|
double nicerValue = distanceSensor.getDistance(DistanceUnit.INCH);
|
||||||
|
|
||||||
telemetry.addData("you are this far (in inches) --> ", "%.2f", nicerValue);
|
telemetry.addData("you are this far (in inches) --> ", "%.2f", nicerValue);
|
||||||
telemetry.addData("Red: ", colorSensor.red());
|
telemetry.addData("green color value",colorSensor.green());
|
||||||
telemetry.addData("Green: ", colorSensor.green());
|
telemetry.addData("blue color value" ,colorSensor.blue());
|
||||||
telemetry.addData("Blue: ", colorSensor.blue());
|
|
||||||
|
|
||||||
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();
|
telemetry.update();
|
||||||
|
|
||||||
|
if (colorSensor.blue() > 800 && colorSensor.green() > 1100) {
|
||||||
|
MovementLibrary.setSpeed(0.4, rightHandWheel, rightLegWheel,leftHandWheel,leftLegWheel);
|
||||||
|
}else {
|
||||||
|
MovementLibrary.setSpeed(0.2, rightHandWheel, rightLegWheel,leftHandWheel,leftLegWheel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user