mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[examples] Fix memory leak in C++ controller command examples (#6306)
This commit is contained in:
@@ -111,8 +111,8 @@ frc2::CommandPtr RobotContainer::GetAutonomousCommand() {
|
||||
// command, then stop at the end.
|
||||
return frc2::cmd::Sequence(
|
||||
frc2::InstantCommand(
|
||||
[this, &exampleTrajectory]() {
|
||||
m_drive.ResetOdometry(exampleTrajectory.InitialPose());
|
||||
[this, initialPose = exampleTrajectory.InitialPose()]() {
|
||||
m_drive.ResetOdometry(initialPose);
|
||||
},
|
||||
{})
|
||||
.ToPtr(),
|
||||
|
||||
@@ -84,8 +84,8 @@ frc2::CommandPtr RobotContainer::GetAutonomousCommand() {
|
||||
// Reset odometry to the initial pose of the trajectory, run path following
|
||||
// command, then stop at the end.
|
||||
return frc2::cmd::RunOnce(
|
||||
[this, &exampleTrajectory] {
|
||||
m_drive.ResetOdometry(exampleTrajectory.InitialPose());
|
||||
[this, initialPose = exampleTrajectory.InitialPose()] {
|
||||
m_drive.ResetOdometry(initialPose);
|
||||
},
|
||||
{})
|
||||
.AndThen(std::move(ramseteCommand))
|
||||
|
||||
@@ -93,8 +93,8 @@ frc2::CommandPtr RobotContainer::GetAutonomousCommand() {
|
||||
// command, then stop at the end.
|
||||
return frc2::cmd::Sequence(
|
||||
frc2::InstantCommand(
|
||||
[this, &exampleTrajectory]() {
|
||||
m_drive.ResetOdometry(exampleTrajectory.InitialPose());
|
||||
[this, initialPose = exampleTrajectory.InitialPose()]() {
|
||||
m_drive.ResetOdometry(initialPose);
|
||||
},
|
||||
{})
|
||||
.ToPtr(),
|
||||
|
||||
Reference in New Issue
Block a user