1 |
|
|
/////////////////////////////////////////////////////////////////////////////// |
2 |
|
|
// BSD 3-Clause License |
3 |
|
|
// |
4 |
|
|
// Copyright (C) 2021-2023, University of Edinburgh, Heriot-Watt University |
5 |
|
|
// Copyright note valid unless otherwise stated in individual files. |
6 |
|
|
// All rights reserved. |
7 |
|
|
/////////////////////////////////////////////////////////////////////////////// |
8 |
|
|
|
9 |
|
|
#include "crocoddyl/multibody/residuals/frame-rotation.hpp" |
10 |
|
|
|
11 |
|
|
#include "python/crocoddyl/multibody/multibody.hpp" |
12 |
|
|
#include "python/crocoddyl/utils/copyable.hpp" |
13 |
|
|
#include "python/crocoddyl/utils/deprecate.hpp" |
14 |
|
|
|
15 |
|
|
namespace crocoddyl { |
16 |
|
|
namespace python { |
17 |
|
|
|
18 |
|
10 |
void exposeResidualFrameRotation() { |
19 |
|
10 |
bp::register_ptr_to_python<boost::shared_ptr<ResidualModelFrameRotation> >(); |
20 |
|
|
|
21 |
✓✗ |
10 |
bp::class_<ResidualModelFrameRotation, bp::bases<ResidualModelAbstract> >( |
22 |
|
|
"ResidualModelFrameRotation", |
23 |
|
|
"This residual function is defined as r = R - Rref, with R and Rref as " |
24 |
|
|
"the current and reference\n" |
25 |
|
|
"frame rotations, respectively.", |
26 |
✓✗ |
10 |
bp::init<boost::shared_ptr<StateMultibody>, pinocchio::FrameIndex, |
27 |
|
|
Eigen::Matrix3d, std::size_t>( |
28 |
|
20 |
bp::args("self", "state", "id", "Rref", "nu"), |
29 |
|
|
"Initialize the frame rotation residual model.\n\n" |
30 |
|
|
":param state: state of the multibody system\n" |
31 |
|
|
":param id: reference frame id\n" |
32 |
|
|
":param Rref: reference frame rotation\n" |
33 |
|
|
":param nu: dimension of control vector")) |
34 |
✓✗ |
10 |
.def(bp::init<boost::shared_ptr<StateMultibody>, pinocchio::FrameIndex, |
35 |
|
|
Eigen::Matrix3d>( |
36 |
✓✗ |
20 |
bp::args("self", "state", "id", "Rref"), |
37 |
|
|
"Initialize the frame rotation residual model.\n\n" |
38 |
|
|
"The default nu value is obtained from model.nv.\n" |
39 |
|
|
":param state: state of the multibody system\n" |
40 |
|
|
":param id: reference frame id\n" |
41 |
✓✗ |
10 |
":param Rref: reference frame rotation")) |
42 |
|
|
.def<void (ResidualModelFrameRotation::*)( |
43 |
|
|
const boost::shared_ptr<ResidualDataAbstract>&, |
44 |
|
|
const Eigen::Ref<const Eigen::VectorXd>&, |
45 |
|
|
const Eigen::Ref<const Eigen::VectorXd>&)>( |
46 |
|
|
"calc", &ResidualModelFrameRotation::calc, |
47 |
✓✗ |
20 |
bp::args("self", "data", "x", "u"), |
48 |
|
|
"Compute the frame rotation residual.\n\n" |
49 |
|
|
":param data: residual data\n" |
50 |
|
|
":param x: state point (dim. state.nx)\n" |
51 |
✓✗ |
10 |
":param u: control input (dim. nu)") |
52 |
|
|
.def<void (ResidualModelFrameRotation::*)( |
53 |
|
|
const boost::shared_ptr<ResidualDataAbstract>&, |
54 |
|
|
const Eigen::Ref<const Eigen::VectorXd>&)>( |
55 |
✓✗ |
20 |
"calc", &ResidualModelAbstract::calc, bp::args("self", "data", "x")) |
56 |
|
|
.def<void (ResidualModelFrameRotation::*)( |
57 |
|
|
const boost::shared_ptr<ResidualDataAbstract>&, |
58 |
|
|
const Eigen::Ref<const Eigen::VectorXd>&, |
59 |
|
|
const Eigen::Ref<const Eigen::VectorXd>&)>( |
60 |
|
|
"calcDiff", &ResidualModelFrameRotation::calcDiff, |
61 |
✓✗ |
20 |
bp::args("self", "data", "x", "u"), |
62 |
|
|
"Compute the Jacobians of the frame rotation residual.\n\n" |
63 |
|
|
"It assumes that calc has been run first.\n" |
64 |
|
|
":param data: action data\n" |
65 |
|
|
":param x: state point (dim. state.nx)\n" |
66 |
✓✗✓✗
|
20 |
":param u: control input (dim. nu)") |
67 |
|
|
.def<void (ResidualModelFrameRotation::*)( |
68 |
|
|
const boost::shared_ptr<ResidualDataAbstract>&, |
69 |
|
|
const Eigen::Ref<const Eigen::VectorXd>&)>( |
70 |
|
|
"calcDiff", &ResidualModelAbstract::calcDiff, |
71 |
✓✗ |
20 |
bp::args("self", "data", "x")) |
72 |
|
|
.def("createData", &ResidualModelFrameRotation::createData, |
73 |
|
|
bp::with_custodian_and_ward_postcall<0, 2>(), |
74 |
✓✗ |
20 |
bp::args("self", "data"), |
75 |
|
|
"Create the frame rotation residual data.\n\n" |
76 |
|
|
"Each residual model has its own data that needs to be allocated. " |
77 |
|
|
"This function\n" |
78 |
|
|
"returns the allocated data for the frame rotation residual.\n" |
79 |
|
|
":param data: shared data\n" |
80 |
✓✗✓✗
|
20 |
":return residual data.") |
81 |
|
|
.add_property("id", &ResidualModelFrameRotation::get_id, |
82 |
✓✗ |
10 |
&ResidualModelFrameRotation::set_id, "reference frame id") |
83 |
|
|
.add_property( |
84 |
|
|
"reference", |
85 |
|
|
bp::make_function(&ResidualModelFrameRotation::get_reference, |
86 |
|
10 |
bp::return_internal_reference<>()), |
87 |
|
|
&ResidualModelFrameRotation::set_reference, |
88 |
✓✗✓✗
|
10 |
"reference frame rotation") |
89 |
✓✗ |
10 |
.def(CopyableVisitor<ResidualModelFrameRotation>()); |
90 |
|
|
|
91 |
|
10 |
bp::register_ptr_to_python<boost::shared_ptr<ResidualDataFrameRotation> >(); |
92 |
|
|
|
93 |
✓✗ |
10 |
bp::class_<ResidualDataFrameRotation, bp::bases<ResidualDataAbstract> >( |
94 |
|
|
"ResidualDataFrameRotation", "Data for frame rotation residual.\n\n", |
95 |
✓✗ |
10 |
bp::init<ResidualModelFrameRotation*, DataCollectorAbstract*>( |
96 |
✓✗ |
10 |
bp::args("self", "model", "data"), |
97 |
|
|
"Create frame rotation residual data.\n\n" |
98 |
|
|
":param model: frame rotation residual model\n" |
99 |
|
10 |
":param data: shared data")[bp::with_custodian_and_ward< |
100 |
✓✗ |
20 |
1, 2, bp::with_custodian_and_ward<1, 3> >()]) |
101 |
|
|
.add_property("pinocchio", |
102 |
✓✗ |
10 |
bp::make_getter(&ResidualDataFrameRotation::pinocchio, |
103 |
|
10 |
bp::return_internal_reference<>()), |
104 |
✓✗ |
10 |
"pinocchio data") |
105 |
|
|
.add_property("r", |
106 |
✓✗ |
10 |
bp::make_getter(&ResidualDataFrameRotation::r, |
107 |
|
10 |
bp::return_internal_reference<>()), |
108 |
✓✗ |
10 |
"residual residual") |
109 |
|
|
.add_property("rRf", |
110 |
✓✗ |
10 |
bp::make_getter(&ResidualDataFrameRotation::rRf, |
111 |
|
10 |
bp::return_internal_reference<>()), |
112 |
✓✗ |
10 |
"rotation error of the frame") |
113 |
|
|
.add_property("rJf", |
114 |
✓✗ |
10 |
bp::make_getter(&ResidualDataFrameRotation::rJf, |
115 |
|
10 |
bp::return_internal_reference<>()), |
116 |
✓✗ |
10 |
"error Jacobian of the frame") |
117 |
|
|
.add_property("fJf", |
118 |
✓✗ |
10 |
bp::make_getter(&ResidualDataFrameRotation::fJf, |
119 |
|
10 |
bp::return_internal_reference<>()), |
120 |
✓✗ |
10 |
"local Jacobian of the frame") |
121 |
✓✗ |
10 |
.def(CopyableVisitor<ResidualDataFrameRotation>()); |
122 |
|
10 |
} |
123 |
|
|
|
124 |
|
|
} // namespace python |
125 |
|
|
} // namespace crocoddyl |