1 |
|
|
/////////////////////////////////////////////////////////////////////////////// |
2 |
|
|
// BSD 3-Clause License |
3 |
|
|
// |
4 |
|
|
// Copyright (C) 2020-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 "crocoddyl/core/activations/quadratic-flat-exp.hpp" |
11 |
|
|
|
12 |
|
|
#include "python/crocoddyl/core/activation-base.hpp" |
13 |
|
|
#include "python/crocoddyl/core/core.hpp" |
14 |
|
|
#include "python/crocoddyl/utils/copyable.hpp" |
15 |
|
|
|
16 |
|
|
namespace crocoddyl { |
17 |
|
|
namespace python { |
18 |
|
|
|
19 |
|
10 |
void exposeActivationQuadFlatExp() { |
20 |
|
|
boost::python::register_ptr_to_python< |
21 |
|
10 |
boost::shared_ptr<ActivationModelQuadFlatExp> >(); |
22 |
|
|
|
23 |
✓✗ |
10 |
bp::class_<ActivationModelQuadFlatExp, bp::bases<ActivationModelAbstract> >( |
24 |
|
|
"ActivationModelQuadFlatExp", |
25 |
|
|
"Quadratic flat activation model.\n\n" |
26 |
|
|
"A quadratic flat action describes a quadratic flat function that " |
27 |
|
|
"depends on the residual, i.e.\n" |
28 |
|
|
"1 - exp(-||r||^2 / alpha).", |
29 |
✓✗ |
20 |
bp::init<int, double>(bp::args("self", "nr", "alpha"), |
30 |
|
|
"Initialize the activation model.\n\n" |
31 |
|
|
":param nr: dimension of the cost-residual vector" |
32 |
|
|
"param alpha: width of quadratic basin near zero")) |
33 |
|
|
.def("calc", &ActivationModelQuadFlatExp::calc, |
34 |
✓✗ |
20 |
bp::args("self", "data", "r"), |
35 |
|
|
"Compute the 1 - exp(-||r||^2 / alpha).\n\n" |
36 |
|
|
":param data: activation data\n" |
37 |
✓✗ |
10 |
":param r: residual vector") |
38 |
|
|
.def("calcDiff", &ActivationModelQuadFlatExp::calcDiff, |
39 |
✓✗ |
20 |
bp::args("self", "data", "r"), |
40 |
|
|
"Compute the derivatives of a quadratic flat function.\n\n" |
41 |
|
|
"Note that the Hessian is constant, so we don't write again this " |
42 |
|
|
"value.\n" |
43 |
|
|
":param data: activation data\n" |
44 |
✓✗ |
10 |
":param r: residual vector \n") |
45 |
|
|
.def("createData", &ActivationModelQuadFlatExp::createData, |
46 |
✓✗✓✗
|
20 |
bp::args("self"), "Create the quadratic flat activation data.\n\n") |
47 |
|
|
.add_property( |
48 |
✓✗ |
10 |
"alpha", bp::make_function(&ActivationModelQuadFlatExp::get_alpha), |
49 |
✓✗✓✗
|
30 |
bp::make_function(&ActivationModelQuadFlatExp::set_alpha), "alpha") |
50 |
✓✗ |
10 |
.def(CopyableVisitor<ActivationModelQuadFlatExp>()); |
51 |
|
10 |
} |
52 |
|
|
|
53 |
|
|
} // namespace python |
54 |
|
|
} // namespace crocoddyl |