GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/multibody/impulses/impulse-3d.cpp
Date: 2025-01-16 08:47:40
Exec Total Coverage
Lines: 34 38 89.5%
Branches: 27 54 50.0%

Line Branch Exec Source
1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (C) 2019-2023, LAAS-CNRS, University of Edinburgh,
5 // Heriot-Watt University
6 // Copyright note valid unless otherwise stated in individual files.
7 // All rights reserved.
8 ///////////////////////////////////////////////////////////////////////////////
9
10 #include "crocoddyl/multibody/impulses/impulse-3d.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 exposeImpulse3D() {
19 10 bp::register_ptr_to_python<boost::shared_ptr<ImpulseModel3D> >();
20
21
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::class_<ImpulseModel3D, bp::bases<ImpulseModelAbstract> >(
22 "ImpulseModel3D",
23 "Rigid 3D impulse model.\n\n"
24 "It defines a rigid 3D impulse models (point impulse) based on "
25 "acceleration-based holonomic constraints.\n"
26 "The calc and calcDiff functions compute the impulse Jacobian and drift "
27 "(holonomic constraint) or\n"
28 "the derivatives of the holonomic constraint, respectively.",
29
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::init<boost::shared_ptr<StateMultibody>, std::size_t,
30 bp::optional<pinocchio::ReferenceFrame> >(
31 20 bp::args("self", "state", "frame", "type"),
32 "Initialize the 3D impulse model.\n\n"
33 ":param state: state of the multibody system\n"
34 ":param type: type of impulse (default pinocchio.LOCAL)\n"
35 ":param frame: reference frame id"))
36
2/4
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
20 .def("calc", &ImpulseModel3D::calc, bp::args("self", "data", "x"),
37 "Compute the 3D impulse Jacobian and drift.\n\n"
38 "The rigid impulse model throught acceleration-base holonomic "
39 "constraint\n"
40 "of the impulse frame placement.\n"
41 ":param data: impulse data\n"
42 ":param x: state point (dim. state.nx)")
43
2/4
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
20 .def("calcDiff", &ImpulseModel3D::calcDiff, bp::args("self", "data", "x"),
44 "Compute the derivatives of the 3D impulse holonomic constraint.\n\n"
45 "The rigid impulse model throught acceleration-base holonomic "
46 "constraint\n"
47 "of the impulse frame placement.\n"
48 "It assumes that calc has been run first.\n"
49 ":param data: cost data\n"
50 ":param x: state point (dim. state.nx)")
51
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def("updateForce", &ImpulseModel3D::updateForce,
52
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "force"),
53 "Convert the force into a stack of spatial forces.\n\n"
54 ":param data: cost data\n"
55 ":param force: force vector (dimension 3)")
56
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def("createData", &ImpulseModel3D::createData,
57 bp::with_custodian_and_ward_postcall<0, 2>(),
58
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data"),
59 "Create the 3D impulse data.\n\n"
60 "Each impulse model has its own data that needs to be allocated. "
61 "This function\n"
62 "returns the allocated data for a predefined cost.\n"
63 ":param data: Pinocchio data\n"
64 ":return impulse data.")
65
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def(CopyableVisitor<ImpulseModel3D>());
66
67 10 bp::register_ptr_to_python<boost::shared_ptr<ImpulseData3D> >();
68
69
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::class_<ImpulseData3D, bp::bases<ImpulseDataAbstract> >(
70 "ImpulseData3D", "Data for 3D impulse.\n\n",
71
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::init<ImpulseModel3D*, pinocchio::Data*>(
72 10 bp::args("self", "model", "data"),
73 "Create 3D impulse data.\n\n"
74 ":param model: 3D impulse model\n"
75 ":param data: Pinocchio data")[bp::with_custodian_and_ward<
76
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 1, 2, bp::with_custodian_and_ward<1, 3> >()])
77
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("f_local",
78
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_getter(&ImpulseData3D::f_local,
79 bp::return_internal_reference<>()),
80
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::make_setter(&ImpulseData3D::f_local),
81 "spatial contact force in local coordinates")
82
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("dv0_local_dq",
83
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_getter(&ImpulseData3D::dv0_local_dq,
84 bp::return_internal_reference<>()),
85
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::make_setter(&ImpulseData3D::dv0_local_dq),
86 "Jacobian of the desired local contact velocity")
87
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("fJf",
88
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_getter(&ImpulseData3D::fJf,
89 10 bp::return_internal_reference<>()),
90 "local Jacobian of the impulse frame")
91
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("v_partial_dq",
92
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_getter(&ImpulseData3D::v_partial_dq,
93 10 bp::return_internal_reference<>()),
94 "Jacobian of the spatial body velocity")
95
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("v_partial_dv",
96
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_getter(&ImpulseData3D::v_partial_dv,
97 10 bp::return_internal_reference<>()),
98 "Jacobian of the spatial body velocity")
99
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def(CopyableVisitor<ImpulseData3D>());
100 10 }
101
102 } // namespace python
103 } // namespace crocoddyl
104