Exploit database

GH-543245c9a789cf0701d8058269007301

22817-knotbot/ftc-rc-2025

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2019-11358

1,181 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files8

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

TeamCode/src/main/java/org/firstinspires/ftc/teamcode/auto/AutoManager.java

Java · 6,054 bytes
package org.firstinspires.ftc.teamcode.auto;

import java.util.ArrayList;
import java.util.List;

import org.firstinspires.ftc.teamcode.auto.AutoComponents.AutoAction;
import org.firstinspires.ftc.teamcode.auto.AutoComponents.AutoActionCommand;
import org.firstinspires.ftc.teamcode.auto.AutoComponents.AutoState;
import org.firstinspires.ftc.teamcode.auto.AutoComponents.StartAutoState;
import org.firstinspires.ftc.teamcode.pedroPathing.Constants;
import org.firstinspires.ftc.teamcode.teleop.Automations;
import org.firstinspires.ftc.teamcode.util.Alliance;
import org.firstinspires.ftc.teamcode.util.BlueAlliance;
import org.firstinspires.ftc.teamcode.util.Drawing;
import org.firstinspires.ftc.teamcode.util.TelemetryManager;

import com.pedropathing.follower.Follower;
import com.pedropathing.geometry.Pose;
import com.pedropathing.paths.PathChain;
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import com.qualcomm.robotcore.hardware.HardwareMap;

public class AutoManager {
	private Alliance alliance;
	private AutoComponents components;

	private Follower follower;
	private Automations automationHandler;
	private List<AutoAction> autoActions;

	private boolean initialized = false;
	private boolean startedFollowingPath;
	private boolean startedActionCommand;
	private AutoActionCommand currentActionCommand;
	private boolean stateFinished;
	private List<PathChain> pathList;
	private List<Boolean> holdEndPoseList;
	private int currentState = 0;

	public AutoManager(Alliance alliance) {
		this.alliance = alliance;
		this.components = new AutoComponents(alliance);
	}

	public void initialize(HardwareMap hardwareMap, StartAutoState startAutoState, List<AutoAction> autoActions) {
		if (initialized)
			return;
		this.follower = Constants.createFollower(hardwareMap);
		Pose startPose = startAutoState.getStartPose();
		if (alliance instanceof BlueAlliance) {
			startPose = startPose.mirror();
		}
		this.follower.setStartingPose(startPose);
		this.automationHandler = new Automations(hardwareMap, alliance, true);
		this.autoActions = autoActions;
		this.stateFinished = false;

		this.pathList = new ArrayList<>();
		this.holdEndPoseList = new ArrayList<>();
		Pose previousPose = startPose;
		for (AutoAction autoAction : autoActions) {
			PathChain newPathChain = autoAction.getPathChain(follower, previousPose);
			this.pathList.add(newPathChain);
			this.holdEndPoseList.add(autoAction.holdEndPose());
			if (newPathChain != null) {
				previousPose = newPathChain.endPose();
			}
		}
	}

	public StartAutoState[] getStartingStates() {
		return new StartAutoState[] {
				components.new StartLowState(),
				components.new StartUpState(),
		};
	}

	public static List<AutoAction> getAutoActionsByClasses(AutoState startingState, List<Class<? extends AutoAction>> classes) {
		List<AutoAction> autoActions = new ArrayList<>();
		AutoState currentState = startingState;
		for (Class<? extends AutoAction> clazz : classes) {
			boolean found = false;
			for (AutoAction autoAction : currentState.getAutoActions()) {
				if (clazz.isInstance(autoAction)) {
					autoActions.add(autoAction);
					currentState = autoAction.getResultingState();
					found = true;
					break;
				}
			}
			if (!found) {
				throw new IllegalArgumentException(
						"No auto action of class " + clazz.getSimpleName() + " found in state " + currentState.getClass().getSimpleName());
			}
		}
		return autoActions;
	}

	public void start() {
		automationHandler.start();
	}

	public void update() {
		if (currentState < 0)
			return;
		updatePathFollowing();
		updateCommands();

		if (stateFinished) {
			if (currentState + 1 < autoActions.size()) {
				setState(currentState + 1);
			} else {
				setState(-1);
			}
		}
	}

	public void updateCommands() {
		automationHandler.updatePose(follower.getPose());
		automationHandler.updateVelocity(follower.getVelocity());
		automationHandler.updateTurret();
		automationHandler.updateShooter();
		automationHandler.automationLoop();

		if (stateFinished)
			return;
		if (!startedActionCommand) {
			currentActionCommand = autoActions.get(currentState).getActionCommand();
			startedActionCommand = true;
		}
		if (startedActionCommand && currentActionCommand != null) {
			stateFinished = currentActionCommand.run(follower, automationHandler);
		}
	}

	public void updatePathFollowing() {
		follower.update();
		if (!startedFollowingPath) {
			if (currentState < pathList.size()) {
				PathChain currentPath = pathList.get(currentState);
				if (currentPath != null) {
					follower.followPath(currentPath, holdEndPoseList.get(currentState));
				}
			}
			startedFollowingPath = true;
		}
	}

	public void end() {
		automationHandler.end();
		OpMode.blackboard.put("alliance", alliance);
		OpMode.blackboard.put("pose", follower.getPose());
	}

	private void setState(int state) {
		currentState = state;
		startedFollowingPath = false;
		startedActionCommand = false;
		stateFinished = false;
	}

	public List<AutoAction> getAutoActions() {
		return new ArrayList<>(autoActions);
	}

	public void showTelemetry(TelemetryManager telemetryManager) {
		telemetryManager.addData("State", currentState);
		telemetryManager.addData("Current action", autoActions.get(currentState).getNameString());
		telemetryManager.addData("Automations state", automationHandler.getState());

		Drawing.drawRobot(follower.getPose(), telemetryManager.getDashboardCanvas());
		Drawing.sendPacket();
	}

	public void showAutomationsTelemetry(TelemetryManager telemetryManager) {
		automationHandler.showTelemetry(telemetryManager);
	}

	public void showFollowerTelemetry(TelemetryManager telemetryManager) {
		telemetryManager.addData("Follower busy", follower.isBusy());
		telemetryManager.addData("Following", pathList.get(currentState));
		String[] debugLines = null;
		try {
			debugLines = follower.debug();
		} catch (Exception e) {
			telemetryManager.addLine("Failed to retrieve debug string!");
		}
		if (debugLines != null) {
			for (String line : debugLines) {
				telemetryManager.addLine(line);
			}
		}

	}
}