-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Added support for MPPI Controller to adjust wz_std parameter based on linear speed #5294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
5ea8873
1332a38
3d042fe
aaeb627
64b810d
b9691c5
74dc704
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,6 @@ | |
#ifndef NAV2_MPPI_CONTROLLER__TOOLS__NOISE_GENERATOR_HPP_ | ||
#define NAV2_MPPI_CONTROLLER__TOOLS__NOISE_GENERATOR_HPP_ | ||
|
||
#include <Eigen/Dense> | ||
|
||
#include <string> | ||
#include <memory> | ||
#include <thread> | ||
|
@@ -47,14 +45,13 @@ class NoiseGenerator | |
|
||
/** | ||
* @brief Initialize noise generator with settings and model types | ||
* @param settings Settings of controller | ||
* @param is_holonomic If base is holonomic | ||
* @param logger Reference to the package logger | ||
* @param name Namespace for configs | ||
* @param param_handler Get parameters util | ||
*/ | ||
void initialize( | ||
mppi::models::OptimizerSettings & settings, | ||
bool is_holonomic, const std::string & name, ParametersHandler * param_handler); | ||
const std::shared_ptr<nav2::LifecycleNode> & node, const std::string & name, | ||
ParametersHandler * param_handler); | ||
|
||
/** | ||
* @brief Shutdown noise generator thread | ||
|
@@ -73,12 +70,27 @@ class NoiseGenerator | |
*/ | ||
void setNoisedControls(models::State & state, const models::ControlSequence & control_sequence); | ||
|
||
/** | ||
* Computes adaptive values of the SamplingStd parameters and updates adaptive counterparts | ||
* See also wz_std_decay_strength, wz_std_decay_to parameters for more information on how wz => wz_std_adaptive is computed | ||
* @param state Current state of the robot | ||
*/ | ||
void computeAdaptiveStds(const models::State & state); | ||
|
||
/** | ||
* Validates decay constraints and returns true if constraints are valid | ||
* @return true if decay constraints are valid | ||
*/ | ||
bool validateWzStdDecayConstraints() const; | ||
|
||
float getWzStdAdaptive() const; | ||
|
||
/** | ||
* @brief Reset noise generator with settings and model types | ||
* @param settings Settings of controller | ||
* @param is_holonomic If base is holonomic | ||
*/ | ||
void reset(mppi::models::OptimizerSettings & settings, bool is_holonomic); | ||
void reset(const mppi::models::OptimizerSettings & settings, bool is_holonomic); | ||
|
||
protected: | ||
/** | ||
|
@@ -100,17 +112,21 @@ class NoiseGenerator | |
Eigen::ArrayXXf noises_wz_; | ||
|
||
std::default_random_engine generator_; | ||
std::normal_distribution<float> ndistribution_vx_; | ||
std::normal_distribution<float> ndistribution_wz_; | ||
std::normal_distribution<float> ndistribution_vy_; | ||
|
||
mppi::models::OptimizerSettings settings_; | ||
std::unique_ptr<rclcpp::Logger> logger_; | ||
models::OptimizerSettings settings_; | ||
bool is_holonomic_; | ||
|
||
std::thread noise_thread_; | ||
std::unique_ptr<std::thread> noise_thread_; | ||
vahapt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
std::condition_variable noise_cond_; | ||
std::mutex noise_lock_; | ||
bool active_{false}, ready_{false}, regenerate_noises_{false}; | ||
bool active_{false}, ready_{false}; | ||
|
||
/** | ||
* @brief Internal variable that holds wz_std after decay is applied. | ||
* If decay is disabled, SamplingStd.wz == wz_std_adaptive | ||
*/ | ||
float wz_std_adaptive; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should not need to be stored here. We talked about this being in the std model alongside the validate / update / reset functions There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still strongly disagree. It's not a setting. It's a part of current state just like vx. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But its not part of the noise generator state, its part of the optimizer state |
||
}; | ||
|
||
} // namespace mppi | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -331,7 +331,7 @@ TEST(CriticTests, PathAngleCritic) | |
costmap_ros->on_configure(lstate); | ||
|
||
models::State state; | ||
state.reset(1000, 30); | ||
state.reset(1000, 30); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This'll cause linting issues |
||
models::ControlSequence control_sequence; | ||
models::Trajectories generated_trajectories; | ||
generated_trajectories.reset(1000, 30); | ||
|
Uh oh!
There was an error while loading. Please reload this page.