Directory: | ./ |
---|---|
File: | bindings/python/crocoddyl/core/actuation/actuation-squashing.cpp |
Date: | 2025-01-16 08:47:40 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 29 | 31 | 93.5% |
Branches: | 22 | 44 | 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/actuation-squashing.hpp" | ||
11 | |||
12 | #include "crocoddyl/core/utils/exception.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 exposeActuationSquashing() { | |
20 | 10 | bp::register_ptr_to_python<boost::shared_ptr<ActuationSquashingModel> >(); | |
21 | |||
22 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | bp::class_<ActuationSquashingModel, bp::bases<ActuationModelAbstract> >( |
23 | "ActuationSquashingModel", "Class for squashing an actuation model.\n\n", | ||
24 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | bp::init<boost::shared_ptr<ActuationModelAbstract>, |
25 | boost::shared_ptr<SquashingModelAbstract>, std::size_t>( | ||
26 | 20 | bp::args("self", "actuation", "squashing", "nu"), | |
27 | "Initialize the actuation model with squashing function.\n\n" | ||
28 | ":param actuation: actuation model to be squashed,\n" | ||
29 | ":param squashing: squashing function,\n" | ||
30 | ":param nu: number of controls")) | ||
31 | .def<void (ActuationSquashingModel::*)( | ||
32 | const boost::shared_ptr<ActuationDataAbstract>&, | ||
33 | const Eigen::Ref<const Eigen::VectorXd>&, | ||
34 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | const Eigen::Ref<const Eigen::VectorXd>&)>( |
35 | "calc", &ActuationSquashingModel::calc, | ||
36 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::args("self", "data", "x", "u"), |
37 | "Compute the actuation signal from the squashing input u.\n\n" | ||
38 | "It describes the time-continuos evolution of the actuation model.\n" | ||
39 | ":param data: actuation data\n" | ||
40 | ":param x: state point (dim. state.nx)\n" | ||
41 | ":param u: squashing function input") | ||
42 | .def<void (ActuationSquashingModel::*)( | ||
43 | const boost::shared_ptr<ActuationDataAbstract>&, | ||
44 | const Eigen::Ref<const Eigen::VectorXd>&, | ||
45 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | const Eigen::Ref<const Eigen::VectorXd>&)>( |
46 | "calcDiff", &ActuationSquashingModel::calcDiff, | ||
47 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::args("self", "data", "x", "u"), |
48 | "Compute the derivatives of the actuation model.\n\n" | ||
49 | "It computes the partial derivatives of the actuation model which " | ||
50 | "is\n" | ||
51 | "describes in continouos time. It assumes that calc has been run " | ||
52 | "first.\n" | ||
53 | ":param data: actuation data\n" | ||
54 | ":param x: state point (dim. state.nx)\n" | ||
55 | ":param u: control input (dim. nu).") | ||
56 |
2/4✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
|
20 | .def("createData", &ActuationSquashingModel::createData, bp::args("self"), |
57 | "Create the actuation squashing data.\n\n" | ||
58 | "Each actuation model (AM) has its own data that needs to be " | ||
59 | "allocated.\n" | ||
60 | "This function returns the allocated data for a predefined AM.\n" | ||
61 | ":return AM data.") | ||
62 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .add_property( |
63 | "squashing", | ||
64 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | bp::make_function(&ActuationSquashingModel::get_squashing, |
65 | 10 | bp::return_value_policy<bp::return_by_value>()), | |
66 | "squashing") | ||
67 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .add_property( |
68 | "actuation", | ||
69 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | bp::make_function(&ActuationSquashingModel::get_actuation, |
70 | 10 | bp::return_value_policy<bp::return_by_value>()), | |
71 | "actuation") | ||
72 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .def(CopyableVisitor<ActuationSquashingModel>()); |
73 | |||
74 | 10 | bp::register_ptr_to_python<boost::shared_ptr<ActuationSquashingData> >(); | |
75 | |||
76 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | bp::class_<ActuationSquashingData, bp::bases<ActuationDataAbstract> >( |
77 | "ActuationSquashingData", | ||
78 | "Class for actuation datas using squashing functions.\n\n" | ||
79 | "In crocoddyl, an actuation data contains all the required information " | ||
80 | "for processing an\n" | ||
81 | "user-defined actuation model. The actuation data typically is allocated " | ||
82 | "onces by running\n" | ||
83 | "model.createData().", | ||
84 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | bp::init<ActuationSquashingModel*>( |
85 | 20 | bp::args("self", "model"), | |
86 | "Create common data shared between actuation models.\n\n" | ||
87 | "The actuation data uses the model in order to first process it.\n" | ||
88 | ":param model: actuation model")) | ||
89 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .add_property( |
90 | "squashing", | ||
91 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | bp::make_getter(&ActuationSquashingData::squashing, |
92 | ✗ | bp::return_value_policy<bp::return_by_value>()), | |
93 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::make_setter(&ActuationSquashingData::squashing), |
94 | "Data of the associated squashing model") | ||
95 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .add_property( |
96 | "actuation", | ||
97 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | bp::make_getter(&ActuationSquashingData::actuation, |
98 | ✗ | bp::return_value_policy<bp::return_by_value>()), | |
99 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::make_setter(&ActuationSquashingData::actuation), |
100 | "Data of the associated actuation model") | ||
101 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .def(CopyableVisitor<ActuationSquashingData>()); |
102 | 10 | } | |
103 | |||
104 | } // namespace python | ||
105 | } // namespace crocoddyl | ||
106 |