GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/multibody/residuals/frame-velocity.cpp
Date: 2025-01-30 11:01:55
Exec Total Coverage
Lines: 33 35 94.3%
Branches: 26 52 50.0%

Line Branch Exec Source
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-velocity.hpp"
10
11 #include "python/crocoddyl/multibody/multibody.hpp"
12 #include "python/crocoddyl/utils/copyable.hpp"
13
14 namespace crocoddyl {
15 namespace python {
16
17 10 void exposeResidualFrameVelocity() {
18 10 bp::register_ptr_to_python<std::shared_ptr<ResidualModelFrameVelocity> >();
19
20
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::class_<ResidualModelFrameVelocity, bp::bases<ResidualModelAbstract> >(
21 "ResidualModelFrameVelocity",
22 "This residual function defines r = v - vref, with v and vref as the "
23 "current and reference\n"
24 "frame velocities, respectively.",
25
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::init<std::shared_ptr<StateMultibody>, std::size_t, pinocchio::Motion,
26 pinocchio::ReferenceFrame, std::size_t>(
27 20 bp::args("self", "state", "id", "velocity", "type", "nu"),
28 "Initialize the frame velocity residual model.\n\n"
29 ":param state: state of the multibody system\n"
30 ":param residual: residual model\n"
31 ":param id: reference frame id\n"
32 ":param velocity: reference velocity\n"
33 ":param type: reference type of velocity\n"
34 ":param nu: dimension of control vector"))
35
2/4
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
10 .def(bp::init<std::shared_ptr<StateMultibody>, pinocchio::FrameIndex,
36 pinocchio::Motion, pinocchio::ReferenceFrame>(
37
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "state", "id", "velocity", "type"),
38 "Initialize the frame velocity residual model.\n\n"
39 ":param state: state of the multibody system\n"
40 ":param residual: residual model\n"
41 ":param id: reference frame id\n"
42 ":param velocity: reference velocity\n"
43 ":param type: reference type of velocity"))
44 .def<void (ResidualModelFrameVelocity::*)(
45 const std::shared_ptr<ResidualDataAbstract>&,
46 const Eigen::Ref<const Eigen::VectorXd>&,
47
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 const Eigen::Ref<const Eigen::VectorXd>&)>(
48 "calc", &ResidualModelFrameVelocity::calc,
49
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "x", "u"),
50 "Compute the frame velocity residual.\n\n"
51 ":param data: residual data\n"
52 ":param x: state point (dim. state.nx)\n"
53 ":param u: control input (dim. nu)")
54 .def<void (ResidualModelFrameVelocity::*)(
55 const std::shared_ptr<ResidualDataAbstract>&,
56 20 const Eigen::Ref<const Eigen::VectorXd>&)>(
57
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 "calc", &ResidualModelAbstract::calc, bp::args("self", "data", "x"))
58 .def<void (ResidualModelFrameVelocity::*)(
59 const std::shared_ptr<ResidualDataAbstract>&,
60 const Eigen::Ref<const Eigen::VectorXd>&,
61
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>&)>(
62 "calcDiff", &ResidualModelFrameVelocity::calcDiff,
63
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "x", "u"),
64 "Compute the Jacobians of the frame velocity residual.\n\n"
65 "It assumes that calc has been run first.\n"
66 ":param data: action data\n"
67 ":param x: state point (dim. state.nx)\n"
68 ":param u: control input (dim. nu)")
69 .def<void (ResidualModelFrameVelocity::*)(
70 const std::shared_ptr<ResidualDataAbstract>&,
71 20 const Eigen::Ref<const Eigen::VectorXd>&)>(
72 "calcDiff", &ResidualModelAbstract::calcDiff,
73
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "x"))
74
2/4
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
20 .def("createData", &ResidualModelFrameVelocity::createData,
75 bp::with_custodian_and_ward_postcall<0, 2>(),
76
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data"),
77 "Create the frame velocity residual data.\n\n"
78 "Each residual model has its own data that needs to be allocated. "
79 "This function\n"
80 "returns the allocated data for the frame velocity residual.\n"
81 ":param data: shared data\n"
82 ":return residual data.")
83
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("id", &ResidualModelFrameVelocity::get_id,
84 &ResidualModelFrameVelocity::set_id, "reference frame id")
85
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property(
86 "reference",
87
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_function(&ResidualModelFrameVelocity::get_reference,
88 10 bp::return_internal_reference<>()),
89 &ResidualModelFrameVelocity::set_reference, "reference velocity")
90
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("type", &ResidualModelFrameVelocity::get_type,
91 &ResidualModelFrameVelocity::set_type,
92 "reference type of velocity")
93
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def(CopyableVisitor<ResidualModelFrameVelocity>());
94
95 10 bp::register_ptr_to_python<std::shared_ptr<ResidualDataFrameVelocity> >();
96
97
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::class_<ResidualDataFrameVelocity, bp::bases<ResidualDataAbstract> >(
98 "ResidualDataFrameVelocity", "Data for frame velocity residual.\n\n",
99
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::init<ResidualModelFrameVelocity*, DataCollectorAbstract*>(
100 10 bp::args("self", "model", "data"),
101 "Create frame velocity residual data.\n\n"
102 ":param model: frame Velocity residual model\n"
103 ":param data: shared data")[bp::with_custodian_and_ward<
104
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 1, 2, bp::with_custodian_and_ward<1, 3> >()])
105
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("pinocchio",
106
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_getter(&ResidualDataFrameVelocity::pinocchio,
107 10 bp::return_internal_reference<>()),
108 "pinocchio data")
109
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def(CopyableVisitor<ResidualDataFrameVelocity>());
110 10 }
111
112 } // namespace python
113 } // namespace crocoddyl
114