GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/core/activations/2norm-barrier-float.cpp
Date: 2025-04-18 16:41:15
Exec Total Coverage
Lines: 0 8 0.0%
Branches: 0 28 0.0%

Line Branch Exec Source
1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (C) 2021-2025, LAAS-CNRS, Heriot-Watt University
5 // Copyright note valid unless otherwise stated in individual files.
6 // All rights reserved.
7 ///////////////////////////////////////////////////////////////////////////////
8
9 // Auto-generated file for float
10 #include "crocoddyl/core/activations/2norm-barrier.hpp"
11
12 #include "python/crocoddyl/core/activation-base.hpp"
13 #include "python/crocoddyl/core/core.hpp"
14
15 namespace crocoddyl {
16 namespace python {
17
18 template <typename Model>
19 struct ActivationModel2NormBarrierVisitor
20 : public bp::def_visitor<ActivationModel2NormBarrierVisitor<Model>> {
21 typedef typename Model::Scalar Scalar;
22 template <class PyClass>
23 void visit(PyClass& cl) const {
24 cl.def("calc", &Model::calc, bp::args("self", "data", "r"),
25 "Compute the activation value.\n\n"
26 ":param data: activation data\n"
27 ":param r: residual vector")
28 .def("calcDiff", &Model::calcDiff, bp::args("self", "data", "r"),
29 "Compute the derivatives of the collision function.\n\n"
30 ":param data: activation data\n"
31 ":param r: residual vector \n")
32 .def("createData", &Model::createData, bp::args("self"),
33 "Create the collision activation data.\n\n")
34 .add_property(
35 "alpha",
36 bp::make_function(&Model::get_alpha,
37 bp::return_value_policy<bp::return_by_value>()),
38 bp::make_function(&Model::set_alpha), "alpha");
39 }
40 };
41
42 #define CROCODDYL_ACTIVATION_MODEL_2NORM_BARRIER_PYTHON_BINDINGS(Scalar) \
43 typedef ActivationModel2NormBarrierTpl<Scalar> Model; \
44 typedef ActivationModelAbstractTpl<Scalar> ModelBase; \
45 bp::register_ptr_to_python<std::shared_ptr<Model>>(); \
46 bp::class_<Model, bp::bases<ModelBase>>( \
47 "ActivationModel2NormBarrier", \
48 "An 2-norm activation model for a defined barrier alpha\n\n" \
49 "If the residual is lower than an alpha threshold, this function " \
50 "imposes a quadratic term. In short, the activation value is 0 if the " \
51 "residual is major or equals alpha, otherwise, it is equals to 0.5 " \
52 "*(||r|| - alpha)^2", \
53 bp::init<std::size_t, bp::optional<Scalar, bool>>( \
54 bp::args("self", "nr", "alpha", "true_hessian"), \
55 "Initialize the activation model.\n\n" \
56 ":param nr: dimension of the cost-residual vector\n" \
57 ":param alpha: activation threshold (default 0.1)\n" \
58 ":param true_hessian: use true Hessian in calcDiff if true, " \
59 "else Gauss-Newton approximation (default false)")) \
60 .def(ActivationModel2NormBarrierVisitor<Model>()) \
61 .def(CastVisitor<Model>()) \
62 .def(PrintableVisitor<Model>()) \
63 .def(CopyableVisitor<Model>());
64
65 void exposeActivation2NormBarrier() {
66 CROCODDYL_ACTIVATION_MODEL_2NORM_BARRIER_PYTHON_BINDINGS(float)
67 }
68
69 } // namespace python
70 } // namespace crocoddyl
71