GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/core/activations/2norm-barrier.cpp
Date: 2025-01-16 08:47:40
Exec Total Coverage
Lines: 15 16 93.8%
Branches: 12 24 50.0%

Line Branch Exec Source
1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (C) 2021-2023, LAAS-CNRS, Heriot-Watt University
5 // Copyright note valid unless otherwise stated in individual files.
6 // All rights reserved.
7 ///////////////////////////////////////////////////////////////////////////////
8
9 #include "crocoddyl/core/activations/2norm-barrier.hpp"
10
11 #include "python/crocoddyl/core/activation-base.hpp"
12 #include "python/crocoddyl/core/core.hpp"
13 #include "python/crocoddyl/utils/copyable.hpp"
14
15 namespace crocoddyl {
16 namespace python {
17
18 10 void exposeActivation2NormBarrier() {
19
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::class_<ActivationModel2NormBarrier, bp::bases<ActivationModelAbstract> >(
20 "ActivationModel2NormBarrier",
21 "An 2-norm activation model for a defined barrier alpha\n\n"
22 "If the residual is lower than an alpha threshold, this function imposes "
23 "a quadratic term. \n"
24 "In short, the activation value is 0 if the residual is major or equals "
25 "to alpha, otherwise, it is \n"
26 "equals to 0.5 *(||r|| - alpha)^2",
27
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::init<std::size_t, bp::optional<double, bool> >(
28 20 bp::args("self", "nr", "alpha", "true_hessian"),
29 "Initialize the activation model.\n\n"
30 ":param nr: dimension of the cost-residual vector\n"
31 ":param alpha: activation threshold (default 0.1)\n"
32 ":param true_hessian: use true Hessian in calcDiff if true, "
33 "else Gauss-Newton approximation (default false)"))
34
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def("calc", &ActivationModel2NormBarrier::calc,
35
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "r"),
36 "Compute the activation value.\n\n"
37 ":param data: activation data\n"
38 ":param r: residual vector")
39
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def("calcDiff", &ActivationModel2NormBarrier::calcDiff,
40
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "r"),
41 "Compute the derivatives of the collision function.\n\n"
42 ":param data: activation data\n"
43 ":param r: residual vector \n")
44
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def("createData", &ActivationModel2NormBarrier::createData,
45
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self"), "Create the collision activation data.\n\n")
46
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property(
47 "alpha",
48
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_function(&ActivationModel2NormBarrier::get_alpha,
49 bp::return_value_policy<bp::return_by_value>()),
50
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::make_function(&ActivationModel2NormBarrier::set_alpha), "alpha")
51
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def(CopyableVisitor<ActivationModel2NormBarrier>());
52 10 }
53
54 } // namespace python
55 } // namespace crocoddyl
56