aligator  0.6.1
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
Loading...
Searching...
No Matches
problem-wrap.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <crocoddyl/core/optctrl/shooting.hpp>
7
8namespace aligator {
9namespace compat {
10namespace croc {
11
18template <typename Scalar>
19TrajOptProblemTpl<Scalar> convertCrocoddylProblem(
20 const boost::shared_ptr<crocoddyl::ShootingProblemTpl<Scalar>>
21 &croc_problem) {
22 const crocoddyl::ShootingProblemTpl<Scalar> &cpb = *croc_problem;
23 using VectorXs = typename math_types<Scalar>::VectorXs;
24 using StageModel = StageModelTpl<Scalar>;
25 using ActionModelWrapper = ActionModelWrapperTpl<Scalar>;
26
27 const std::size_t nsteps = cpb.get_T();
28 const VectorXs &x0 = cpb.get_x0();
29
30 const auto &running_models = cpb.get_runningModels();
31
32 // construct the std::vector of StageModel to provide the proxddp
33 // TrajOptProblem.
34 std::vector<shared_ptr<StageModel>> stages;
35 stages.reserve(nsteps);
36 for (std::size_t i = 0; i < nsteps; i++) {
37 stages.push_back(std::make_shared<ActionModelWrapper>(running_models[i]));
38 }
39 auto converted_cost = std::make_shared<CrocCostModelWrapperTpl<Scalar>>(
40 cpb.get_terminalModel());
41 TrajOptProblemTpl<Scalar> problem(x0, stages, converted_cost);
42 return problem;
43}
44
45} // namespace croc
46} // namespace compat
47} // namespace aligator
TrajOptProblemTpl< Scalar > convertCrocoddylProblem(const boost::shared_ptr< crocoddyl::ShootingProblemTpl< Scalar > > &croc_problem)
This function converts a crocoddyl::ShootingProblemTpl to an aligator::TrajOptProblemTpl.
Main package namespace.