Line |
Branch |
Exec |
Source |
1 |
|
|
/////////////////////////////////////////////////////////////////////////////// |
2 |
|
|
// BSD 3-Clause License |
3 |
|
|
// |
4 |
|
|
// Copyright (C) 2020-2025, 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 |
|
|
// Auto-generated file for double |
11 |
|
|
#include "crocoddyl/core/activations/quadratic-flat-log.hpp" |
12 |
|
|
|
13 |
|
|
#include "python/crocoddyl/core/activation-base.hpp" |
14 |
|
|
#include "python/crocoddyl/core/core.hpp" |
15 |
|
|
|
16 |
|
|
namespace crocoddyl { |
17 |
|
|
namespace python { |
18 |
|
|
|
19 |
|
|
template <typename Model> |
20 |
|
|
struct ActivationModelQuadFlatLogVisitor |
21 |
|
|
: public bp::def_visitor<ActivationModelQuadFlatLogVisitor<Model>> { |
22 |
|
|
typedef typename Model::Scalar Scalar; |
23 |
|
|
template <class PyClass> |
24 |
|
✗ |
void visit(PyClass& cl) const { |
25 |
|
✗ |
cl.def("calc", &Model::calc, bp::args("self", "data", "r"), |
26 |
|
|
"Compute the log(1 + ||r||^2 / alpha).\n" |
27 |
|
|
":param data: activation data\n" |
28 |
|
|
":param r: residual vector") |
29 |
|
✗ |
.def("calcDiff", &Model::calcDiff, bp::args("self", "data", "r"), |
30 |
|
|
"Compute the derivatives of a quadratic flat function.\n" |
31 |
|
|
"Note that the Hessian is constant, so we don't write again this " |
32 |
|
|
"value.\n" |
33 |
|
|
":param data: activation data\n" |
34 |
|
|
":param r: residual vector \n") |
35 |
|
✗ |
.def("createData", &Model::createData, bp::args("self"), |
36 |
|
|
"Create the quadratic flat activation data.\n") |
37 |
|
✗ |
.add_property("alpha", bp::make_function(&Model::get_alpha), |
38 |
|
|
bp::make_function(&Model::set_alpha), "alpha"); |
39 |
|
|
} |
40 |
|
|
}; |
41 |
|
|
|
42 |
|
|
#define CROCODDYL_ACTIVATION_MODEL_QUADFLATLOG_PYTHON_BINDINGS(Scalar) \ |
43 |
|
|
typedef ActivationModelQuadFlatLogTpl<Scalar> Model; \ |
44 |
|
|
typedef ActivationModelAbstractTpl<Scalar> ModelBase; \ |
45 |
|
|
bp::register_ptr_to_python<std::shared_ptr<Model>>(); \ |
46 |
|
|
bp::class_<Model, bp::bases<ModelBase>>( \ |
47 |
|
|
"ActivationModelQuadFlatLog", \ |
48 |
|
|
"Quadratic flat activation model.\n" \ |
49 |
|
|
"A quadratic flat action describes a quadratic flat function that " \ |
50 |
|
|
"depends on the residual, i.e., log(1 + ||r||^2 / alpha).", \ |
51 |
|
|
bp::init<std::size_t, Scalar>( \ |
52 |
|
|
bp::args("self", "nr", "alpha"), \ |
53 |
|
|
"Initialize the activation model.\n\n" \ |
54 |
|
|
":param nr: dimension of the cost-residual vector" \ |
55 |
|
|
"param alpha: width of quadratic basin near zero")) \ |
56 |
|
|
.def(ActivationModelQuadFlatLogVisitor<Model>()) \ |
57 |
|
|
.def(CastVisitor<Model>()) \ |
58 |
|
|
.def(PrintableVisitor<Model>()) \ |
59 |
|
|
.def(CopyableVisitor<Model>()); |
60 |
|
|
|
61 |
|
✗ |
void exposeActivationQuadFlatLog() { |
62 |
|
✗ |
CROCODDYL_ACTIVATION_MODEL_QUADFLATLOG_PYTHON_BINDINGS(double) |
63 |
|
|
} |
64 |
|
|
|
65 |
|
|
} // namespace python |
66 |
|
|
} // namespace crocoddyl |
67 |
|
|
|