| 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 "crocoddyl/core/activations/weighted-quadratic.hpp" | ||
| 12 | |||
| 13 | #include "python/crocoddyl/core/activation-base.hpp" | ||
| 14 | #include "python/crocoddyl/core/core.hpp" | ||
| 15 | |||
| 16 | namespace crocoddyl { | ||
| 17 | namespace python { | ||
| 18 | |||
| 19 | template <typename Model> | ||
| 20 | struct ActivationModelWeightedQuadVisitor | ||
| 21 | : public bp::def_visitor<ActivationModelWeightedQuadVisitor<Model>> { | ||
| 22 | typedef typename Model::Scalar Scalar; | ||
| 23 | template <class PyClass> | ||
| 24 | ✗ | void visit(PyClass& cl) const { | |
| 25 | ✗ | cl.def("calc", &Model::calc, bp::args("self", "data", "r"), | |
| 26 | "Compute the 0.5 * ||r||_w^2.\n\n" | ||
| 27 | ":param data: activation data\n" | ||
| 28 | ":param r: residual vector") | ||
| 29 | ✗ | .def("calcDiff", &Model::calcDiff, bp::args("self", "data", "r"), | |
| 30 | "Compute the derivatives of a quadratic function.\n\n" | ||
| 31 | ":param data: activation data\n" | ||
| 32 | "Note that the Hessian is constant, so we don't write again this " | ||
| 33 | "value.\n" | ||
| 34 | "It assumes that calc has been run first.\n" | ||
| 35 | ":param r: residual vector \n") | ||
| 36 | ✗ | .def("createData", &Model::createData, bp::args("self"), | |
| 37 | "Create the weighted quadratic action data.") | ||
| 38 | ✗ | .add_property("weights", | |
| 39 | bp::make_function(&Model::get_weights, | ||
| 40 | ✗ | bp::return_internal_reference<>()), | |
| 41 | &Model::set_weights, "weights of the quadratic term"); | ||
| 42 | ✗ | } | |
| 43 | }; | ||
| 44 | |||
| 45 | #define CROCODDYL_ACTIVATION_MODEL_WEIGHTEDQUAD_PYTHON_BINDINGS(Scalar) \ | ||
| 46 | typedef ActivationModelWeightedQuadTpl<Scalar> Model; \ | ||
| 47 | typedef ActivationModelAbstractTpl<Scalar> ModelBase; \ | ||
| 48 | typedef typename Model::VectorXs VectorXs; \ | ||
| 49 | bp::register_ptr_to_python<std::shared_ptr<Model>>(); \ | ||
| 50 | bp::class_<Model, bp::bases<ModelBase>>( \ | ||
| 51 | "ActivationModelWeightedQuad", \ | ||
| 52 | "Weighted quadratic activation model.\n\n" \ | ||
| 53 | "A weighted quadratic action describes a quadratic function that " \ | ||
| 54 | "depends on the residual, i.e., 0.5 *||r||_w^2.", \ | ||
| 55 | bp::init<VectorXs>( \ | ||
| 56 | bp::args("self", "weights"), \ | ||
| 57 | "Initialize the activation model.\n\n" \ | ||
| 58 | ":param weights: weights vector, note that nr=weights.size()")) \ | ||
| 59 | .def(ActivationModelWeightedQuadVisitor<Model>()) \ | ||
| 60 | .def(CastVisitor<Model>()) \ | ||
| 61 | .def(PrintableVisitor<Model>()) \ | ||
| 62 | .def(CopyableVisitor<Model>()); | ||
| 63 | |||
| 64 | ✗ | void exposeActivationWeightedQuad() { | |
| 65 | ✗ | CROCODDYL_ACTIVATION_MODEL_WEIGHTEDQUAD_PYTHON_BINDINGS(double) | |
| 66 | ✗ | } | |
| 67 | |||
| 68 | } // namespace python | ||
| 69 | } // namespace crocoddyl | ||
| 70 |