Exploit databaseDownload repository ZIP
GH-dd4906bb4a91bc33b2b535e24206b810
15465-krash/krash_2023_centerstage
Sources for CVE-2019-11358
1,181 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files14
15465-krash/krash_2023_centerstageRevision 8df4f2602687
- ↑..Parent directory
- ARCHIVE/
- Auto/
- DriveTrain/
- OpModes/
- processors/
- trajectorysequence/
- util/
- visiontests/
- Arm.java
- Climber.java
- DistanceSensor.java
- DroneLauncher.java
- Robot.java
- readme.md
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Arm.java
Suggested starting fileJava · 10,910 bytespackage org.firstinspires.ftc.teamcode;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.DcMotorEx;
import com.qualcomm.robotcore.hardware.DcMotorSimple;
import com.qualcomm.robotcore.hardware.HardwareMap;
import com.qualcomm.robotcore.hardware.Servo;
import com.qualcomm.robotcore.util.ElapsedTime;
import org.firstinspires.ftc.robotcore.external.Telemetry;
import org.firstinspires.ftc.teamcode.util.Encoder;
import org.firstinspires.ftc.teamcode.util.Utils;
import org.slf4j.helpers.Util;
import static org.firstinspires.ftc.teamcode.util.Utils.sleep;
public class Arm {
public Servo gripper, ejector, swivel;
public DcMotorEx shoulder;
public DcMotorEx extension;
public Encoder shoulderEncoder;
public Encoder extensionEncoder;
public boolean zeroingArm = false;
private Telemetry telemetry;
final double GRIPPER_RELEASE = 0;
final double GRIPPER_RELEASE_ONE = 0.07;
final double GRIPPER_HOLD_ALL = 0.1;
final double WIGGLE_WIGGLE = 0.04; //was +/-0.07
final double WIGGLE_DELAY = 0.250;
final double PUSHER_RETRACT = 0; //1.0
final double PUSHER_PUSH1 =0.65;
final double PUSHER_PUSH2 = 0.55;
final double SWIVEL_READY = 0.14;
final double SWIVEL_PICKUP = 0.21;
final double SWIVEL_PLACE_FRONT = 0.28;
final double SWIVEL_HOLD = 0.85;
final double SWIVEL_BACK_LOW = 0.61;
final double SWIVEL_BACK_HIGH = 0.74;
final int ARM_MIN = 0;
final int ARM_MIN_SLOW = 400;
final int ARM_MAX_SLOW = 5300;
final int ARM_MAX = 6500;
final int EXTENSION_MIN = 0;
final int EXTENSION_MIN_SLOW = 75;
final int EXTENSION_MAX_SLOW = 425;
final int EXTENSION_MAX = 450;
final int ARM_READY_PICKUP = 500;
final int EXTENSION_READY_PICKUP = 40;
final int ARM_PICKUP = 0;
public final int EXTENSION_PICKUP = 75;
final int ARM_DELIVER_BACK = 4350;
final int EXTENSION_DELIVER_BACK = 250;
final int ARM_DELIVER_FRONT = 1000; // 1100
public final int EXTENSION_DELIVER_FRONT = 390; //400
final int ARM_DELIVER_FRONT_HIGH = 1150; // 1100
public final int EXTENSION_DELIVER_FRONT_HIGH = 390; //400
final int ARM_PIXEL_SPIKE = 460;
final int EXTENSION_PIXEL_SPIKE = 370;
boolean inPickupSequence = false;
ElapsedTime timer = new ElapsedTime();
public boolean haveTwo = false;
public enum Arm_Modes {
PICKUP,
HOLD,
DELIVER_FRONT,
DELIVER_BACK_LOW,
DELIVER_BACK_HIGH,
MANUAL
}
public Arm(HardwareMap hardwareMap, Telemetry telemetry){
this.telemetry = telemetry;
gripper = hardwareMap.get(Servo.class, "gripper");
ejector = hardwareMap.get(Servo.class, "ejector");
swivel = hardwareMap.get(Servo.class, "swivel");
shoulder = hardwareMap.get(DcMotorEx.class,"shoulder");
shoulder.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
shoulder.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
extension = hardwareMap.get(DcMotorEx.class,"extension");
extension.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
extension.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
extension.setDirection(DcMotorSimple.Direction.REVERSE);
shoulderEncoder = new Encoder(hardwareMap.get(DcMotorEx.class, "shoulder"));
extensionEncoder = new Encoder(hardwareMap.get(DcMotorEx.class, "extension"));
extensionEncoder.setDirection(Encoder.Direction.REVERSE);
}
public void setGripper(double pos){
gripper.setPosition(pos);
}
public void setPusher(double pos){
ejector.setPosition(pos);
}
public void setSwivel(double pos) {
swivel.setPosition(pos);
}
public void gripperRelease(){
setGripper(GRIPPER_RELEASE);
}
public void gripperReleaseOne(){
setGripper(GRIPPER_RELEASE_ONE);
}
public void gripperHoldAll(){
setGripper(GRIPPER_HOLD_ALL);
}
public void pusherRetract(){
setPusher(PUSHER_RETRACT);
}
public void pusherPush1(){
setPusher(PUSHER_PUSH1);
}
public void pusherPush2(){
setPusher(PUSHER_PUSH2);
}
public void swivelPickup(){setSwivel(SWIVEL_PICKUP);}
public void swivelReady(){setSwivel(SWIVEL_READY);}
public void swivelHold(){setSwivel(SWIVEL_HOLD);}
public void readyDeliverBackLow(){setSwivel(SWIVEL_BACK_LOW);}
public void readyDeliverFront(boolean extend) {
setSwivel(SWIVEL_PLACE_FRONT);
runShoulderToPosition(ARM_DELIVER_FRONT);
if (extend) {
runExtensionToPosition(EXTENSION_DELIVER_FRONT);
} else {
runExtensionToPosition(EXTENSION_DELIVER_FRONT - 90);
}
}
public void readyDeliverFrontHigh(){
setSwivel(SWIVEL_PLACE_FRONT);
runShoulderToPosition(ARM_DELIVER_FRONT_HIGH);
runExtensionToPosition(EXTENSION_DELIVER_FRONT_HIGH);
}
public void readyDeliverBackHigh(){
setSwivel(SWIVEL_BACK_HIGH);
runShoulderToPosition(ARM_DELIVER_BACK);
runExtensionToPosition(EXTENSION_DELIVER_BACK);
}
public void readyPickup(boolean gripperEngaged){
runShoulderToPosition(ARM_READY_PICKUP);
runExtensionToPosition(EXTENSION_READY_PICKUP);
pusherRetract();
if(!gripperEngaged){
gripperRelease();
clearHaveTwo();
}
swivelReady();
}
public void drop1(){
gripperReleaseOne();
pusherPush1();
}
public void drop2(){
gripperRelease();
pusherPush2();
}
public void drop(){
if(haveTwo){
drop1();
clearHaveTwo();
} else {
drop2();
}
}
public void safePosition(){
gripperRelease();
pusherRetract();
}
public void pickup(){
gripperHoldAll();
setHaveTwo();
}
public void wiggle(){
double currentPos = swivel.getPosition();
setSwivel(currentPos-WIGGLE_WIGGLE);
sleep((long)(WIGGLE_DELAY*1000));
setSwivel(currentPos+WIGGLE_WIGGLE);
sleep((long)(WIGGLE_DELAY*1000));
setSwivel(currentPos);
}
public double getShoulderPosition(){
return shoulderEncoder.getCurrentPosition();
}
public double getExtensionPosition(){
return extensionEncoder.getCurrentPosition();
}
public void runShoulder(double power){
shoulder.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
shoulder.setPower(limitPower(power, ARM_MIN, ARM_MIN_SLOW, ARM_MAX, ARM_MAX_SLOW, shoulderEncoder));
}
public void runShoulderUnlimited(double power){
shoulder.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
shoulder.setPower(power);
}
public void runExtension(double power){
extension.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
extension.setPower(limitPower(power, EXTENSION_MIN, EXTENSION_MIN_SLOW, EXTENSION_MAX, EXTENSION_MAX_SLOW, extensionEncoder));
}
public void runSwivel(double power){
double currentPos = swivel.getPosition();
swivel.setPosition(currentPos + power / 100);
}
public double limitPower(double power, int min, int minSlow, int max, int maxSlow, Encoder encoder){
double slow = 0.3;
int pos = encoder.getCurrentPosition();
// if(isInRange(pos, minSlow, maxSlow)){
// return power;
// } else
if ((power >= 0) && isInRange(pos, maxSlow, max)){
return power*slow;
} else if ((power >=0) && (pos >= max)){
return 0;
} else if ((power < 0) && isInRange(pos, min, minSlow)){
return power*slow;
} else if ((power < 0) && (pos <= min)){
return 0;
} else {
return power;
}
}
public boolean isInRange(int val, int min, int max){
return (val >= min) && (val <= max);
}
public void runShoulderToPosition(int target){
shoulder.setTargetPosition(target);
shoulder.setMode(DcMotor.RunMode.RUN_TO_POSITION);
shoulder.setPower(1.0);
}
public void runExtensionToPosition(int target){
extension.setTargetPosition(target);
extension.setMode(DcMotor.RunMode.RUN_TO_POSITION);
extension.setPower(1.0);
}
public void setInPickupSequence(){
inPickupSequence = true;
}
public void clearInPickupSequence(){
inPickupSequence = false;
}
public boolean getInPickupSequencec(){
return inPickupSequence;
}
public void pickupSequence(){
double WIGGLE_HOLD = 0.25;
if (!inPickupSequence){
setInPickupSequence();
gripperRelease();
timer.reset();
runShoulderToPosition(ARM_PICKUP);
runExtensionToPosition(EXTENSION_PICKUP);
swivelPickup();
clearHaveTwo();
} else {
double time = timer.seconds();
if(time>WIGGLE_HOLD){
double wiggleCount = Math.floor((time - WIGGLE_HOLD) / WIGGLE_DELAY);
if(wiggleCount % 2 == 0){
setSwivel(SWIVEL_PICKUP-WIGGLE_WIGGLE);
} else {
setSwivel(SWIVEL_PICKUP+WIGGLE_WIGGLE);
}
}
}
}
public void pixelSpikeReady() {
swivelPickup();
runShoulderToPosition(ARM_PIXEL_SPIKE);
runExtensionToPosition(EXTENSION_PIXEL_SPIKE);
}
public void pixelHold() {
swivelHold();
runShoulderToPosition(ARM_READY_PICKUP);
runExtensionToPosition(EXTENSION_READY_PICKUP);
}
public void setHaveTwo(){
haveTwo = true;
}
public void clearHaveTwo(){
haveTwo = false;
}
public void drop1Flat(){
drop1();
}
public void autoInit(){
shoulder.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
extension.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
swivelHold();
pusherRetract();
sleep(500);
gripperHoldAll();
resetShoulderEncoder();
}
public void zeroShoulder(){
zeroingArm = true;
runShoulderUnlimited(-0.1);
}
public void resetShoulderEncoder(){
shoulder.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
}
public void backoffShoulder(){
int posOffset = 200;
int currentPos = shoulderEncoder.getCurrentPosition();
int targetPos = currentPos;
if(currentPos > 3000){
posOffset = -posOffset;
}
targetPos = currentPos + posOffset;
runShoulderToPosition(targetPos);
}
}