Skip to content

Live View

The TurtleTracerLiveView class is a utility that allows you to broadcast your robot's pose in real-time. This can be used to visualize your robot's movement on a dashboard or the TurtleTracer during autonomous or teleop routines.

TurtleTracerLiveView creates a lightweight TCP server on your robot controller that listens on port 8888. When a client (like TurtleTracer) connects, it streams the current robot pose (x, y, and heading) as JSON data.

  • Port: 8888
  • Protocol: TCP
  • Format: One JSON object per line (newline-delimited): {"x": <x>, "y": <y>, "heading": <heading>}
  • Units: x and y are inches in Pedro Pathing field coordinates, the same ones Turtle Tracer uses. heading is in radians.
  • Update Rate: ~20Hz (50ms interval)

If your pose provider throws (for example because the hardware was closed), the server sends {"error": "provider_error"} instead of a pose and keeps the connection open.

To use the Live View, you need to integrate it into your OpMode's lifecycle methods: init(), start(), and stop().

Here is a complete example of how to use TurtleTracerLiveView in an Autonomous OpMode.

package org.firstinspires.ftc.teamcode;
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.pedropathing.follower.Follower;
import com.pedropathing.math.Pose;
import com.turtletracerlib.TurtleTracerLiveView;
import org.firstinspires.ftc.teamcode.pedro.Constants;
@Autonomous(name = "Example Auto with Live View")
public class ExampleAuto extends LinearOpMode {
private Follower follower;
@Override
public void runOpMode() {
// Initialize your Follower as usual
follower = Constants.create(hardwareMap);
// 1. Start the Live View server
TurtleTracerLiveView.getInstance().start();
// 2. Link the Follower so Live View can read the pose
TurtleTracerLiveView.getInstance().setFollower(follower);
telemetry.addData("Status", "Initialized");
telemetry.update();
waitForStart();
// Your autonomous logic here...
// follower.follow(...);
while (opModeIsActive()) {
follower.update();
// Optional: Add telemetry to Driver Station
telemetry.addData("X", follower.pose().x());
telemetry.addData("Y", follower.pose().y());
telemetry.addData("Heading", follower.pose().heading());
telemetry.update();
}
// 3. Disable Live View when the OpMode stops to prevent memory leaks
TurtleTracerLiveView.getInstance().disable();
// optionally stop the server entirely if no other opmode needs it,
// though typically we let it run in the background.
// TurtleTracerLiveView.getInstance().stop();
}
}

If you are using a command-based framework (like FTCLib or the one built into TurtleTracerLib), you can integrate the Live View into your subsystem's periodic() method or initialize it in your OpMode.

Here is an example using a MecanumDrive subsystem:

public class MecanumDrive extends SubsystemBase {
private final Follower follower;
public MecanumDrive(HardwareMap hardwareMap) {
follower = Constants.create(hardwareMap);
// Start and link Live View in the constructor
TurtleTracerLiveView.getInstance().start();
TurtleTracerLiveView.getInstance().setFollower(follower);
}
@Override
public void periodic() {
// Update the follower each loop
follower.update();
// You don't need to manually update Live View here;
// it runs on its own thread and polls the follower.
}
public void stop() {
// Disable Live View when the subsystem is no longer needed
TurtleTracerLiveView.getInstance().disable();
}
}

And in your Command-Based OpMode:

@Autonomous(name = "Command Auto")
public class CommandAuto extends CommandOpMode {
private MecanumDrive drive;
@Override
public void initialize() {
drive = new MecanumDrive(hardwareMap);
// ... register other subsystems and schedule commands
}
@Override
public void runOpMode() {
initialize();
waitForStart();
// Run the scheduler
while (opModeIsActive()) {
run();
}
// Clean up
drive.stop();
reset();
}
}

Starts the background server thread if it's not already running. This method is safe to call multiple times; if the server is already running, it does nothing.

TurtleTracerLiveView.getInstance().start();

Links the Follower instance to the Live View. The server will automatically query this follower for the robot's current pose.

TurtleTracerLiveView.getInstance().setFollower(follower);

Disables the telemetry stream by clearing the reference to the follower. This should be called in your OpMode's cleanup phase (e.g., after the loop finishes) to ensure the server doesn't try to access a follower that has been destroyed.

TurtleTracerLiveView.getInstance().disable();

For advanced users, you can provide a custom supplier if you are not using the standard Follower class or want to manipulate the data before sending it.

TurtleTracerLiveView.getInstance().setPoseProvider(() -> {
// Return a custom Pose object
return new Pose(10, 20, Math.toRadians(90));
});

Once your robot is running the OpMode:

  1. Ensure your computer is connected to the robot's Wi-Fi network.
  2. Open the TurtleTracer desktop app. Connecting to a robot needs the desktop app; the browser version cannot open the socket.
  3. Open the Telemetry tab in the control panel. If it is missing, turn on Show Live Telemetry Tab in Settings > General.
  4. Choose TCP (TurtleTracerLib), enter the Robot Controller's IP address and port 8888, then click Connect. The defaults are 192.168.43.1 (the Control Hub's own Wi-Fi network) and 8888.

Once the status reads CONNECTED, the live robot is drawn on the field and its values appear in the Telemetry Data table. The tab also supports WebSocket (Panels), which defaults to port 8082; that mode is for Panels and doesn't use TurtleTracerLiveView.

Note: Ensure your firewall allows connections on port 8888.