1 |
|
|
/////////////////////////////////////////////////////////////////////////////// |
2 |
|
|
// BSD 3-Clause License |
3 |
|
|
// |
4 |
|
|
// Copyright (C) 2019-2023, 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 |
✓✗ |
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 |
✓✗ |
20 |
bp::init<int>(bp::args("self", "nr"), |
30 |
|
|
"Initialize the activation model.\n\n" |
31 |
|
|
":param nr: dimension of the cost-residual vector")) |
32 |
|
|
.def("calc", pure_virtual(&ActivationModelAbstract_wrap::calc), |
33 |
✓✗ |
20 |
bp::args("self", "data", "r"), |
34 |
|
|
"Compute the activation value.\n\n" |
35 |
|
|
":param data: activation data\n" |
36 |
✓✗✓✗
|
10 |
":param r: residual vector") |
37 |
|
|
.def("calcDiff", pure_virtual(&ActivationModelAbstract_wrap::calcDiff), |
38 |
✓✗ |
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 |
✓✗✓✗
|
10 |
":param r: residual vector \n") |
44 |
|
|
.def("createData", &ActivationModelAbstract_wrap::createData, |
45 |
✓✗ |
20 |
&ActivationModelAbstract_wrap::default_createData, bp::args("self"), |
46 |
✓✗ |
10 |
"Create the activation data.\n\n") |
47 |
|
|
.add_property("nr", |
48 |
✓✗ |
20 |
bp::make_function(&ActivationModelAbstract_wrap::get_nr), |
49 |
✓✗ |
10 |
"dimension of cost-residual vector") |
50 |
✓✗ |
10 |
.def(PrintableVisitor<ActivationModelAbstract>()); |
51 |
|
|
|
52 |
|
10 |
bp::register_ptr_to_python<boost::shared_ptr<ActivationDataAbstract> >(); |
53 |
|
|
|
54 |
✓✗ |
10 |
bp::class_<ActivationDataAbstract>( |
55 |
|
|
"ActivationDataAbstract", "Abstract class for activation data.\n\n", |
56 |
✓✗ |
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 |
|
|
.add_property( |
62 |
|
|
"a_value", |
63 |
✓✗ |
10 |
bp::make_getter(&ActivationDataAbstract::a_value, |
64 |
|
|
bp::return_value_policy<bp::return_by_value>()), |
65 |
✓✗✓✗
|
30 |
bp::make_setter(&ActivationDataAbstract::a_value), "cost value") |
66 |
|
|
.add_property("Ar", |
67 |
✓✗ |
10 |
bp::make_getter(&ActivationDataAbstract::Ar, |
68 |
|
|
bp::return_internal_reference<>()), |
69 |
✓✗ |
20 |
bp::make_setter(&ActivationDataAbstract::Ar), |
70 |
✓✗ |
10 |
"Jacobian of the residual") |
71 |
|
|
.add_property("Arr", &ActivationDataAbstract::getHessianMatrix, |
72 |
|
|
&ActivationDataAbstract::setHessianMatrix, |
73 |
✓✗ |
10 |
"Hessian of the residual") |
74 |
✓✗ |
10 |
.def(CopyableVisitor<ActivationDataAbstract>()); |
75 |
|
10 |
} |
76 |
|
|
|
77 |
|
|
} // namespace python |
78 |
|
|
} // namespace crocoddyl |