GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: bindings/python/crocoddyl/multibody/force-base.cpp Lines: 29 37 78.4 %
Date: 2024-02-13 11:12:33 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/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
10
  bp::class_<ForceDataAbstract>(
23
      "ForceDataAbstract", "Abstract class for force datas.\n\n",
24
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
10
          ":param data: Pinocchio data")[bp::with_custodian_and_ward<
29
20
          1, 2, bp::with_custodian_and_ward<1, 3> >()])
30
10
      .def(bp::init<ImpulseModelAbstract*,
31
                    pinocchio::Data*>()[bp::with_custodian_and_ward<
32

10
          1, 2, bp::with_custodian_and_ward<1, 3> >()])
33
      .add_property("pinocchio",
34
10
                    bp::make_getter(&ForceDataAbstract::pinocchio,
35
10
                                    bp::return_internal_reference<>()),
36
10
                    "pinocchio data")
37
      .def_readwrite("frame", &ForceDataAbstract::frame,
38
10
                     "frame id of the contact")
39
10
      .def_readwrite("type", &ForceDataAbstract::type, "type of contact")
40
      .add_property(
41
          "jMf",
42
10
          bp::make_getter(&ForceDataAbstract::jMf,
43
                          bp::return_value_policy<bp::return_by_value>()),
44
20
          bp::make_setter(&ForceDataAbstract::jMf),
45
10
          "local frame placement of the contact frame")
46
      .add_property("Jc",
47
10
                    bp::make_getter(&ForceDataAbstract::Jc,
48
                                    bp::return_internal_reference<>()),
49

30
                    bp::make_setter(&ForceDataAbstract::Jc), "contact Jacobian")
50
      .def_readwrite(
51
          "f", &ForceDataAbstract::f,
52
10
          "contact force expressed in the coordinate defined by type")
53
      .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
10
                     "contact frame by using jMf (i.e. data.jMf.actInv(data.f)")
57
      .add_property("df_dx",
58
10
                    bp::make_getter(&ForceDataAbstract::df_dx,
59
                                    bp::return_internal_reference<>()),
60
20
                    bp::make_setter(&ForceDataAbstract::df_dx),
61
                    "Jacobian of the contact forces expressed in the "
62
10
                    "coordinate defined by type")
63
      .add_property("df_du",
64
10
                    bp::make_getter(&ForceDataAbstract::df_du,
65
                                    bp::return_internal_reference<>()),
66
20
                    bp::make_setter(&ForceDataAbstract::df_du),
67
                    "Jacobian of the contact forces expressed in the "
68
10
                    "coordinate defined by type")
69
10
      .def(CopyableVisitor<ForceDataAbstract>());
70
10
}
71
72
}  // namespace python
73
}  // namespace crocoddyl