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/smooth-2norm.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 exposeActivationSmooth2Norm() { |
20 |
|
|
boost::python::register_ptr_to_python< |
21 |
|
10 |
boost::shared_ptr<ActivationModelSmooth2Norm> >(); |
22 |
|
|
|
23 |
✓✗ |
10 |
bp::class_<ActivationModelSmooth2Norm, bp::bases<ActivationModelAbstract> >( |
24 |
|
|
"ActivationModelSmooth2Norm", |
25 |
|
|
"Smooth-2Norm activation model.\n\n" |
26 |
|
|
"It describes a smooth representation of a 2-norm, i.e.\n" |
27 |
|
|
"sqrt{eps + sum^nr_{i=0} ||ri||^2}, where ri is the scalar residual for " |
28 |
|
|
"the i constraints,\n." |
29 |
|
|
"and nr is the dimension of the residual vector.", |
30 |
✓✗ |
10 |
bp::init<int, bp::optional<double> >( |
31 |
|
20 |
bp::args("self", "nr", "eps"), |
32 |
|
|
"Initialize the activation model.\n\n" |
33 |
|
|
":param nr: dimension of the residual vector\n" |
34 |
|
|
":param eps: smoothing factor (default: 1.)")) |
35 |
|
|
.def("calc", &ActivationModelSmooth2Norm::calc, |
36 |
✓✗ |
20 |
bp::args("self", "data", "r"), |
37 |
|
|
"Compute the smooth-2norm function.\n\n" |
38 |
|
|
":param data: activation data\n" |
39 |
✓✗ |
10 |
":param r: residual vector") |
40 |
|
|
.def("calcDiff", &ActivationModelSmooth2Norm::calcDiff, |
41 |
✓✗ |
20 |
bp::args("self", "data", "r"), |
42 |
|
|
"Compute the derivatives of a smooth-2norm function.\n\n" |
43 |
|
|
"It assumes that calc has been run first.\n" |
44 |
|
|
":param data: activation data\n" |
45 |
✓✗ |
10 |
":param r: residual vector \n") |
46 |
|
|
.def("createData", &ActivationModelSmooth2Norm::createData, |
47 |
✓✗✓✗
|
20 |
bp::args("self"), "Create the smooth-2norm activation data.\n\n") |
48 |
✓✗ |
10 |
.def(CopyableVisitor<ActivationModelSmooth2Norm>()); |
49 |
|
10 |
} |
50 |
|
|
|
51 |
|
|
} // namespace python |
52 |
|
|
} // namespace crocoddyl |