12template <
typename Scalar>
14 std::vector<
typename math_types<Scalar>::VectorXs> &xs) {
15 const std::size_t nsteps = problem.
numSteps();
16 xs.resize(nsteps + 1);
20 if (problem.
stages_.size() > 0) {
21 xs[0] = problem.
stages_[0]->xspace().neutral();
24 "The problem should have either a StateErrorResidual as an initial "
25 "condition or at least one stage.");
28 for (std::size_t i = 0; i < nsteps; i++) {
36template <
typename Scalar>
38 std::vector<
typename math_types<Scalar>::VectorXs> &us) {
39 const std::size_t nsteps = problem.
numSteps();
41 for (std::size_t i = 0; i < nsteps; i++) {
43 us[i] = sm.
uspace().neutral();
47template <
typename Scalar>
49 using VectorXs =
typename math_types<Scalar>::VectorXs;
50 std::vector<VectorXs> xs, us, vs, lbdas;
51 const size_t nsteps = problem.
numSteps();
55 vs.resize(nsteps + 1);
56 lbdas.resize(nsteps + 1);
58 for (
size_t i = 0; i < nsteps; i++) {
60 lbdas[i + 1].setZero(sm.
ndx2());
61 vs[i].setZero(sm.
nc());
68 return std::make_tuple(std::move(xs), std::move(us), std::move(vs),
74template <
typename T1,
typename T2>
76 std::vector<T2> &rhs) {
77 static_assert(std::is_base_of_v<Eigen::EigenBase<T1>, T1>,
78 "T1 should be an Eigen object!");
79 static_assert(std::is_base_of_v<Eigen::EigenBase<T2>, T2>,
80 "T2 should be an Eigen object!");
81 if (lhs.size() != rhs.size())
84 const auto same_dims = [](
auto &x,
auto &y) {
85 return (x.cols() == y.cols()) && (x.rows() == y.rows());
88 for (std::size_t i = 0; i < lhs.size(); i++) {
89 if (!same_dims(lhs[i], rhs[i]))
98template <
typename Scalar>
101 const typename math_types<Scalar>::VectorOfVectors &xs_init,
102 const typename math_types<Scalar>::VectorOfVectors &us_init,
103 typename math_types<Scalar>::VectorOfVectors &xs_out,
104 typename math_types<Scalar>::VectorOfVectors &us_out) {
105 const std::size_t nsteps = problem.
numSteps();
106 xs_out.reserve(nsteps + 1);
107 us_out.reserve(nsteps);
108 if (xs_init.empty()) {
113 if (us_init.empty()) {
#define ALIGATOR_RUNTIME_ERROR(...)
void check_trajectory_and_assign(const TrajOptProblemTpl< Scalar > &problem, const typename math_types< Scalar >::VectorOfVectors &xs_init, const typename math_types< Scalar >::VectorOfVectors &us_init, typename math_types< Scalar >::VectorOfVectors &xs_out, typename math_types< Scalar >::VectorOfVectors &us_out)
Check the input state-control trajectory is a consistent warm-start for the output.
bool assign_no_resize(const std::vector< T1 > &lhs, std::vector< T2 > &rhs)
Assign a vector of Eigen types into another, ensure there is no resize.
void us_default_init(const TrajOptProblemTpl< Scalar > &problem, std::vector< typename math_types< Scalar >::VectorXs > &us)
Default-initialize a controls trajectory from the neutral element of each control space.
void xs_default_init(const TrajOptProblemTpl< Scalar > &problem, std::vector< typename math_types< Scalar >::VectorXs > &xs)
Default-intialize a trajectory to the neutral states for each state space at each stage.
auto problemInitializeSolution(const TrajOptProblemTpl< Scalar > &problem)
A stage in the control problem.
const Manifold & xspace_next() const
const Manifold & uspace() const
int nc() const
Total number of constraints.
Trajectory optimization problem.
xyz::polymorphic< UnaryFunction > init_constraint_
Initial condition.
ConstraintStackTpl< Scalar > term_cstrs_
Terminal constraints.
bool initCondIsStateError() const
std::size_t numSteps() const
std::vector< xyz::polymorphic< StageModel > > stages_
Stages of the control problem.
ConstVectorRef getInitState() const
Get initial state constraint.