Directory: | ./ |
---|---|
File: | bindings/python/crocoddyl/core/activation-base.cpp |
Date: | 2025-01-16 08:47:40 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 26 | 28 | 92.9% |
Branches: | 23 | 46 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | ||
2 | // BSD 3-Clause License | ||
3 | // | ||
4 | // Copyright (C) 2019-2024, 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 | #include "python/crocoddyl/core/activation-base.hpp" | ||
11 | |||
12 | #include "python/crocoddyl/utils/copyable.hpp" | ||
13 | #include "python/crocoddyl/utils/printable.hpp" | ||
14 | |||
15 | namespace crocoddyl { | ||
16 | namespace python { | ||
17 | |||
18 | 10 | void exposeActivationAbstract() { | |
19 | 10 | bp::register_ptr_to_python<boost::shared_ptr<ActivationModelAbstract> >(); | |
20 | |||
21 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | bp::class_<ActivationModelAbstract_wrap, boost::noncopyable>( |
22 | "ActivationModelAbstract", | ||
23 | "Abstract class for activation models.\n\n" | ||
24 | "In crocoddyl, an activation model takes the residual vector and " | ||
25 | "computes the activation\n" | ||
26 | "value and its derivatives from it. Activation value and its derivatives " | ||
27 | "are computed by\n" | ||
28 | "calc() and calcDiff(), respectively.", | ||
29 |
1/2✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
|
20 | bp::init<std::size_t>(bp::args("self", "nr"), |
30 | "Initialize the activation model.\n\n" | ||
31 | ":param nr: dimension of the cost-residual vector")) | ||
32 |
2/4✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
|
10 | .def("calc", pure_virtual(&ActivationModelAbstract_wrap::calc), |
33 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::args("self", "data", "r"), |
34 | "Compute the activation value.\n\n" | ||
35 | ":param data: activation data\n" | ||
36 | ":param r: residual vector") | ||
37 |
2/4✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
|
10 | .def("calcDiff", pure_virtual(&ActivationModelAbstract_wrap::calcDiff), |
38 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::args("self", "data", "r"), |
39 | "Compute the derivatives of the residual.\n\n" | ||
40 | "It computes the partial derivatives of the residual vector " | ||
41 | "function\n" | ||
42 | ":param data: activation data\n" | ||
43 | ":param r: residual vector \n") | ||
44 | 20 | .def("createData", &ActivationModelAbstract_wrap::createData, | |
45 |
2/4✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
|
20 | &ActivationModelAbstract_wrap::default_createData, bp::args("self"), |
46 | "Create the activation data.\n\n") | ||
47 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .add_property("nr", |
48 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::make_function(&ActivationModelAbstract_wrap::get_nr), |
49 | "dimension of cost-residual vector") | ||
50 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .def(PrintableVisitor<ActivationModelAbstract>()); |
51 | |||
52 | 10 | bp::register_ptr_to_python<boost::shared_ptr<ActivationDataAbstract> >(); | |
53 | |||
54 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | bp::class_<ActivationDataAbstract>( |
55 | "ActivationDataAbstract", "Abstract class for activation data.\n\n", | ||
56 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | bp::init<ActivationModelAbstract*>( |
57 | 20 | bp::args("self", "model"), | |
58 | "Create common data shared between AMs.\n\n" | ||
59 | "The action data uses the model in order to first process it.\n" | ||
60 | ":param model: action model")) | ||
61 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .add_property( |
62 | "a_value", | ||
63 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | bp::make_getter(&ActivationDataAbstract::a_value, |
64 | ✗ | bp::return_value_policy<bp::return_by_value>()), | |
65 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::make_setter(&ActivationDataAbstract::a_value), "cost value") |
66 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .add_property("Ar", |
67 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | bp::make_getter(&ActivationDataAbstract::Ar, |
68 | ✗ | bp::return_internal_reference<>()), | |
69 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::make_setter(&ActivationDataAbstract::Ar), |
70 | "Jacobian of the residual") | ||
71 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .add_property("Arr", &ActivationDataAbstract::getHessianMatrix, |
72 | &ActivationDataAbstract::setHessianMatrix, | ||
73 | "Hessian of the residual") | ||
74 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .def(CopyableVisitor<ActivationDataAbstract>()); |
75 | 10 | } | |
76 | |||
77 | } // namespace python | ||
78 | } // namespace crocoddyl | ||
79 |