Directory: | ./ |
---|---|
File: | bindings/python/crocoddyl/multibody/actuations/multicopter-base.cpp |
Date: | 2025-01-16 08:47:40 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 24 | 25 | 96.0% |
Branches: | 21 | 42 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | ||
2 | // BSD 3-Clause License | ||
3 | // | ||
4 | // Copyright (C) 2019-2023, LAAS-CNRS, 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/multibody/actuations/multicopter-base.hpp" | ||
11 | |||
12 | #include "python/crocoddyl/multibody/multibody.hpp" | ||
13 | #include "python/crocoddyl/utils/copyable.hpp" | ||
14 | |||
15 | namespace crocoddyl { | ||
16 | namespace python { | ||
17 | |||
18 | 10 | void exposeActuationModelMultiCopterBase() { | |
19 | bp::register_ptr_to_python< | ||
20 | 10 | boost::shared_ptr<crocoddyl::ActuationModelMultiCopterBase> >(); | |
21 | |||
22 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | bp::class_<ActuationModelMultiCopterBase, bp::bases<ActuationModelAbstract> >( |
23 | "ActuationModelMultiCopterBase", | ||
24 | "Actuation models with base actuated by several propellers (e.g. aerial " | ||
25 | "manipulators).", | ||
26 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | bp::init<boost::shared_ptr<StateMultibody>, |
27 | Eigen::Matrix<double, 6, Eigen::Dynamic> >( | ||
28 | 20 | bp::args("self", "state", "tau_f"), | |
29 | "Initialize the full actuation model.\n\n" | ||
30 | ":param state: state of multibody system\n" | ||
31 | ":param tau_f: matrix that maps rotors thrust to generalized torque " | ||
32 | "of the flying base.")) | ||
33 |
2/4✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
|
10 | .def(bp::init<boost::shared_ptr<StateMultibody>, std::size_t, |
34 | Eigen::Matrix<double, 6, Eigen::Dynamic> >( | ||
35 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::args("self", "state", "nrotors", "tau_f"), |
36 | "Initialize the full actuation model.\n\n" | ||
37 | ":param state: state of multibody system, \n" | ||
38 | ":param nrotors: number of rotors of the flying base, \n" | ||
39 | ":param tau_f: matrix that maps rotors thrust to generalized torque " | ||
40 | "of the flying base.")) | ||
41 | .def<void (ActuationModelMultiCopterBase::*)( | ||
42 | const boost::shared_ptr<ActuationDataAbstract>&, | ||
43 | const Eigen::Ref<const Eigen::VectorXd>&, | ||
44 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | const Eigen::Ref<const Eigen::VectorXd>&)>( |
45 | "calc", &ActuationModelMultiCopterBase::calc, | ||
46 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::args("self", "data", "x", "u"), |
47 | "Compute the actuation signal and actuation set from the joint " | ||
48 | "torque input u.\n\n" | ||
49 | ":param data: multicopter-base actuation data\n" | ||
50 | ":param x: state point (dim. state.nx)\n" | ||
51 | ":param u: joint torque input (dim. nu)") | ||
52 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .def("calcDiff", &ActuationModelMultiCopterBase::calcDiff, |
53 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::args("self", "data", "x", "u"), |
54 | "Compute the derivatives of the actuation model.\n\n" | ||
55 | "It computes the partial derivatives of the full actuation. It " | ||
56 | "assumes that calc\n" | ||
57 | "has been run first. The reason is that the derivatives are " | ||
58 | "constant and\n" | ||
59 | "defined in createData. The Hessian is constant, so we don't write " | ||
60 | "again this value.\n" | ||
61 | ":param data: multicopter-base actuation data\n" | ||
62 | ":param x: state point (dim. state.nx)\n" | ||
63 | ":param u: joint torque input (dim. nu)") | ||
64 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .def("commands", &ActuationModelMultiCopterBase::commands, |
65 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::args("self", "data", "x", "tau"), |
66 | "Compute the joint torque commands from the generalized torques.\n\n" | ||
67 | "It stores the results in data.u.\n" | ||
68 | ":param data: actuation data\n" | ||
69 | ":param x: state point (dim. state.nx)\n" | ||
70 | ":param tau: generalized torques (dim state.nv)") | ||
71 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .def("torqueTransform", &ActuationModelMultiCopterBase::torqueTransform, |
72 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::args("self", "data", "x", "tau"), |
73 | "Compute the torque transform from generalized torques to joint " | ||
74 | "torque inputs.\n\n" | ||
75 | "It stores the results in data.Mtau.\n" | ||
76 | ":param data: actuation data\n" | ||
77 | ":param x: state point (dim. state.nx)\n" | ||
78 | ":param tau: generalized torques (dim state.nv)") | ||
79 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .def("createData", &ActuationModelMultiCopterBase::createData, |
80 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::args("self"), |
81 | "Create the multicopter-base actuation data.\n\n" | ||
82 | "Each actuation model (AM) has its own data that needs to be " | ||
83 | "allocated.\n" | ||
84 | "This function returns the allocated data for a predefined AM.\n" | ||
85 | ":return AM data.") | ||
86 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .add_property( |
87 | "nrotors", | ||
88 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::make_function(&ActuationModelMultiCopterBase::get_nrotors), |
89 | "Number of rotors in the flying base") | ||
90 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .add_property( |
91 | "tauf", | ||
92 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | bp::make_function(&ActuationModelMultiCopterBase::get_tauf, |
93 | ✗ | bp::return_value_policy<bp::return_by_value>()), | |
94 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::make_function(&ActuationModelMultiCopterBase::set_tauf), |
95 | "Matrix mapping from thrusts to body torque") | ||
96 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .def(CopyableVisitor<ActuationModelMultiCopterBase>()); |
97 | 10 | } | |
98 | |||
99 | } // namespace python | ||
100 | } // namespace crocoddyl | ||
101 |