Exploit databaseDownload repository ZIP
GH-1615919550439d2f818f9bf6b428941b
8081knights/knights-8081-power-play-2022
Sources for CVE-2019-11358
1,181 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files18
8081knights/knights-8081-power-play-2022Revision 5dcd00c2546a
- ↑..Parent directory
- BraydenTeleop.java
- CamOrientTest.java
- CarboMecanumDT.java
- EmergencyTeleop.java
- EncoderTest.java
- FieldCentricDT.java
- GyroTest.java
- HeadlessRobot.java
- JudgesTeleop.java
- MecanumTest.java
- MotorFunctionTest.java
- MotorTest.java
- RobotCommands.java
- ServoTest.java
- carouselTest.java
- compTeleop.java
- scrimmageTeleop.java
- testForEncoder.java
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
TeamCode/src/main/java/org/firstinspires/ftc/teamcode/TeleOp/testForEncoder.java
Java · 7,984 bytespackage org.firstinspires.ftc.teamcode.TeleOp;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.Servo;
import com.qualcomm.robotcore.util.ElapsedTime;
@TeleOp(name="Robot: Auto Drive By Encoder haha", group="Robot")
@Disabled
public class testForEncoder extends LinearOpMode {
/* Declare OpMode members. */
private DcMotor frontRight = null;
private DcMotor backRight = null;
private DcMotor frontLeft = null;
private DcMotor backLeft = null;
private ElapsedTime runtime = new ElapsedTime();
// Calculate the COUNTS_PER_INCH for your specific drive train.
// Go to your motor vendor website to determine your motor's COUNTS_PER_MOTOR_REV
// For external drive gearing, set DRIVE_GEAR_REDUCTION as needed.
// For example, use a value of 2.0 for a 12-tooth spur gear driving a 24-tooth spur gear.
// This is gearing DOWN for less speed and more torque.
// For gearing UP, use a gear ratio less than 1.0. Note this will affect the direction of wheel rotation.
static final double COUNTS_PER_MOTOR_REV = 1440 ; // eg: TETRIX Motor Encoder
static final double DRIVE_GEAR_REDUCTION = 1.0 ; // No External Gearing.
static final double WHEEL_DIAMETER_INCHES = 4.0 ; // For figuring circumference
static final double COUNTS_PER_INCH = (COUNTS_PER_MOTOR_REV * DRIVE_GEAR_REDUCTION) /
(WHEEL_DIAMETER_INCHES * 3.1415);
static final double DRIVE_SPEED = 0.6;
static final double TURN_SPEED = 0.5;
@Override
public void runOpMode() {
// Initialize the drive system variables.
frontRight = hardwareMap.get(DcMotor.class, "frontRight");
backRight = hardwareMap.get(DcMotor.class, "backRight");
frontLeft = hardwareMap.get(DcMotor.class, "frontLeft");
backLeft = hardwareMap.get(DcMotor.class, "backRight");
// To drive forward, most robots need the motor on one side to be reversed, because the axles point in opposite directions.
// When run, this OpMode should start both motors driving forward. So adjust these two lines based on your first test drive.
// Note: The settings here assume direct drive on left and right wheels. Gear Reduction or 90 Deg drives may require direction flips
frontLeft.setDirection(DcMotor.Direction.REVERSE);
backLeft.setDirection(DcMotor.Direction.REVERSE);
frontRight.setDirection(DcMotor.Direction.FORWARD);
backRight.setDirection(DcMotor.Direction.FORWARD);
frontRight.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
backRight.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
frontLeft.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
backLeft.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
frontRight.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
backRight.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
frontLeft.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
backLeft.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
// Send telemetry message to indicate successful Encoder reset
telemetry.addData("Starting at", "%7d :%7d",
frontRight.getCurrentPosition(),
backRight.getCurrentPosition(),
frontLeft.getCurrentPosition(),
backLeft.getCurrentPosition());
telemetry.update();
// Wait for the game to start (driver presses PLAY)
waitForStart();
// Step through each leg of the path,
// Note: Reverse movement is obtained by setting a negative distance (not speed)
//test
encoderDrive(.8,1,1,1,1,7);
encoderDrive(DRIVE_SPEED, 48, 48, 5.0,5.0, 8);
telemetry.addData("Path", "Complete");
telemetry.update();
sleep(1000); // pause to display final telemetry message.
}
/*
* Method to perform a relative move, based on encoder counts.
* Encoders are not reset as the move is based on the current position.
* Move will stop if any of three conditions occur:
* 1) Move gets to the desired position
* 2) Move runs out of time
* 3) Driver stops the opmode running.
*/
public void encoderDrive(double speed, double backLeftInches, double backRightInches, double frontLeftInches, double frontRightInches, double timeoutS) {
int newBackRightTarget;
int newFrontRightTarget;
int newFrontLeftTarget;
int newBackLeftTarget;
// Ensure that the opmode is still active
if (opModeIsActive()) {
// Determine new target position, and pass to motor controller
newBackLeftTarget = backLeft.getCurrentPosition() + (int)(backLeftInches * COUNTS_PER_INCH);
newFrontRightTarget = frontRight.getCurrentPosition() + (int)(frontRightInches * COUNTS_PER_INCH);
newFrontLeftTarget = frontLeft.getCurrentPosition() + (int)(frontLeftInches * COUNTS_PER_INCH);
newBackRightTarget = backRight.getCurrentPosition() + (int)(backRightInches * COUNTS_PER_INCH);
backLeft.setTargetPosition(newBackLeftTarget);
frontRight.setTargetPosition(newFrontRightTarget);
frontLeft.setTargetPosition(newFrontLeftTarget);
backRight.setTargetPosition(newBackRightTarget);
// Turn On RUN_TO_POSITION
backLeft.setMode(DcMotor.RunMode.RUN_TO_POSITION);
frontRight.setMode(DcMotor.RunMode.RUN_TO_POSITION);
frontLeft.setMode(DcMotor.RunMode.RUN_TO_POSITION);
backRight.setMode(DcMotor.RunMode.RUN_TO_POSITION);
// reset the timeout time and start motion.
runtime.reset();
backLeft.setPower(Math.abs(speed));
frontRight.setPower(Math.abs(speed));
frontLeft.setPower(Math.abs(speed));
backRight.setPower(Math.abs(speed));
// keep looping while we are still active, and there is time left, and both motors are running.
// Note: We use (isBusy() && isBusy()) in the loop test, which means that when EITHER motor hits
// its target position, the motion will stop. This is "safer" in the event that the robot will
// always end the motion as soon as possible.
// However, if you require that BOTH motors have finished their moves before the robot continues
// onto the next step, use (isBusy() || isBusy()) in the loop test.
while (opModeIsActive() &&
(runtime.seconds() < timeoutS) &&
(backLeft.isBusy() && frontRight.isBusy() && frontLeft.isBusy() && backRight.isBusy())) {
// Display it for the driver.
telemetry.addData("Running to", " %7d :%7d", newBackLeftTarget, newBackRightTarget, newFrontLeftTarget, newFrontRightTarget);
telemetry.addData("Currently at", " at %7d :%7d",
backLeft.getCurrentPosition(), frontRight.getCurrentPosition(), frontLeft.getCurrentPosition(), backRight.getCurrentPosition());
telemetry.update();
}
// Stop all motion;
backLeft.setPower(0);
frontRight.setPower(0);
frontLeft.setPower(0);
backRight.setPower(0);
// Turn off RUN_TO_POSITION
backLeft.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
frontRight.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
frontLeft.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
backRight.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
sleep(250); // optional pause after each move.
}
}
}