Path Planner RamseteAutoBuilder in C++ Robot Crashing

I am trying to implement the Path Planner RamseteAutoBuilder into my project, but am having some issues. When I attempt to run auto, the program seems to crash and then restart. There are also no messages in the console when this occurs. I talked to Michael the developer of Path Planner and we could not come up with a solution yet. I was hoping somebody else might have an idea. Here is the code in the GetAutonomousCommand for Path Planner and the code in AutonomousInit as well.

frc2::CommandPtr RobotContainer::GetAutonomousCommand() {
    std::vector<pathplanner::PathPlannerTrajectory> traj = pathplanner::PathPlanner::loadPathGroup(m_autoChooser.GetSelected(), {pathplanner::PathConstraints(4_mps, 3_mps_sq)});
    pathplanner::RamseteAutoBuilder ramseteCommand{[this]() {return m_drivetrain.GetPose();}, 
                                                   [this] (frc::Pose2d pose) {m_drivetrain.ResetOdometry(pose);}, 
                                                   frc::RamseteController{DriveConstants::kRamseteB * 1_rad * 1_rad / (1_m * 1_m),
                                                                          DriveConstants::kRamseteZeta / 1_rad}, 
                                                   frc::SimpleMotorFeedforward<units::meters>{DriveConstants::kS, DriveConstants::kV, DriveConstants::kA}, 
                                                   [this] {return m_drivetrain.GetWheelSpeed();},
                                                   {DriveConstants::kPDriveVel, 0, 0},
                                                   [this] (auto left, auto right) {m_drivetrain.DriveVolts(left, right);},
                                                   {&m_drivetrain}, false};
    return ramseteCommand.fullAuto(traj);

It’s worth noting that m_autoChooser pulls from a list of strings that are selected via the dashboard to choose the desired autonomous.

void Robot::AutonomousInit() {
  m_autonomousCommand = m_container.GetAutonomousCommand();
  if (m_autonomousCommand) {

Nothing is in the RioLog? Or are you talking about the DS console?

You might try doing remote debugging (wpilib debug robot code) to help find the crash.

As far as I can tell, the issue is likely that you’re letting the RamseteAutoBuilder go out of scope. From its implementation, there are “this” captures inside of it (e.g. in BaseAutoBuilder::resetPose()), so you need to not let it go out of scope as long as the returned command exists.

What’s the best way of making sure it stays in scope?

Both the DS console and the RioLog.

Make it a member variable of the container.

That seemed to fix it. Thanks!