diff --git a/CHANGELOG.md b/CHANGELOG.md index c39099863..b95a1e7ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- core : have `replaceStageCircular()` return ejected knot (https://github.com/Simple-Robotics/aligator/pull/376) - python : do not import utils.plotting automatically (https://github.com/Simple-Robotics/aligator/pull/369) - ci: display ccache statistics (https://github.com/Simple-Robotics/aligator/pull/369) - pixi: update environments (https://github.com/Simple-Robotics/aligator/pull/369) diff --git a/include/aligator/core/traj-opt-problem.hpp b/include/aligator/core/traj-opt-problem.hpp index ccd3304d7..ef33a2cba 100644 --- a/include/aligator/core/traj-opt-problem.hpp +++ b/include/aligator/core/traj-opt-problem.hpp @@ -210,9 +210,11 @@ template struct TrajOptProblemTpl { std::size_t num_threads = 1, bool compute_second_order = true) const; - /// @brief Pop out the first StageModel and replace by the supplied one; - /// updates the supplied problem data (TrajOptDataTpl) object. - void replaceStageCircular(const xyz::polymorphic &model); + /// @brief Advance each stage model by one slot after inserting a new stage, + /// pop out the first model. + /// @returns The first StageModel. + xyz::polymorphic + replaceStageCircular(const xyz::polymorphic &model); bool checkIntegrity() const; diff --git a/include/aligator/core/traj-opt-problem.hxx b/include/aligator/core/traj-opt-problem.hxx index 942637551..a57c9ecb3 100644 --- a/include/aligator/core/traj-opt-problem.hxx +++ b/include/aligator/core/traj-opt-problem.hxx @@ -164,11 +164,13 @@ inline std::size_t TrajOptProblemTpl::numSteps() const { } template -void TrajOptProblemTpl::replaceStageCircular( - const xyz::polymorphic &model) { +auto TrajOptProblemTpl::replaceStageCircular( + const xyz::polymorphic &model) -> xyz::polymorphic { addStage(model); rotate_vec_left(stages_); + auto last = std::move(stages_.back()); stages_.pop_back(); + return last; } template