| 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 double | ||
| 11 | #include "python/crocoddyl/core/activation-base.hpp" | ||
| 12 | |||
| 13 | namespace crocoddyl { | ||
| 14 | namespace python { | ||
| 15 | |||
| 16 | template <typename Model> | ||
| 17 | struct ActivationModelAbstractVisitor | ||
| 18 | : public bp::def_visitor<ActivationModelAbstractVisitor<Model>> { | ||
| 19 | template <class PyClass> | ||
| 20 | ✗ | void visit(PyClass& cl) const { | |
| 21 | ✗ | cl.def("calc", pure_virtual(&Model::calc), bp::args("self", "data", "r"), | |
| 22 | "Compute the activation value.\n\n" | ||
| 23 | ":param data: activation data\n" | ||
| 24 | ":param r: residual vector") | ||
| 25 | ✗ | .def("calcDiff", pure_virtual(&Model::calcDiff), | |
| 26 | bp::args("self", "data", "r"), | ||
| 27 | "Compute the derivatives of the residual.\n\n" | ||
| 28 | "It computes the partial derivatives of the residual vector " | ||
| 29 | "function.\n" | ||
| 30 | ":param data: activation data\n" | ||
| 31 | ":param r: residual vector \n") | ||
| 32 | ✗ | .def("createData", &Model::createData, &Model::default_createData, | |
| 33 | bp::args("self"), "Create the activation data.\n\n") | ||
| 34 | ✗ | .add_property("nr", bp::make_function(&Model::get_nr), | |
| 35 | "dimension of cost-residual vector"); | ||
| 36 | ✗ | } | |
| 37 | }; | ||
| 38 | |||
| 39 | template <typename Data> | ||
| 40 | struct ActivationDataAbstractVisitor | ||
| 41 | : public bp::def_visitor<ActivationDataAbstractVisitor<Data>> { | ||
| 42 | template <class PyClass> | ||
| 43 | ✗ | void visit(PyClass& cl) const { | |
| 44 | ✗ | cl.add_property( | |
| 45 | "a_value", | ||
| 46 | ✗ | bp::make_getter(&Data::a_value, | |
| 47 | ✗ | bp::return_value_policy<bp::return_by_value>()), | |
| 48 | ✗ | bp::make_setter(&Data::a_value), "cost value") | |
| 49 | ✗ | .add_property( | |
| 50 | ✗ | "Ar", bp::make_getter(&Data::Ar, bp::return_internal_reference<>()), | |
| 51 | ✗ | bp::make_setter(&Data::Ar), "Jacobian of the residual") | |
| 52 | ✗ | .add_property("Arr", &Data::getHessianMatrix, &Data::setHessianMatrix, | |
| 53 | "Hessian of the residual"); | ||
| 54 | ✗ | } | |
| 55 | }; | ||
| 56 | |||
| 57 | #define CROCODDYL_ACTIVATION_MODEL_ABSTRACT_PYTHON_BINDINGS(Scalar) \ | ||
| 58 | typedef ActivationModelAbstractTpl<Scalar> Model; \ | ||
| 59 | typedef ActivationModelAbstractTpl_wrap<Scalar> Model_wrap; \ | ||
| 60 | bp::register_ptr_to_python<std::shared_ptr<Model>>(); \ | ||
| 61 | bp::class_<Model_wrap, boost::noncopyable>( \ | ||
| 62 | "ActivationModelAbstract", \ | ||
| 63 | "Abstract class for activation models.\n\n" \ | ||
| 64 | "In crocoddyl, an activation model takes the residual vector and " \ | ||
| 65 | "computes the activation value and its derivatives from it. Activation " \ | ||
| 66 | "value and its derivatives are computed by calc() and calcDiff(), " \ | ||
| 67 | "respectively.", \ | ||
| 68 | bp::init<std::size_t>( \ | ||
| 69 | bp::args("self", "nr"), \ | ||
| 70 | "Initialize the activation model.\n\n" \ | ||
| 71 | ":param nr: dimension of the cost-residual vector")) \ | ||
| 72 | .def(ActivationModelAbstractVisitor<Model_wrap>()) \ | ||
| 73 | .def(PrintableVisitor<Model_wrap>()) \ | ||
| 74 | .def(CopyableVisitor<Model_wrap>()); | ||
| 75 | |||
| 76 | #define CROCODDYL_ACTIVATION_DATA_ABSTRACT_PYTHON_BINDINGS(Scalar) \ | ||
| 77 | typedef ActivationDataAbstractTpl<Scalar> Data; \ | ||
| 78 | typedef ActivationModelAbstractTpl<Scalar> Model; \ | ||
| 79 | bp::register_ptr_to_python<std::shared_ptr<Data>>(); \ | ||
| 80 | bp::class_<Data>( \ | ||
| 81 | "ActivationDataAbstract", "Abstract class for activation data.\n\n", \ | ||
| 82 | bp::init<Model*>( \ | ||
| 83 | bp::args("self", "model"), \ | ||
| 84 | "Create common data shared between AMs.\n\n" \ | ||
| 85 | "The action data uses the model in order to first process it.\n" \ | ||
| 86 | ":param model: action model")) \ | ||
| 87 | .def(ActivationDataAbstractVisitor<Data>()) \ | ||
| 88 | .def(CopyableVisitor<Data>()); | ||
| 89 | |||
| 90 | ✗ | void exposeActivationAbstract() { | |
| 91 | ✗ | CROCODDYL_ACTIVATION_MODEL_ABSTRACT_PYTHON_BINDINGS(double) | |
| 92 | ✗ | CROCODDYL_ACTIVATION_DATA_ABSTRACT_PYTHON_BINDINGS(double) | |
| 93 | ✗ | } | |
| 94 | |||
| 95 | } // namespace python | ||
| 96 | } // namespace crocoddyl | ||
| 97 |