Directory: | ./ |
---|---|
File: | bindings/python/crocoddyl/core/actuation/squashing/smooth-sat.cpp |
Date: | 2025-03-26 19:23:43 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 9 | 9 | 100.0% |
Branches: | 25 | 50 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | ||
2 | // BSD 3-Clause License | ||
3 | // | ||
4 | // Copyright (C) 2019-2024, University of Edinburgh, IRI: CSIC-UPC | ||
5 | // Heriot-Watt University | ||
6 | // Copyright note valid unless otherwise stated in individual files. | ||
7 | // All rights reserved. | ||
8 | /////////////////////////////////////////////////////////////////////////////// | ||
9 | |||
10 | #include "crocoddyl/core/actuation/squashing/smooth-sat.hpp" | ||
11 | |||
12 | #include "python/crocoddyl/core/actuation/squashing-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 | template <typename Model> | ||
20 | struct SquashingSmoothSatVisitor | ||
21 | : public bp::def_visitor<SquashingSmoothSatVisitor<Model>> { | ||
22 | template <class PyClass> | ||
23 | 40 | void visit(PyClass& cl) const { | |
24 | 40 | cl.def("calc", &Model::calc, bp::args("self", "data", "s"), | |
25 | "Compute the squashing value for a given value of s, " | ||
26 | "component-wise. \n\n" | ||
27 | ":param data: squashing data\n" | ||
28 | ":param s: control input") | ||
29 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
80 | .def("calcDiff", &Model::calcDiff, bp::args("self", "data", "s"), |
30 | "Compute the derivative of the squashing function.\n\n" | ||
31 | ":param data: squashing data\n" | ||
32 | ":param s: squashing input.") | ||
33 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
80 | .def("createData", &Model::createData, bp::args("self"), |
34 | "Create the squashing data.\n\n") | ||
35 |
4/8✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 20 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 20 times.
✗ Branch 11 not taken.
|
40 | .add_property("smooth", bp::make_function(&Model::get_smooth), |
36 | bp::make_function(&Model::set_smooth), | ||
37 | "Smoothness parameter of the smooth sat. function"); | ||
38 | 40 | } | |
39 | }; | ||
40 | |||
41 | #define CROCODDYL_SQUASHING_SMOOTH_SAT_PYTHON_BINDINGS(Scalar) \ | ||
42 | typedef SquashingModelSmoothSatTpl<Scalar> Model; \ | ||
43 | typedef SquashingModelAbstractTpl<Scalar> ModelBase; \ | ||
44 | typedef Model::VectorXs VectorXs; \ | ||
45 | bp::register_ptr_to_python<std::shared_ptr<Model>>(); \ | ||
46 | bp::class_<Model, bp::bases<ModelBase>>( \ | ||
47 | "SquashingModelSmoothSat", "Smooth Sat squashing model", \ | ||
48 | bp::init<VectorXs, VectorXs, std::size_t>( \ | ||
49 | bp::args("self", "u_lb", "u_ub", "ns"), \ | ||
50 | "Initialize the squashing model.\n\n" \ | ||
51 | ":param u_lb: output lower bound\n" \ | ||
52 | ":param u_ub: output upper bound\n" \ | ||
53 | ":param ns: dimension of the input vector")) \ | ||
54 | .def(SquashingSmoothSatVisitor<Model>()) \ | ||
55 | .def(CastVisitor<Model>()) \ | ||
56 | .def(PrintableVisitor<Model>()) \ | ||
57 | .def(CopyableVisitor<Model>()); | ||
58 | |||
59 | 10 | void exposeSquashingSmoothSat() { | |
60 |
17/34✓ Branch 3 taken 10 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 10 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 10 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 10 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 10 times.
✗ Branch 19 not taken.
✓ Branch 24 taken 10 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 10 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 10 times.
✗ Branch 31 not taken.
✓ Branch 35 taken 10 times.
✗ Branch 36 not taken.
✓ Branch 38 taken 10 times.
✗ Branch 39 not taken.
✓ Branch 41 taken 10 times.
✗ Branch 42 not taken.
✓ Branch 44 taken 10 times.
✗ Branch 45 not taken.
✓ Branch 47 taken 10 times.
✗ Branch 48 not taken.
✓ Branch 50 taken 10 times.
✗ Branch 51 not taken.
✓ Branch 53 taken 10 times.
✗ Branch 54 not taken.
✓ Branch 56 taken 10 times.
✗ Branch 57 not taken.
|
20 | CROCODDYL_PYTHON_SCALARS(CROCODDYL_SQUASHING_SMOOTH_SAT_PYTHON_BINDINGS) |
61 | 10 | } | |
62 | |||
63 | } // namespace python | ||
64 | } // namespace crocoddyl | ||
65 |