GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/core/actuation/squashing-base-double.cpp
Date: 2025-04-18 16:41:15
Exec Total Coverage
Lines: 0 18 0.0%
Branches: 0 58 0.0%

Line Branch Exec Source
1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (C) 2019-2025, 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 // Auto-generated file for double
11 #include "python/crocoddyl/core/actuation/squashing-base.hpp"
12
13 namespace crocoddyl {
14 namespace python {
15
16 template <typename Model>
17 struct SquashingModelAbstractVisitor
18 : public bp::def_visitor<SquashingModelAbstractVisitor<Model>> {
19 template <class PyClass>
20 void visit(PyClass& cl) const {
21 cl.def("calc", pure_virtual(&Model::calc), bp::args("self", "data", "s"),
22 "Compute the squashing value for a given value of u, "
23 "component-wise. \n\n"
24 ":param data: squashing data\n"
25 ":param s: squashing input")
26 .def("calcDiff", pure_virtual(&Model::calcDiff),
27 bp::args("self", "data", "s"),
28 "Compute the derivative of the squashing function.\n\n"
29 "It assumes that calc has been run first.\n"
30 ":param data: squashing data\n"
31 ":param u: squashing input")
32 .def("createData", &Model::createData, bp::args("self"),
33 "Create the squashing data.\n\n")
34 .add_property(
35 "ns",
36 bp::make_function(&Model::get_ns,
37 bp::return_value_policy<bp::return_by_value>()),
38 "dimension of the squashing vector")
39 .add_property(
40 "s_lb",
41 bp::make_function(&Model::get_s_lb,
42 bp::return_value_policy<bp::return_by_value>()),
43 bp::make_function(&Model::set_s_lb),
44 "lower bound for the active zone of the squashing function")
45 .add_property(
46 "s_ub",
47 bp::make_function(&Model::get_s_ub,
48 bp::return_value_policy<bp::return_by_value>()),
49 bp::make_function(&Model::set_s_ub),
50 "upper bound for the active zone of the squashing function");
51 }
52 };
53
54 template <typename Data>
55 struct SquashingDataAbstractVisitor
56 : public bp::def_visitor<SquashingDataAbstractVisitor<Data>> {
57 template <class PyClass>
58 void visit(PyClass& cl) const {
59 cl.add_property(
60 "u", bp::make_getter(&Data::u, bp::return_internal_reference<>()),
61 bp::make_setter(&Data::u), "squashing-output")
62 .add_property(
63 "du_ds",
64 bp::make_getter(&Data::du_ds, bp::return_internal_reference<>()),
65 bp::make_setter(&Data::du_ds),
66 "Jacobian of the squashing function");
67 }
68 };
69
70 #define CROCODDYL_SQUASHING_MODEL_ABSTRACT_PYTHON_BINDINGS(Scalar) \
71 typedef SquashingModelAbstractTpl<Scalar> Model; \
72 typedef SquashingModelAbstractTpl_wrap<Scalar> Model_wrap; \
73 bp::register_ptr_to_python<std::shared_ptr<Model>>(); \
74 bp::class_<Model_wrap, boost::noncopyable>( \
75 "SquashingModelAbstract", \
76 "Abstract class for squashing functions.\n\n" \
77 "A squashing function is any sigmoid function that maps from R to a " \
78 "bounded domain Its input can be any value and its output will be a " \
79 "value between a lower bound and an upper bound. The computation of " \
80 "the output value is done using calc() while its derivative is " \
81 "computed using calcDiff(), respectively.", \
82 bp::init<std::size_t>(bp::args("self", "ns"), \
83 "Initialize the squashing model.\n\n" \
84 ":param ns: dimension of the input vector")) \
85 .def(SquashingModelAbstractVisitor<Model_wrap>()) \
86 .def(CopyableVisitor<Model_wrap>());
87
88 #define CROCODDYL_SQUASHING_DATA_ABSTRACT_PYTHON_BINDINGS(Scalar) \
89 typedef SquashingDataAbstractTpl<Scalar> Data; \
90 typedef SquashingModelAbstractTpl<Scalar> Model; \
91 bp::register_ptr_to_python<std::shared_ptr<Data>>(); \
92 bp::class_<Data>( \
93 "SquashingDataAbstract", \
94 "Abstract class for squashing datas.\n\n" \
95 "In crocoddyl, an squashing data contains all the required information " \
96 "for processing a user-defined squashing model. The squashing data is " \
97 "typically allocated once per running via model.createData().", \
98 bp::init<Model*>( \
99 bp::args("self", "model"), \
100 "Create common data shared between squashing models.\n\n" \
101 "The squashing data uses the model in order to first process it.\n" \
102 ":param model: squashing model")) \
103 .def(SquashingDataAbstractVisitor<Data>()) \
104 .def(CopyableVisitor<Data>());
105
106 void exposeSquashingAbstract() {
107 CROCODDYL_SQUASHING_MODEL_ABSTRACT_PYTHON_BINDINGS(double)
108 CROCODDYL_SQUASHING_DATA_ABSTRACT_PYTHON_BINDINGS(double)
109 }
110
111 } // namespace python
112 } // namespace crocoddyl
113