| 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 "crocoddyl/core/states/euclidean.hpp" | ||
| 12 | |||
| 13 | #include "python/crocoddyl/core/core.hpp" | ||
| 14 | #include "python/crocoddyl/core/state-base.hpp" | ||
| 15 | |||
| 16 | namespace crocoddyl { | ||
| 17 | namespace python { | ||
| 18 | |||
| 19 | template <typename State> | ||
| 20 | struct StateVectorVisitor : public bp::def_visitor<StateVectorVisitor<State>> { | ||
| 21 | typedef typename State::Scalar Scalar; | ||
| 22 | ✗ | BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Jdiffs, | |
| 23 | StateAbstractTpl<Scalar>::Jdiff_Js, 2, | ||
| 24 | 3) | ||
| 25 | ✗ | BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS( | |
| 26 | Jintegrates, StateAbstractTpl<Scalar>::Jintegrate_Js, 2, 3) | ||
| 27 | template <class PyClass> | ||
| 28 | ✗ | void visit(PyClass& cl) const { | |
| 29 | ✗ | cl.def("zero", &State::zero, bp::args("self"), | |
| 30 | "Return a zero reference state.\n\n" | ||
| 31 | ":return zero reference state") | ||
| 32 | ✗ | .def("rand", &State::rand, bp::args("self"), | |
| 33 | "Return a random reference state.\n\n" | ||
| 34 | ":return random reference state") | ||
| 35 | ✗ | .def("diff", &State::diff_dx, bp::args("self", "x0", "x1"), | |
| 36 | "Operator that differentiates the two state points.\n\n" | ||
| 37 | "It returns the value of x1 [-] x0 operation. Due to a state " | ||
| 38 | "vector lies in the Euclidean space, this operator is defined " | ||
| 39 | "with arithmetic subtraction.\n" | ||
| 40 | ":param x0: current state (dim state.nx()).\n" | ||
| 41 | ":param x1: next state (dim state.nx()).\n" | ||
| 42 | ":return x1 - x0 value (dim state.nx()).") | ||
| 43 | ✗ | .def("integrate", &State::integrate_x, bp::args("self", "x", "dx"), | |
| 44 | "Operator that integrates the current state.\n\n" | ||
| 45 | "It returns the value of x [+] dx operation. Due to a state " | ||
| 46 | "vector lies in the Euclidean space, this operator is defined " | ||
| 47 | "with arithmetic addition. Futhermore there is no timestep here " | ||
| 48 | "(i.e. dx = v*dt), note this if you're integrating a velocity v " | ||
| 49 | "during an interval dt.\n" | ||
| 50 | ":param x: current state (dim state.nx()).\n" | ||
| 51 | ":param dx: displacement of the state (dim state.nx()).\n" | ||
| 52 | ":return x + dx value (dim state.nx()).") | ||
| 53 | ✗ | .def("Jdiff", &State::Jdiff_Js, | |
| 54 | ✗ | Jdiffs(bp::args("self", "x0", "x1", "firstsecond"), | |
| 55 | "Compute the partial derivatives of arithmetic " | ||
| 56 | "substraction.\n\n" | ||
| 57 | "Both Jacobian matrices are represented throught an " | ||
| 58 | "identity matrix, with the exception that the first " | ||
| 59 | "partial derivatives (w.r.t. x0) has negative signed. By " | ||
| 60 | "default, this function returns the derivatives of the " | ||
| 61 | "first and second argument (i.e. firstsecond='both'). " | ||
| 62 | "However we ask for a specific partial derivative by " | ||
| 63 | "setting firstsecond='first' or firstsecond='second'.\n" | ||
| 64 | ":param x0: current state (dim state.nx()).\n" | ||
| 65 | ":param x1: next state (dim state.nx()).\n" | ||
| 66 | ":param firstsecond: derivative w.r.t x0 or x1 or both\n" | ||
| 67 | ":return the partial derivative(s) of the diff(x0, x1) " | ||
| 68 | "function")) | ||
| 69 | ✗ | .def("Jintegrate", &State::Jintegrate_Js, | |
| 70 | ✗ | Jintegrates( | |
| 71 | bp::args("self", "x", "dx", "firstsecond"), | ||
| 72 | "Compute the partial derivatives of arithmetic addition.\n\n" | ||
| 73 | "Both Jacobian matrices are represented throught an identity " | ||
| 74 | "matrix. By default, this function returns the derivatives of " | ||
| 75 | "the first and second argument (i.e. firstsecond='both'). " | ||
| 76 | "However we ask for a specific partial derivative by setting " | ||
| 77 | "firstsecond='first' or firstsecond='second'.\n" | ||
| 78 | ":param x: current state (dim state.nx()).\n" | ||
| 79 | ":param dx: displacement of the state (dim state.nx()).\n" | ||
| 80 | ":param firstsecond: derivative w.r.t x or dx or both\n" | ||
| 81 | ":return the partial derivative(s) of the integrate(x, dx) " | ||
| 82 | "function")) | ||
| 83 | ✗ | .def("JintegrateTransport", &State::JintegrateTransport, | |
| 84 | bp::args("self", "x", "dx", "Jin", "firstsecond"), | ||
| 85 | "Parallel transport from integrate(x, dx) to x.\n\n" | ||
| 86 | "This function performs the parallel transportation of an input " | ||
| 87 | "matrix whose columns are expressed in the tangent space at " | ||
| 88 | "integrate(x, dx) to the tangent space at x point.\n" | ||
| 89 | ":param x: state point (dim. state.nx).\n" | ||
| 90 | ":param dx: velocity vector (dim state.ndx).\n" | ||
| 91 | ":param Jin: input matrix (number of rows = state.nv).\n" | ||
| 92 | ":param firstsecond: derivative w.r.t x or dx"); | ||
| 93 | ✗ | } | |
| 94 | }; | ||
| 95 | |||
| 96 | #define CROCODDYL_STATE_VECTOR_PYTHON_BINDINGS(Scalar) \ | ||
| 97 | typedef StateVectorTpl<Scalar> State; \ | ||
| 98 | typedef StateAbstractTpl<Scalar> StateBase; \ | ||
| 99 | bp::register_ptr_to_python<std::shared_ptr<State>>(); \ | ||
| 100 | bp::class_<State, bp::bases<StateBase>>( \ | ||
| 101 | "StateVector", \ | ||
| 102 | "Euclidean state vector.\n\n" \ | ||
| 103 | "For this type of states, the difference and integrate operators are " \ | ||
| 104 | "described by arithmetic subtraction and addition operations, " \ | ||
| 105 | "respectively. Due to the Euclidean point and its velocity lie in the " \ | ||
| 106 | "same space, all Jacobians are described throught the identity matrix.", \ | ||
| 107 | bp::init<std::size_t>(bp::args("self", "nx"), \ | ||
| 108 | "Initialize the vector dimension.\n\n" \ | ||
| 109 | ":param nx: dimension of state")) \ | ||
| 110 | .def(StateVectorVisitor<State>()) \ | ||
| 111 | .def(CastVisitor<State>()) \ | ||
| 112 | .def(PrintableVisitor<State>()) \ | ||
| 113 | .def(CopyableVisitor<State>()); | ||
| 114 | |||
| 115 | ✗ | void exposeStateEuclidean() { | |
| 116 | ✗ | CROCODDYL_STATE_VECTOR_PYTHON_BINDINGS(float) | |
| 117 | ✗ | } | |
| 118 | |||
| 119 | } // namespace python | ||
| 120 | } // namespace crocoddyl | ||
| 121 |