GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/multibody/residuals/frame-rotation.cpp
Date: 2025-01-16 08:47:40
Exec Total Coverage
Lines: 44 46 95.7%
Branches: 33 66 50.0%

Line Branch Exec Source
1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (C) 2021-2025, 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
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
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
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
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
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>, pinocchio::FrameIndex,
35 Eigen::Matrix3d>(
36
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
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 ":param Rref: reference frame rotation"))
42 .def<void (ResidualModelFrameRotation::*)(
43 const boost::shared_ptr<ResidualDataAbstract>&,
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 "calc", &ResidualModelFrameRotation::calc,
47
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
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 ":param u: control input (dim. nu)")
52 .def<void (ResidualModelFrameRotation::*)(
53 const boost::shared_ptr<ResidualDataAbstract>&,
54 20 const Eigen::Ref<const Eigen::VectorXd>&)>(
55
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
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
2/4
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
20 const Eigen::Ref<const Eigen::VectorXd>&)>(
60 "calcDiff", &ResidualModelFrameRotation::calcDiff,
61
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
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 ":param u: control input (dim. nu)")
67 .def<void (ResidualModelFrameRotation::*)(
68 const boost::shared_ptr<ResidualDataAbstract>&,
69 20 const Eigen::Ref<const Eigen::VectorXd>&)>(
70 "calcDiff", &ResidualModelAbstract::calcDiff,
71
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "x"))
72
2/4
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
20 .def("createData", &ResidualModelFrameRotation::createData,
73 bp::with_custodian_and_ward_postcall<0, 2>(),
74
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
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 ":return residual data.")
81
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("id", &ResidualModelFrameRotation::get_id,
82 &ResidualModelFrameRotation::set_id, "reference frame id")
83
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("reference",
84
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_function(
85 &ResidualModelFrameRotation::get_reference,
86 10 bp::return_value_policy<bp::copy_const_reference>()),
87 &ResidualModelFrameRotation::set_reference,
88 "reference frame rotation")
89
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def(CopyableVisitor<ResidualModelFrameRotation>());
90
91 10 bp::register_ptr_to_python<boost::shared_ptr<ResidualDataFrameRotation> >();
92
93
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::class_<ResidualDataFrameRotation, bp::bases<ResidualDataAbstract> >(
94 "ResidualDataFrameRotation", "Data for frame rotation residual.\n\n",
95
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
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 ":param data: shared data")[bp::with_custodian_and_ward<
100
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 1, 2, bp::with_custodian_and_ward<1, 3> >()])
101
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("pinocchio",
102
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_getter(&ResidualDataFrameRotation::pinocchio,
103 10 bp::return_internal_reference<>()),
104 "pinocchio data")
105
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("r",
106
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_getter(&ResidualDataFrameRotation::r,
107 10 bp::return_internal_reference<>()),
108 "residual residual")
109
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("rRf",
110
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_getter(&ResidualDataFrameRotation::rRf,
111 10 bp::return_internal_reference<>()),
112 "rotation error of the frame")
113
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("rJf",
114
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_getter(&ResidualDataFrameRotation::rJf,
115 10 bp::return_internal_reference<>()),
116 "error Jacobian of the frame")
117
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("fJf",
118
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_getter(&ResidualDataFrameRotation::fJf,
119 10 bp::return_internal_reference<>()),
120 "local Jacobian of the frame")
121
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def(CopyableVisitor<ResidualDataFrameRotation>());
122 10 }
123
124 } // namespace python
125 } // namespace crocoddyl
126