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 "crocoddyl/core/activations/weighted-quadratic.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 exposeActivationWeightedQuad() { |
20 |
|
|
boost::python::register_ptr_to_python< |
21 |
|
10 |
boost::shared_ptr<ActivationModelWeightedQuad> >(); |
22 |
|
|
|
23 |
✓✗ |
10 |
bp::class_<ActivationModelWeightedQuad, bp::bases<ActivationModelAbstract> >( |
24 |
|
|
"ActivationModelWeightedQuad", |
25 |
|
|
"Weighted quadratic activation model.\n\n" |
26 |
|
|
"A weighted quadratic action describes a quadratic function that depends " |
27 |
|
|
"on the residual,\n" |
28 |
|
|
"i.e. 0.5 *||r||_w^2.", |
29 |
✓✗ |
10 |
bp::init<Eigen::VectorXd>( |
30 |
|
20 |
bp::args("self", "weights"), |
31 |
|
|
"Initialize the activation model.\n\n" |
32 |
|
|
":param weights: weights vector, note that nr=weights.size()")) |
33 |
|
|
.def("calc", &ActivationModelWeightedQuad::calc, |
34 |
✓✗ |
20 |
bp::args("self", "data", "r"), |
35 |
|
|
"Compute the 0.5 * ||r||_w^2.\n\n" |
36 |
|
|
":param data: activation data\n" |
37 |
✓✗ |
10 |
":param r: residual vector") |
38 |
|
|
.def("calcDiff", &ActivationModelWeightedQuad::calcDiff, |
39 |
✓✗ |
20 |
bp::args("self", "data", "r"), |
40 |
|
|
"Compute the derivatives of a quadratic function.\n\n" |
41 |
|
|
":param data: activation data\n" |
42 |
|
|
"Note that the Hessian is constant, so we don't write again this " |
43 |
|
|
"value.\n" |
44 |
|
|
"It assumes that calc has been run first.\n" |
45 |
✓✗ |
10 |
":param r: residual vector \n") |
46 |
|
|
.def("createData", &ActivationModelWeightedQuad::createData, |
47 |
✓✗✓✗
|
20 |
bp::args("self"), "Create the weighted quadratic action data.") |
48 |
|
|
.add_property("weights", |
49 |
|
|
bp::make_function(&ActivationModelWeightedQuad::get_weights, |
50 |
|
10 |
bp::return_internal_reference<>()), |
51 |
|
|
&ActivationModelWeightedQuad::set_weights, |
52 |
✓✗✓✗
|
10 |
"weights of the quadratic term") |
53 |
✓✗ |
10 |
.def(CopyableVisitor<ActivationModelWeightedQuad>()); |
54 |
|
10 |
} |
55 |
|
|
|
56 |
|
|
} // namespace python |
57 |
|
|
} // namespace crocoddyl |