| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /////////////////////////////////////////////////////////////////////////////// | ||
| 2 | // BSD 3-Clause License | ||
| 3 | // | ||
| 4 | // Copyright (C) 2021-2025, University of Edinburgh, University of Trento | ||
| 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 double | ||
| 11 | #include "crocoddyl/core/controls/poly-zero.hpp" | ||
| 12 | |||
| 13 | #include "python/crocoddyl/core/control-base.hpp" | ||
| 14 | #include "python/crocoddyl/core/core.hpp" | ||
| 15 | #include "python/crocoddyl/utils/copyable.hpp" | ||
| 16 | |||
| 17 | namespace crocoddyl { | ||
| 18 | namespace python { | ||
| 19 | |||
| 20 | template <typename Model> | ||
| 21 | struct ControlParametrizationModelPolyZeroVisitor | ||
| 22 | : public bp::def_visitor< | ||
| 23 | ControlParametrizationModelPolyZeroVisitor<Model>> { | ||
| 24 | typedef typename Model::Scalar Scalar; | ||
| 25 | typedef typename Model::ControlParametrizationDataAbstract Data; | ||
| 26 | typedef typename Model::VectorXs VectorXs; | ||
| 27 | template <class PyClass> | ||
| 28 | ✗ | void visit(PyClass& cl) const { | |
| 29 | ✗ | cl.def("calc", | |
| 30 | static_cast<void (Model::*)( | ||
| 31 | const std::shared_ptr<Data>&, const Scalar, | ||
| 32 | const Eigen::Ref<const VectorXs>&) const>(&Model::calc), | ||
| 33 | bp::args("self", "data", "t", "u"), | ||
| 34 | "Compute the control value.\n\n" | ||
| 35 | ":param data: control-parametrization data\n" | ||
| 36 | ":param t: normalized time in [0, 1]\n" | ||
| 37 | ":param u: control parameters (dim control.nu)") | ||
| 38 | ✗ | .def("calcDiff", | |
| 39 | static_cast<void (Model::*)( | ||
| 40 | const std::shared_ptr<Data>&, const Scalar, | ||
| 41 | const Eigen::Ref<const VectorXs>&) const>(&Model::calcDiff), | ||
| 42 | bp::args("self", "data", "t", "u"), | ||
| 43 | "Compute the Jacobian of the control value with respect to the " | ||
| 44 | "control parameters.\n" | ||
| 45 | "It assumes that calc has been run first.\n\n" | ||
| 46 | ":param data: control-parametrization data\n" | ||
| 47 | ":param t: normalized time in [0, 1]\n" | ||
| 48 | ":param u: control parameters (dim control.nu)") | ||
| 49 | ✗ | .def("createData", &Model::createData, bp::args("self"), | |
| 50 | "Create the poly-zero data.") | ||
| 51 | ✗ | .def("params", | |
| 52 | static_cast<void (Model::*)( | ||
| 53 | const std::shared_ptr<Data>&, const Scalar, | ||
| 54 | const Eigen::Ref<const VectorXs>&) const>(&Model::params), | ||
| 55 | bp::args("self", "data", "t", "u"), | ||
| 56 | "Compute the control parameters.\n\n" | ||
| 57 | ":param data: control-parametrization data\n" | ||
| 58 | ":param t: normalized time in [0, 1]\n" | ||
| 59 | ":param w: control value (dim control.nw)") | ||
| 60 | ✗ | .def("convertBounds", &Model::convertBounds, | |
| 61 | bp::args("self", "u_lb", "u_ub"), | ||
| 62 | "Convert the bounds on the control to bounds on the control " | ||
| 63 | "parameters.\n\n" | ||
| 64 | ":param w_lb: lower bounds on w (dim control.nw)\n" | ||
| 65 | ":param w_ub: upper bounds on w (dim control.nw)\n" | ||
| 66 | ":return p_lb, p_ub: lower and upper bounds on the control " | ||
| 67 | "parameters (dim control.nu)") | ||
| 68 | ✗ | .def( | |
| 69 | "multiplyByJacobian", &Model::multiplyByJacobian_J, | ||
| 70 | bp::args("self", "data", "A"), | ||
| 71 | "Compute the product between the given matrix A and the derivative " | ||
| 72 | "of the control with respect to the " | ||
| 73 | "parameters.\n\n" | ||
| 74 | "It assumes that calc has been run first.\n" | ||
| 75 | ":param data: control-parametrization data\n" | ||
| 76 | ":param A: matrix to multiply (dim na x control.nw)\n" | ||
| 77 | ":return Product between A and the partial derivative of the value " | ||
| 78 | "function (dim na x control.nu)") | ||
| 79 | ✗ | .def("multiplyJacobianTransposeBy", | |
| 80 | &Model::multiplyJacobianTransposeBy_J, | ||
| 81 | bp::args("self", "data", "A"), | ||
| 82 | "Compute the product between the transpose of the derivative of " | ||
| 83 | "the " | ||
| 84 | "control with respect to the parameters\n" | ||
| 85 | "and a given matrix A.\n\n" | ||
| 86 | "It assumes that calc has been run first.\n" | ||
| 87 | ":param data: control-parametrization data\n" | ||
| 88 | ":param A: matrix to multiply (dim control.nw x na)\n" | ||
| 89 | ":return Product between the partial derivative of the value " | ||
| 90 | "function (transposed) and A (dim control.nu x " | ||
| 91 | "na)"); | ||
| 92 | ✗ | } | |
| 93 | }; | ||
| 94 | |||
| 95 | #define CROCODDYL_CONTROL_PARAMETRIZATION_MODEL_POLYZERO_PYTHON_BINDINGS( \ | ||
| 96 | Scalar) \ | ||
| 97 | typedef ControlParametrizationModelPolyZeroTpl<Scalar> Model; \ | ||
| 98 | typedef ControlParametrizationModelAbstractTpl<Scalar> ModelBase; \ | ||
| 99 | bp::register_ptr_to_python<std::shared_ptr<Model>>(); \ | ||
| 100 | bp::class_<Model, bp::bases<ModelBase>>( \ | ||
| 101 | "ControlParametrizationModelPolyZero", \ | ||
| 102 | "Constant control.\n\n" \ | ||
| 103 | "This control is a constant. The parameter vector corresponds to the " \ | ||
| 104 | "constant value of the differential control w, that is w=p.", \ | ||
| 105 | bp::init<std::size_t>( \ | ||
| 106 | bp::args("self", "nw"), \ | ||
| 107 | "Initialize the control dimensions.\n\n" \ | ||
| 108 | ":param nw: dimension of differential control space")) \ | ||
| 109 | .def(ControlParametrizationModelPolyZeroVisitor<Model>()) \ | ||
| 110 | .def(CastVisitor<Model>()) \ | ||
| 111 | .def(PrintableVisitor<Model>()) \ | ||
| 112 | .def(CopyableVisitor<Model>()); | ||
| 113 | |||
| 114 | ✗ | void exposeControlParametrizationPolyZero() { | |
| 115 | ✗ | CROCODDYL_CONTROL_PARAMETRIZATION_MODEL_POLYZERO_PYTHON_BINDINGS(double) | |
| 116 | ✗ | } | |
| 117 | |||
| 118 | } // namespace python | ||
| 119 | } // namespace crocoddyl | ||
| 120 |