diff --git a/nav2_mppi_controller/README.md b/nav2_mppi_controller/README.md
index 68db5b73719..4fd16fb2e58 100644
--- a/nav2_mppi_controller/README.md
+++ b/nav2_mppi_controller/README.md
@@ -38,28 +38,29 @@ This process is then repeated a number of times and returns a converged solution
## Configuration
### Controller
- | Parameter | Type | Definition |
- | --------------------- | ------ | -------------------------------------------------------------------------------------------------------- |
- | motion_model | string | Default: DiffDrive. Type of model [DiffDrive, Omni, Ackermann]. |
- | critics | string | Default: None. Critics (plugins) names |
- | iteration_count | int | Default 1. Iteration count in MPPI algorithm. Recommend to keep as 1 and prefer more batches. |
- | batch_size | int | Default 1000. Count of randomly sampled candidate trajectories |
- | time_steps | int | Default 56. Number of time steps (points) in each sampled trajectory |
- | model_dt | double | Default: 0.05. Time interval (s) between two sampled points in trajectories. |
- | vx_std | double | Default 0.2. Sampling standard deviation for VX |
- | vy_std | double | Default 0.2. Sampling standard deviation for VY |
- | wz_std | double | Default 0.4. Sampling standard deviation for Wz |
- | vx_max | double | Default 0.5. Max VX (m/s) |
- | vy_max | double | Default 0.5. Max VY in either direction, if holonomic. (m/s) |
- | vx_min | double | Default -0.35. Min VX (m/s) |
- | wz_max | double | Default 1.9. Max WZ (rad/s) |
- | temperature | double | Default: 0.3. Selectiveness of trajectories by their costs (The closer this value to 0, the "more" we take in consideration controls with less cost), 0 mean use control with best cost, huge value will lead to just taking mean of all trajectories without cost consideration |
- | gamma | double | Default: 0.015. A trade-off between smoothness (high) and low energy (low). This is a complex parameter that likely won't need to be changed from the default of `0.1` which works well for a broad range of cases. See Section 3D-2 in "Information Theoretic Model Predictive Control: Theory and Applications to Autonomous Driving" for detailed information. |
- | visualize | bool | Default: false. Publish visualization of trajectories, which can slow down the controller significantly. Use only for debugging. |
- | retry_attempt_limit | int | Default 1. Number of attempts to find feasible trajectory on failure for soft-resets before reporting failure. |
- | regenerate_noises | bool | Default false. Whether to regenerate noises each iteration or use single noise distribution computed on initialization and reset. Practically, this is found to work fine since the trajectories are being sampled stochastically from a normal distribution and reduces compute jittering at run-time due to thread wake-ups to resample normal distribution. |
+ | Parameter | Type | Definition |
+ |----------------------------------|--------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+ | motion_model | string | Default: DiffDrive. Type of model [DiffDrive, Omni, Ackermann]. |
+ | critics | string | Default: None. Critics (plugins) names |
+ | iteration_count | int | Default 1. Iteration count in MPPI algorithm. Recommend to keep as 1 and prefer more batches. |
+ | batch_size | int | Default 1000. Count of randomly sampled candidate trajectories |
+ | time_steps | int | Default 56. Number of time steps (points) in each sampled trajectory |
+ | model_dt | double | Default: 0.05. Time interval (s) between two sampled points in trajectories. |
+ | vx_std | double | Default 0.2. Sampling standard deviation for VX |
+ | vy_std | double | Default 0.2. Sampling standard deviation for VY |
+ | wz_std | double | Default 0.4. Sampling standard deviation for Wz |
+ | vx_max | double | Default 0.5. Max VX (m/s) |
+ | vy_max | double | Default 0.5. Max VY in either direction, if holonomic. (m/s) |
+ | vx_min | double | Default -0.35. Min VX (m/s) |
+ | wz_max | double | Default 1.9. Max WZ (rad/s) |
+ | temperature | double | Default: 0.3. Selectiveness of trajectories by their costs (The closer this value to 0, the "more" we take in consideration controls with less cost), 0 mean use control with best cost, huge value will lead to just taking mean of all trajectories without cost consideration |
+ | gamma | double | Default: 0.015. A trade-off between smoothness (high) and low energy (low). This is a complex parameter that likely won't need to be changed from the default of `0.1` which works well for a broad range of cases. See Section 3D-2 in "Information Theoretic Model Predictive Control: Theory and Applications to Autonomous Driving" for detailed information. |
+ | visualize | bool | Default: false. Publish visualization of trajectories, which can slow down the controller significantly. Use only for debugging. |
+ | retry_attempt_limit | int | Default 1. Number of attempts to find feasible trajectory on failure for soft-resets before reporting failure. |
+ | regenerate_noises | bool | Default false. Whether to regenerate noises each iteration or use single noise distribution computed on initialization and reset. Practically, this is found to work fine since the trajectories are being sampled stochastically from a normal distribution and reduces compute jittering at run-time due to thread wake-ups to resample normal distribution. |
| publish_optimal_trajectory | bool | Publishes the full optimal trajectory sequence each control iteration for downstream control systems, collision checkers, etc to have context beyond the next timestep. |
-
+ | advanced.wz_std_decay_strength | double | Default: -1.0 (disabled). Defines the strength of the reduction function.
`wz_std_decay_strength` and `wz_std_decay_to` defines a function that enables dynamic modification of wz_std (angular deviation) based on linear velocity of the robot.
When a robot with high inertia (e.g. 500kg) is moving fast and if wz_std is above 0.3, oscillation behavior can be observed. Lowering wz_std stabilizes the robot but then the maneuvers take more time.
Dynamically reducing wz_std as vx, vy increase (speed of the robot) solves both problems.
Suggested values to start with are: `wz_std = 0.4, wz_std_decay_to = 0.05, wz_std_decay_strength = 3.0`
The following is used as the decay function
`f(x) = (wz_std - wz_std_decay_to) * e^(-wz_std_decay_strength * v_linear) + wz_std_decay_to`
[Visualize the decay function here](https://www.wolframalpha.com/input?i=plot+%5B%28a-b%29+*+e%5E%28-c+*+x%29+%2B+b%5D+with+a%3D0.5%2C+b%3D0.05%2C+c%3D3) |
+ | advanced.wz_std_decay_to | double | Default: 0.0. Target wz_std value while linear speed goes to infinity. Must be between 0 and wz_std. Has no effect if `advanced.wz_std_decay_strength` <= 0.0 |
#### Trajectory Visualizer
| Parameter | Type | Definition |
diff --git a/nav2_mppi_controller/include/nav2_mppi_controller/models/constraints.hpp b/nav2_mppi_controller/include/nav2_mppi_controller/models/constraints.hpp
index bd8b972473d..5626b461776 100644
--- a/nav2_mppi_controller/include/nav2_mppi_controller/models/constraints.hpp
+++ b/nav2_mppi_controller/include/nav2_mppi_controller/models/constraints.hpp
@@ -35,6 +35,30 @@ struct ControlConstraints
float az_max;
};
+struct AdvancedConstraints
+{
+ /**
+ * @brief Defines the strength of the reduction function
+ * Allows dynamic modification of wz_std (angular deviation) based on linear velocity of the robot.
+ * When a robot with high inertia (e.g. 500kg) is moving fast and if wz_std is above 0.3, oscillation behavior can be observed. Lowering wz_std stabilizes the robot but then the maneuvers take more time.
+ * Dynamically reducing wz_std as vx, vy increase (speed of the robot) solves both problems.
+ * Suggested values to start with: wz_std = 0.4, wz_std_decay_to = 0.05, wz_std_decay_strength = 3.0
+ * The following is used as the decay function
+ *
f(x) = (wz_std - wz_std_decay_to) * e^(-wz_std_decay_strength * v_linear) + wz_std_decay_to+ * Playground + * Default: -1.0 (disabled) + */ + float wz_std_decay_strength; + + /** + * @brief Target wz_std value while linear speed goes to infinity. + * Must be between 0 and wz_std. + * Has no effect if `advanced.wz_std_decay_strength` <= 0.0 + * Default: 0.0 + */ + float wz_std_decay_to; +}; + /** * @struct mppi::models::SamplingStd * @brief Noise parameters for sampling trajectories diff --git a/nav2_mppi_controller/include/nav2_mppi_controller/models/optimizer_settings.hpp b/nav2_mppi_controller/include/nav2_mppi_controller/models/optimizer_settings.hpp index 9416b53e1ba..dac1abd9166 100644 --- a/nav2_mppi_controller/include/nav2_mppi_controller/models/optimizer_settings.hpp +++ b/nav2_mppi_controller/include/nav2_mppi_controller/models/optimizer_settings.hpp @@ -30,6 +30,7 @@ struct OptimizerSettings models::ControlConstraints base_constraints{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}; models::ControlConstraints constraints{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}; models::SamplingStd sampling_std{0.0f, 0.0f, 0.0f}; + models::AdvancedConstraints advanced_constraints{0.0f, 0.0f}; float model_dt{0.0f}; float temperature{0.0f}; float gamma{0.0f}; diff --git a/nav2_mppi_controller/include/nav2_mppi_controller/tools/noise_generator.hpp b/nav2_mppi_controller/include/nav2_mppi_controller/tools/noise_generator.hpp index a201a1d4d1b..f8bc72d4f1d 100644 --- a/nav2_mppi_controller/include/nav2_mppi_controller/tools/noise_generator.hpp +++ b/nav2_mppi_controller/include/nav2_mppi_controller/tools/noise_generator.hpp @@ -15,8 +15,6 @@ #ifndef NAV2_MPPI_CONTROLLER__TOOLS__NOISE_GENERATOR_HPP_ #define NAV2_MPPI_CONTROLLER__TOOLS__NOISE_GENERATOR_HPP_ -#include