Skip to content

Commit 1f48b30

Browse files
leander-dsouzaSteveMacenski
authored andcommitted
Prevent MPPI controller from resetting speed limits upon goal execution. (#5165)
Signed-off-by: Leander Stephen D'Souza <[email protected]>
1 parent 7e9b250 commit 1f48b30

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

nav2_mppi_controller/include/nav2_mppi_controller/optimizer.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,9 @@ class Optimizer
119119

120120
/**
121121
* @brief Reset the optimization problem to initial conditions
122+
* @param Whether to reset the constraints to its base values
122123
*/
123-
void reset();
124+
void reset(bool reset_dynamic_speed_limits = true);
124125

125126
protected:
126127
/**

nav2_mppi_controller/src/controller.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void MPPIController::deactivate()
7171

7272
void MPPIController::reset()
7373
{
74-
optimizer_.reset();
74+
optimizer_.reset(false /*Don't reset zone-based speed limits between requests*/);
7575
}
7676

7777
geometry_msgs::msg::TwistStamped MPPIController::computeVelocityCommands(

nav2_mppi_controller/src/optimizer.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void Optimizer::setOffset(double controller_frequency)
126126
}
127127
}
128128

129-
void Optimizer::reset()
129+
void Optimizer::reset(bool reset_dynamic_speed_limits)
130130
{
131131
state_.reset(settings_.batch_size, settings_.time_steps);
132132
control_sequence_.reset(settings_.time_steps);
@@ -135,7 +135,9 @@ void Optimizer::reset()
135135
control_history_[2] = {0.0f, 0.0f, 0.0f};
136136
control_history_[3] = {0.0f, 0.0f, 0.0f};
137137

138-
settings_.constraints = settings_.base_constraints;
138+
if (reset_dynamic_speed_limits) {
139+
settings_.constraints = settings_.base_constraints;
140+
}
139141

140142
costs_ = xt::zeros<float>({settings_.batch_size});
141143
generated_trajectories_.reset(settings_.batch_size, settings_.time_steps);

0 commit comments

Comments
 (0)