Line |
Branch |
Exec |
Source |
1 |
|
|
/////////////////////////////////////////////////////////////////////////////// |
2 |
|
|
// BSD 3-Clause License |
3 |
|
|
// |
4 |
|
|
// Copyright (C) 2019-2025, LAAS-CNRS, University of Edinburgh, |
5 |
|
|
// Heriot-Watt University |
6 |
|
|
// Copyright note valid unless otherwise stated in individual files. |
7 |
|
|
// All rights reserved. |
8 |
|
|
/////////////////////////////////////////////////////////////////////////////// |
9 |
|
|
|
10 |
|
|
// Auto-generated file for float |
11 |
|
|
#include "python/crocoddyl/core/state-base.hpp" |
12 |
|
|
|
13 |
|
|
#include "python/crocoddyl/core/core.hpp" |
14 |
|
|
|
15 |
|
|
#define SCALAR_float32 |
16 |
|
|
|
17 |
|
|
namespace crocoddyl { |
18 |
|
|
namespace python { |
19 |
|
|
|
20 |
|
|
template <typename State> |
21 |
|
|
struct StateAbstractVisitor |
22 |
|
|
: public bp::def_visitor<StateAbstractVisitor<State>> { |
23 |
|
|
typedef typename State::Scalar Scalar; |
24 |
|
|
template <class PyClass> |
25 |
|
✗ |
void visit(PyClass& cl) const { |
26 |
|
✗ |
cl.def(bp::init<std::size_t, std::size_t>( |
27 |
|
|
bp::args("self", "nx", "ndx"), |
28 |
|
|
"Initialize the state dimensions.\n\n" |
29 |
|
|
":param nx: dimension of state configuration tuple\n" |
30 |
|
|
":param ndx: dimension of state tangent vector")) |
31 |
|
✗ |
.def("zero", pure_virtual(&State::zero), bp::args("self"), |
32 |
|
|
"Generate a zero reference state.\n\n" |
33 |
|
|
":return zero reference state") |
34 |
|
✗ |
.def("rand", pure_virtual(&State::rand), bp::args("self"), |
35 |
|
|
"Generate a random reference state.\n\n" |
36 |
|
|
":return random reference state") |
37 |
|
✗ |
.def("diff", pure_virtual(&State::diff_wrap), |
38 |
|
|
bp::args("self", "x0", "x1"), |
39 |
|
|
"Compute the state manifold differentiation.\n\n" |
40 |
|
|
"It returns the value of x1 [-] x0 operation. Note tha x0 and x1 " |
41 |
|
|
"are points in the state manifold (in M). Instead the operator " |
42 |
|
|
"result lies in the tangent-space of M.\n" |
43 |
|
|
":param x0: previous state point (dim state.nx).\n" |
44 |
|
|
":param x1: current state point (dim state.nx).\n" |
45 |
|
|
":return x1 [-] x0 value (dim state.ndx).") |
46 |
|
✗ |
.def("integrate", pure_virtual(&State::integrate_wrap), |
47 |
|
|
bp::args("self", "x", "dx"), |
48 |
|
|
"Compute the state manifold integration.\n\n" |
49 |
|
|
"It returns the value of x [+] dx operation. x and dx are points " |
50 |
|
|
"in the state.diff(x0,x1) (in M) and its tangent, respectively. " |
51 |
|
|
"Note that the operator result lies on M too.\n" |
52 |
|
|
":param x: state point (dim. state.nx).\n" |
53 |
|
|
":param dx: velocity vector (dim state.ndx).\n" |
54 |
|
|
":return x [+] dx value (dim state.nx).") |
55 |
|
✗ |
.def("Jdiff", pure_virtual(&State::Jdiff_wrap), |
56 |
|
|
bp::args("self", "x0", "x1", "firstsecond"), |
57 |
|
|
"Compute the partial derivatives of difference operator.\n\n" |
58 |
|
|
"The difference operator (x1 [-] x0) is defined by diff(x0, x1). " |
59 |
|
|
"Instead Jdiff computes its partial derivatives, i.e. " |
60 |
|
|
"\\partial{diff(x0, x1)}{x0} and \\partial{diff(x0, x1)}{x1}. By " |
61 |
|
|
"default, this function returns the derivatives of the first and " |
62 |
|
|
"second argument (i.e. firstsecond='both'). However we can also " |
63 |
|
|
"specific the partial derivative for the first and second " |
64 |
|
|
"variables by setting firstsecond='first' or " |
65 |
|
|
"firstsecond='second', respectively.\n" |
66 |
|
|
":param x0: previous state point (dim state.nx).\n" |
67 |
|
|
":param x1: current state point (dim state.nx).\n" |
68 |
|
|
":param firstsecond: derivative w.r.t x0 or x1 or both\n" |
69 |
|
|
":return the partial derivative(s) of the diff(x0, x1) function") |
70 |
|
✗ |
.def("Jintegrate", pure_virtual(&State::Jintegrate_wrap), |
71 |
|
|
bp::args("self", "x", "dx", "firstsecond"), |
72 |
|
|
"Compute the partial derivatives of integrate operator.\n\n" |
73 |
|
|
"The integrate operator (x [+] dx) is defined by integrate(x, " |
74 |
|
|
"dx). Instead Jintegrate computes its partial derivatives, i.e. " |
75 |
|
|
"\\partial{integrate(x, dx)}{x} and \\partial{integrate(x, " |
76 |
|
|
"dx)}{dx}. By default, this function returns the derivatives of " |
77 |
|
|
"the first and second argument (i.e. firstsecond='both'), partial " |
78 |
|
|
"derivative by setting firstsecond='first' or " |
79 |
|
|
"firstsecond='second'.\n" |
80 |
|
|
":param x: state point (dim. state.nx).\n" |
81 |
|
|
":param dx: velocity vector (dim state.ndx).\n" |
82 |
|
|
":param firstsecond: derivative w.r.t x or dx or both\n" |
83 |
|
|
":return the partial derivative(s) of the integrate(x, dx) " |
84 |
|
|
"function") |
85 |
|
✗ |
.def("JintegrateTransport", |
86 |
|
|
pure_virtual(&State::JintegrateTransport_wrap), |
87 |
|
|
bp::args("self", "x", "dx", "Jin", "firstsecond"), |
88 |
|
|
"Parallel transport from integrate(x, dx) to x.\n\n" |
89 |
|
|
"This function performs the parallel transportation of an input " |
90 |
|
|
"matrix whose columns are expressed in the tangent space at " |
91 |
|
|
"integrate(x, dx) to the tangent space at x point\n" |
92 |
|
|
":param x: state point (dim. state.nx).\n" |
93 |
|
|
":param dx: velocity vector (dim state.ndx).\n" |
94 |
|
|
":param Jin: input matrix (number of rows = state.nv).\n" |
95 |
|
|
":param firstsecond: derivative w.r.t x or dx") |
96 |
|
✗ |
.add_property( |
97 |
|
|
"nx", bp::make_function(&State::get_nx), |
98 |
|
✗ |
bp::make_setter(&State::nx_, bp::return_internal_reference<>()), |
99 |
|
|
"dimension of state tuple") |
100 |
|
✗ |
.add_property( |
101 |
|
|
"ndx", bp::make_function(&State::get_ndx), |
102 |
|
✗ |
bp::make_setter(&State::ndx_, bp::return_internal_reference<>()), |
103 |
|
|
"dimension of the tangent space of the state manifold") |
104 |
|
✗ |
.add_property( |
105 |
|
|
"nq", bp::make_function(&State::get_nq), |
106 |
|
✗ |
bp::make_setter(&State::nq_, bp::return_internal_reference<>()), |
107 |
|
|
"dimension of the configuration tuple") |
108 |
|
✗ |
.add_property( |
109 |
|
|
"nv", bp::make_function(&State::get_nv), |
110 |
|
✗ |
bp::make_setter(&State::nv_, bp::return_internal_reference<>()), |
111 |
|
|
"dimension of tangent space of the configuration manifold") |
112 |
|
✗ |
.add_property("has_limits", bp::make_function(&State::get_has_limits), |
113 |
|
|
"indicates whether problem has finite state limits") |
114 |
|
✗ |
.add_property( |
115 |
|
|
"lb", |
116 |
|
✗ |
bp::make_getter(&State::lb_, bp::return_internal_reference<>()), |
117 |
|
|
&State::set_lb, "lower state limits") |
118 |
|
✗ |
.add_property( |
119 |
|
|
"ub", |
120 |
|
✗ |
bp::make_getter(&State::ub_, bp::return_internal_reference<>()), |
121 |
|
|
&State::set_ub, "upper state limits"); |
122 |
|
|
} |
123 |
|
|
}; |
124 |
|
|
|
125 |
|
|
#define CROCODDYL_STATE_ABSTRACT_PYTHON_BINDINGS(Scalar) \ |
126 |
|
|
typedef StateAbstractTpl<Scalar> State; \ |
127 |
|
|
typedef StateAbstractTpl_wrap<Scalar> State_wrap; \ |
128 |
|
|
bp::register_ptr_to_python<std::shared_ptr<State>>(); \ |
129 |
|
|
bp::class_<State_wrap, boost::noncopyable>( \ |
130 |
|
|
"StateAbstract", \ |
131 |
|
|
"Abstract class for the state representation.\n\n" \ |
132 |
|
|
"A state is represented by its operators: difference, integrates and " \ |
133 |
|
|
"their derivatives. The difference operator returns the value of x1 " \ |
134 |
|
|
"[-] x0 operation. Instead the integrate operator returns the value of " \ |
135 |
|
|
"x [+] dx. These operators are used to compared two points on the " \ |
136 |
|
|
"state manifold M or to advance the state given a tangential velocity " \ |
137 |
|
|
"(Tx M). Therefore the points x, x0 and x1 belong to the manifold M; " \ |
138 |
|
|
"and dx or x1 [-] x0 lie on its tangential space") \ |
139 |
|
|
.def(StateAbstractVisitor<State_wrap>()) \ |
140 |
|
|
.def(PrintableVisitor<State_wrap>()) \ |
141 |
|
|
.def(CopyableVisitor<State_wrap>()); |
142 |
|
|
|
143 |
|
✗ |
void exposeStateAbstract() { |
144 |
|
|
#ifdef SCALAR_float64 |
145 |
|
|
bp::enum_<Jcomponent>("Jcomponent") |
146 |
|
|
.value("both", both) |
147 |
|
|
.value("first", first) |
148 |
|
|
.export_values() |
149 |
|
|
.value("second", second); |
150 |
|
|
|
151 |
|
|
bp::enum_<AssignmentOp>("AssignmentOp") |
152 |
|
|
.value("setto", setto) |
153 |
|
|
.value("addto", addto) |
154 |
|
|
.value("rmfrom", rmfrom) |
155 |
|
|
.export_values(); |
156 |
|
|
#endif |
157 |
|
|
|
158 |
|
✗ |
CROCODDYL_STATE_ABSTRACT_PYTHON_BINDINGS(float) |
159 |
|
|
} |
160 |
|
|
|
161 |
|
|
} // namespace python |
162 |
|
|
} // namespace crocoddyl |
163 |
|
|
|