Skip to content

Create PoseRecorder.java#78

Open
aryanmathur1 wants to merge 2 commits into
Pedro-Pathing:masterfrom
aryanmathur1:master
Open

Create PoseRecorder.java#78
aryanmathur1 wants to merge 2 commits into
Pedro-Pathing:masterfrom
aryanmathur1:master

Conversation

@aryanmathur1

@aryanmathur1 aryanmathur1 commented Jul 20, 2026

Copy link
Copy Markdown

By Metal Magic FTC 23362

We added a TeleOp for authoring field coordinates by moving the robot instead of measuring the field by hand. Set a starting pose in code, then drag or drive the robot around the field and press a button to capture the robot's current pose. Captures show up in a numbered, copy-pasteable list on the Driver Station, and a save button writes the whole list to a text file on the Robot Controller so they drop straight into path code.

It's one concrete OpMode in org.firstinspires.ftc.teamcode.pedroPathing, alongside the existing Tuning OpModes. PoseRecorder is a self-contained @TELEOP. All gamepad reading and telemetry rendering live directly in the OpMode, and button rising-edges use the FTC SDK's built-in gamepad1.aWasPressed() / bWasPressed() / xWasPressed() / yWasPressed() detection. Each loop it drives via follower.setTeleOpDrive(...) so the robot can be driven or hand-dragged, captures follower.getPose(), and renders the live pose plus the recorded list. Pressing X writes every captured pose to a file using the SDK's ReadWriteFile, so teams don't need logcat. Teams edit two things in the class: the startingPose field and the Constants.createFollower(hardwareMap) line, plus an optional OUTPUT_PATH.

The save file defaults to the FTC FIRST folder (/sdcard/FIRST/pose_recorder.txt), which every Control Hub and RC phone already has. OUTPUT_PATH can be edited to put the file anywhere the app can write. Telemetry shows the current save path and a save status line, so you get confirmation right on the Driver Station.

Poses are captured in the follower's native Pedro coordinate frame. Compiles against the existing SDK and Pedro com.pedropathing:ftc:2.1.2 dependencies, no build changes. @Utility isn't available in this repo's dependencies (checked RobotCore 11.1.0 and the full fullpanels:1.0.12 tree), so this uses @TELEOP.

To use, just edit the two lines in the class:

@TeleOp(name = "Pose Recorder", group = "Pedro Pathing")
public class PoseRecorder extends OpMode {
    // where the robot starts
    public Pose startingPose = new Pose(9, 111, Math.toRadians(90));

    @Override
    public void init() {
        follower = Constants.createFollower(hardwareMap); // your normal follower setup
        follower.setStartingPose(startingPose);
    }
    // ...
}

on the gamepad:

  • A to capture current pose
  • B to undo last
  • X to save all captured poses to the file
  • Back + Y to clear all

then get the file onto your computer:

  • Android Studio: adb pull /sdcard/FIRST/pose_recorder.txt (adjust to your OUTPUT_PATH)
  • OnBot Java or no adb: plug the Control Hub or RC phone into your computer over USB and browse to the FIRST folder

the file holds lines you can copypaste like new Pose(12.00, 34.00, Math.toRadians(90.00)).

By Metal Magic FTC 23362

We added a TeleOp for authoring field coordinates by moving the robot instead of measuring the field by hand. Set a starting pose in code, then drag or drive the robot around the field and press a button to capture the robot's current pose. Captures accumulate in a numbered, copy-pasteable list on the Driver Station and stream to the coding computer via adb logcat, so they drop straight into path code.
@Tyler-Stocks

Copy link
Copy Markdown

This looks a lot better!

The final suggestion I have is moving away from logcat for storing the poses. What if instead of writing each of the captured poses to the log when the are recorded, you have a button to save all of them to a file?

You could have a PATH variable that defaults to something sensible (maybe OnBot java so it can be accessed by less advanced teams?) which can then be edited to put he logs wherever.

I think that would make it more approachable for teams that don't have much experience with logcat.

Changed saving from logcat to:
Buttons are now: A capture, B undo, X save, Back+Y clear.

Retrieving the file (documented in the class Javadoc):

Android Studio teams: adb pull /sdcard/FIRST/pose_recorder.txt
OnBot Java / no adb: plug the Control Hub or RC phone into the computer over USB and browse to the FIRST folder (the exact on-robot path is shown live in telemetry).
@aryanmathur1

Copy link
Copy Markdown
Author

Thanks again for the feedback. I updated it so:

Buttons are now: A capture, B undo, X save, Back+Y clear.

Retrieving the file (documented in the class Javadoc):

  • Android Studio teams: adb pull /sdcard/FIRST/pose_recorder.txt
  • OnBot Java / no adb: plug the Control Hub or RC phone into the computer over USB and browse to the FIRST folder (the exact on-robot path is shown live in telemetry).

I couldn't think of a better way to do this, so lmk if you have any other suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants