Skip to content

Commit 17f2f58

Browse files
authored
Merge pull request #376 from Simple-Robotics/topic/core-trajopt-replace-return
core: have `TrajOptProblem::replaceStageCircular()` return ejected first stage
2 parents e326eaf + a76d81e commit 17f2f58

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2222

2323
### Changed
2424

25+
- core : have `replaceStageCircular()` return ejected knot (https://github.com/Simple-Robotics/aligator/pull/376)
2526
- python : do not import utils.plotting automatically (https://github.com/Simple-Robotics/aligator/pull/369)
2627
- ci: display ccache statistics (https://github.com/Simple-Robotics/aligator/pull/369)
2728
- pixi: update environments (https://github.com/Simple-Robotics/aligator/pull/369)

include/aligator/core/traj-opt-problem.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,11 @@ template <typename _Scalar> struct TrajOptProblemTpl {
210210
std::size_t num_threads = 1,
211211
bool compute_second_order = true) const;
212212

213-
/// @brief Pop out the first StageModel and replace by the supplied one;
214-
/// updates the supplied problem data (TrajOptDataTpl) object.
215-
void replaceStageCircular(const xyz::polymorphic<StageModel> &model);
213+
/// @brief Advance each stage model by one slot after inserting a new stage,
214+
/// pop out the first model.
215+
/// @returns The first StageModel.
216+
xyz::polymorphic<StageModel>
217+
replaceStageCircular(const xyz::polymorphic<StageModel> &model);
216218

217219
bool checkIntegrity() const;
218220

include/aligator/core/traj-opt-problem.hxx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,13 @@ inline std::size_t TrajOptProblemTpl<Scalar>::numSteps() const {
164164
}
165165

166166
template <typename Scalar>
167-
void TrajOptProblemTpl<Scalar>::replaceStageCircular(
168-
const xyz::polymorphic<StageModel> &model) {
167+
auto TrajOptProblemTpl<Scalar>::replaceStageCircular(
168+
const xyz::polymorphic<StageModel> &model) -> xyz::polymorphic<StageModel> {
169169
addStage(model);
170170
rotate_vec_left(stages_);
171+
auto last = std::move(stages_.back());
171172
stages_.pop_back();
173+
return last;
172174
}
173175

174176
template <typename Scalar>

0 commit comments

Comments
 (0)