GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/multibody/impulses/impulse-6d.cpp
Date: 2025-01-16 08:47:40
Exec Total Coverage
Lines: 31 34 91.2%
Branches: 24 48 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-6d.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 exposeImpulse6D() {
19 10 bp::register_ptr_to_python<boost::shared_ptr<ImpulseModel6D> >();
20
21
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::class_<ImpulseModel6D, bp::bases<ImpulseModelAbstract> >(
22 "ImpulseModel6D",
23 "Rigid 6D impulse model.\n\n"
24 "It defines a rigid 6D impulse models based on acceleration-based "
25 "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 impulse model.\n\n"
33 ":param state: state of the multibody system\n"
34 ":param type: type of impulse\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", &ImpulseModel6D::calc, bp::args("self", "data", "x"),
37 "Compute the 6D 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", &ImpulseModel6D::calcDiff, bp::args("self", "data", "x"),
44 "Compute the derivatives of the 6D 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", &ImpulseModel6D::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 lambda: force vector (dimension 6)")
56
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def("createData", &ImpulseModel6D::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 6D 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<ImpulseModel6D>());
66
67 10 bp::register_ptr_to_python<boost::shared_ptr<ImpulseData6D> >();
68
69
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::class_<ImpulseData6D, bp::bases<ImpulseDataAbstract> >(
70 "ImpulseData6D", "Data for 6D impulse.\n\n",
71
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::init<ImpulseModel6D*, pinocchio::Data*>(
72 10 bp::args("self", "model", "data"),
73 "Create 6D impulse data.\n\n"
74 ":param model: 6D 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("dv0_local_dq",
78
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_getter(&ImpulseData6D::dv0_local_dq,
79 bp::return_internal_reference<>()),
80
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::make_setter(&ImpulseData6D::dv0_local_dq),
81 "Jacobian of the desired local contact velocity")
82
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("fJf",
83
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_getter(&ImpulseData6D::fJf,
84 10 bp::return_internal_reference<>()),
85 "local Jacobian of the impulse frame")
86
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("v_partial_dq",
87
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_getter(&ImpulseData6D::v_partial_dq,
88 10 bp::return_internal_reference<>()),
89 "Jacobian of the spatial body velocity")
90
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("v_partial_dv",
91
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_getter(&ImpulseData6D::v_partial_dv,
92 10 bp::return_internal_reference<>()),
93 "Jacobian of the spatial body velocity")
94
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def(CopyableVisitor<ImpulseData6D>());
95 10 }
96
97 } // namespace python
98 } // namespace crocoddyl
99