GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/multibody/force-base.cpp
Date: 2025-01-16 08:47:40
Exec Total Coverage
Lines: 30 36 83.3%
Branches: 25 50 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/force-base.hpp"
10
11 #include "python/crocoddyl/multibody/contact-base.hpp"
12 #include "python/crocoddyl/multibody/impulse-base.hpp"
13 #include "python/crocoddyl/multibody/multibody.hpp"
14 #include "python/crocoddyl/utils/copyable.hpp"
15
16 namespace crocoddyl {
17 namespace python {
18
19 10 void exposeForceAbstract() {
20 10 bp::register_ptr_to_python<boost::shared_ptr<ForceDataAbstract> >();
21
22
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::class_<ForceDataAbstract>(
23 "ForceDataAbstract", "Abstract class for force datas.\n\n",
24
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::init<ContactModelAbstract*, pinocchio::Data*>(
25 10 bp::args("self", "model", "data"),
26 "Create common data shared between force models.\n\n"
27 ":param model: force/impulse model\n"
28 ":param data: Pinocchio data")[bp::with_custodian_and_ward<
29
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 1, 2, bp::with_custodian_and_ward<1, 3> >()])
30
2/4
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
20 .def(bp::init<ImpulseModelAbstract*,
31 pinocchio::Data*>()[bp::with_custodian_and_ward<
32
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 1, 2, bp::with_custodian_and_ward<1, 3> >()])
33
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("pinocchio",
34
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_getter(&ForceDataAbstract::pinocchio,
35 10 bp::return_internal_reference<>()),
36 "pinocchio data")
37
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def_readwrite("frame", &ForceDataAbstract::frame,
38 "frame id of the contact")
39
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def_readwrite("type", &ForceDataAbstract::type, "type of contact")
40
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property(
41 "jMf",
42
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_getter(&ForceDataAbstract::jMf,
43 bp::return_value_policy<bp::return_by_value>()),
44
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::make_setter(&ForceDataAbstract::jMf),
45 "local frame placement of the contact frame")
46
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("Jc",
47
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_getter(&ForceDataAbstract::Jc,
48 bp::return_internal_reference<>()),
49
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::make_setter(&ForceDataAbstract::Jc), "contact Jacobian")
50 20 .def_readwrite(
51
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 "f", &ForceDataAbstract::f,
52 "contact force expressed in the coordinate defined by type")
53
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def_readwrite("fext", &ForceDataAbstract::fext,
54 "external spatial force at the parent joint level. Note "
55 "that we could compute the force at the "
56 "contact frame by using jMf (i.e. data.jMf.actInv(data.f)")
57
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("df_dx",
58
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_getter(&ForceDataAbstract::df_dx,
59 bp::return_internal_reference<>()),
60
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::make_setter(&ForceDataAbstract::df_dx),
61 "Jacobian of the contact forces expressed in the "
62 "coordinate defined by type")
63
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("df_du",
64
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_getter(&ForceDataAbstract::df_du,
65 bp::return_internal_reference<>()),
66
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::make_setter(&ForceDataAbstract::df_du),
67 "Jacobian of the contact forces expressed in the "
68 "coordinate defined by type")
69
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def(CopyableVisitor<ForceDataAbstract>());
70 10 }
71
72 } // namespace python
73 } // namespace crocoddyl
74