aligator 0.18.0
A versatile and efficient C++ library for real-time constrained trajectory optimization.
Loading...
Searching...
No Matches
expose-center-of-mass.cpp
Go to the documentation of this file.
1
3#ifdef ALIGATOR_WITH_PINOCCHIO
4
5// Boost.Python 1.74 include manually mpl/vector/vector20.hpp
6// that prevent us to define mpl::list and mpl::vector with
7// the right size.
8// To avoid this issue this header should be included first.
9#include <pinocchio/fwd.hpp>
10
13
19
20namespace aligator {
21namespace python {
22
25using context::Scalar;
29
31 using CenterOfMassTranslation = CenterOfMassTranslationResidualTpl<Scalar>;
32 using CenterOfMassTranslationData = CenterOfMassTranslationDataTpl<Scalar>;
33
34 using CenterOfMassVelocity = CenterOfMassVelocityResidualTpl<Scalar>;
35 using CenterOfMassVelocityData = CenterOfMassVelocityDataTpl<Scalar>;
36
37 using DCMPosition = DCMPositionResidualTpl<Scalar>;
38 using DCMPositionData = DCMPositionDataTpl<Scalar>;
39
40 using CentroidalMomentumDerivativeResidual =
42 using CentroidalMomentumDerivativeData =
44
45 using CentroidalMomentumResidual = CentroidalMomentumResidualTpl<Scalar>;
46 using CentroidalMomentumData = CentroidalMomentumDataTpl<Scalar>;
47
50
51 bp::class_<CenterOfMassTranslation, bp::bases<UnaryFunction>>(
52 "CenterOfMassTranslationResidual",
53 "A residual function :math:`r(x) = com(x)` ",
54 bp::init<const int, const int, const PinModel &, const context::Vector3s>(
55 bp::args("self", "ndx", "nu", "model", "p_ref")))
57 .def("getReference", &CenterOfMassTranslation::getReference,
58 bp::args("self"), bp::return_internal_reference<>(),
59 "Get the target Center Of Mass translation.")
60 .def("setReference", &CenterOfMassTranslation::setReference,
61 bp::args("self", "p_new"),
62 "Set the target Center Of Mass translation.")
63 .def(unary_visitor);
64
65 bp::register_ptr_to_python<shared_ptr<CenterOfMassTranslationData>>();
66
67 bp::class_<CenterOfMassTranslationData, bp::bases<StageFunctionData>>(
68 "CenterOfMassTranslationResidualData",
69 "Data Structure for CenterOfMassTranslation", bp::no_init)
70 .def_readonly("pin_data", &CenterOfMassTranslationData::pin_data_,
71 "Pinocchio data struct.");
72
73 bp::class_<CenterOfMassVelocity, bp::bases<UnaryFunction>>(
74 "CenterOfMassVelocityResidual",
75 "A residual function :math:`r(x) = vcom(x)` ",
76 bp::init<const int, const int, const PinModel &, const context::Vector3s>(
77 bp::args("self", "ndx", "nu", "model", "v_ref")))
79 .def(unary_visitor)
80 .def("getReference", &CenterOfMassVelocity::getReference,
81 bp::args("self"), bp::return_internal_reference<>(),
82 "Get the target Center Of Mass velocity.")
83 .def("setReference", &CenterOfMassVelocity::setReference,
84 bp::args("self", "p_new"),
85 "Set the target Center Of Mass velocity.");
86
87 bp::register_ptr_to_python<shared_ptr<CenterOfMassVelocityData>>();
88
89 bp::class_<CenterOfMassVelocityData, bp::bases<StageFunctionData>>(
90 "CenterOfMassVelocityResidualData",
91 "Data Structure for CenterOfMassVelocity", bp::no_init)
92 .def_readonly("pin_data", &CenterOfMassVelocityData::pin_data_,
93 "Pinocchio data struct.");
94
95 bp::class_<DCMPosition, bp::bases<UnaryFunction>>(
96 "DCMPositionResidual", "A residual function :math:`r(x) = dcm(x)` ",
97 bp::init<const int, const int, const PinModel &,
98 const context::Vector3s &, const double>(
99 bp::args("self", "ndx", "nu", "model", "dcm_ref", "alpha")))
101 .def(unary_visitor)
102 .def("getReference", &DCMPosition::getReference, bp::args("self"),
103 bp::return_internal_reference<>(), "Get the target DCM position.")
104 .def("setReference", &DCMPosition::setReference,
105 bp::args("self", "new_ref"), "Set the target DCM position.");
106
107 bp::register_ptr_to_python<shared_ptr<DCMPositionData>>();
108
109 bp::class_<DCMPositionData, bp::bases<StageFunctionData>>(
110 "DCMPositionResidualData", "Data Structure for DCMPosition", bp::no_init)
111 .def_readonly("pin_data", &DCMPositionData::pin_data_,
112 "Pinocchio data struct.");
113
114 bp::class_<CentroidalMomentumDerivativeResidual, bp::bases<StageFunction>>(
115 "CentroidalMomentumDerivativeResidual",
116 "A residual function :math:`r(x) = H_dot` ",
117 bp::init<const int, const PinModel &, const context::Vector3s &,
118 const std::vector<bool> &,
119 const std::vector<pinocchio::FrameIndex> &, const int>(
120 bp::args("self", "ndx", "model", "gravity", "contact_states",
121 "contact_ids", "force_size")))
122 .def(func_visitor)
123 .def_readwrite("contact_states",
124 &CentroidalMomentumDerivativeResidual::contact_states_);
125
126 bp::register_ptr_to_python<shared_ptr<CentroidalMomentumDerivativeData>>();
127
128 bp::class_<CentroidalMomentumDerivativeData, bp::bases<StageFunctionData>>(
129 "CentroidalMomentumDerivativeResidualData",
130 "Data Structure for CentroidalMomentumDerivativeResidual", bp::no_init)
131 .def_readonly("pin_data", &CentroidalMomentumDerivativeData::pin_data_,
132 "Pinocchio data struct.");
133
134 bp::class_<CentroidalMomentumResidual, bp::bases<UnaryFunction>>(
135 "CentroidalMomentumResidual", "A residual function :math:`r(x) = H` ",
136 bp::init<const int, const int, const PinModel &,
137 const context::Vector6s &>(
138 bp::args("self", "ndx", "nu", "model", "h_ref")))
139 .def(unary_visitor)
140 .def("getReference", &CentroidalMomentumResidual::getReference,
141 bp::args("self"), bp::return_internal_reference<>(),
142 "Get the centroidal target.")
143 .def("setReference", &CentroidalMomentumResidual::setReference,
144 bp::args("self", "h_new"), "Set the centroidal target.");
145
146 bp::register_ptr_to_python<shared_ptr<CentroidalMomentumData>>();
147
148 bp::class_<CentroidalMomentumData, bp::bases<StageFunctionData>>(
149 "CentroidalMomentumResidualData",
150 "Data Structure for CentroidalMomentumResidual", bp::no_init)
151 .def_readonly("pin_data", &CentroidalMomentumData::pin_data_,
152 "Pinocchio data struct.");
153}
154
155} // namespace python
156} // namespace aligator
157
158#endif
pinocchio::ModelTpl< Scalar, Options > PinModel
Definition fwd.hpp:21
StageFunctionTpl< Scalar > StageFunction
Definition context.hpp:17
UnaryFunctionTpl< Scalar > UnaryFunction
Definition context.hpp:18
StageFunctionDataTpl< Scalar > StageFunctionData
Definition context.hpp:19
pinocchio::DataTpl< Scalar, Options > PinData
Definition fwd.hpp:22
The Python bindings.
Definition blk-matrix.hpp:7
const PolymorphicMultiBaseVisitor< UnaryFunction, StageFunction > unary_visitor
PolymorphicMultiBaseVisitor< StageFunction > func_visitor
Main package namespace.
This residual returns the Center of Mass translation for a centroidal model with state .
This residual returns the derivative of centroidal momentum for a kinodynamics model.
This residual returns the derivative of centroidal momentum for a kinodynamics model.