Cpp Example: Custom Logging - mjansen4857/pathplanner GitHub Wiki

PathPlannerLib provides the ability to set custom logging callbacks that will be called when the built in path following commands are running. You can set these callbacks through the PathPlannerLogging class.

#include <pathplanner/lib/util/PathPlannerLogging.h>

using namespace pathplanner;

// Logging callback for current robot pose
PathPlannerLogging::setLogCurrentPoseCallback([](frc::Pose2d pose) -> {
    // Do whatever you want with the pose here
});

// Logging callback for target robot pose
PathPlannerLogging::setLogTargetPoseCallback([](frc::Pose2d pose) -> {
    // Do whatever you want with the pose here
});

// Logging callback for the active path, this is sent as a vector of poses
PathPlannerLogging::setLogActivePathCallback([](std::vector<frc::Pose2d> poses) -> {
    // Do whatever you want with the poses here
});