GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: bindings/python/crocoddyl/core/data/joint.cpp Lines: 35 41 85.4 %
Date: 2024-02-13 11:12:33 Branches: 29 58 50.0 %

Line Branch Exec Source
1
///////////////////////////////////////////////////////////////////////////////
2
// BSD 3-Clause License
3
//
4
// Copyright (C) 2022-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/core/data/joint.hpp"
10
11
#include "python/crocoddyl/core/core.hpp"
12
#include "python/crocoddyl/utils/copyable.hpp"
13
14
namespace crocoddyl {
15
namespace python {
16
17
10
void exposeDataCollectorJoint() {
18
10
  bp::register_ptr_to_python<boost::shared_ptr<JointDataAbstract> >();
19
20
10
  bp::class_<JointDataAbstract>(
21
      "JointDataAbstract",
22
      "Abstract class for joint datas.\n\n"
23
      "A joint data contains all the required information about joint efforts "
24
      "and accelerations.\n"
25
      "The joint data typically is allocated once by running "
26
      "model.createData().",
27
10
      bp::init<boost::shared_ptr<StateAbstract>,
28
               boost::shared_ptr<ActuationModelAbstract>, std::size_t>(
29
20
          bp::args("self", "state", "actuation", "nu"),
30
          "Create the joint data.\n\n"
31
          "The joint data uses the model in order to first process it.\n"
32
          ":param state: state description\n"
33
          ":param actuation: actuation model\n"
34
          ":param nu: dimension of control vector."))
35
      .add_property("tau",
36
10
                    bp::make_getter(&JointDataAbstract::tau,
37
                                    bp::return_internal_reference<>()),
38

30
                    bp::make_setter(&JointDataAbstract::tau), "joint efforts")
39
      .add_property("a",
40
10
                    bp::make_getter(&JointDataAbstract::a,
41
                                    bp::return_internal_reference<>()),
42
20
                    bp::make_setter(&JointDataAbstract::a),
43
10
                    "generalized joint accelerations")
44
      .add_property(
45
          "dtau_dx",
46
10
          bp::make_getter(&JointDataAbstract::dtau_dx,
47
                          bp::return_internal_reference<>()),
48
20
          bp::make_setter(&JointDataAbstract::dtau_dx),
49
10
          "partial derivatives of the joint efforts w.r.t. the state point")
50
      .add_property(
51
          "dtau_du",
52
10
          bp::make_getter(&JointDataAbstract::dtau_du,
53
                          bp::return_internal_reference<>()),
54
20
          bp::make_setter(&JointDataAbstract::dtau_du),
55
10
          "partial derivatives of the joint efforts w.r.t. the control input")
56
      .add_property("da_dx",
57
10
                    bp::make_getter(&JointDataAbstract::da_dx,
58
                                    bp::return_internal_reference<>()),
59
20
                    bp::make_setter(&JointDataAbstract::da_dx),
60
                    "partial derivatives of the generalized joint "
61
10
                    "accelerations w.r.t. the state point")
62
      .add_property("da_du",
63
10
                    bp::make_getter(&JointDataAbstract::da_du,
64
                                    bp::return_internal_reference<>()),
65
20
                    bp::make_setter(&JointDataAbstract::da_du),
66
                    "partial derivatives of the generalized joint "
67
10
                    "accelerations w.r.t. the control input")
68
10
      .def(CopyableVisitor<JointDataAbstract>());
69
70
10
  bp::class_<DataCollectorJoint, bp::bases<DataCollectorAbstract> >(
71
      "DataCollectorJoint", "Joint data collector.\n\n",
72
10
      bp::init<boost::shared_ptr<JointDataAbstract> >(
73
20
          bp::args("self", "joint"),
74
          "Create joint data collection.\n\n"
75
          ":param joint: joint data"))
76
      .add_property(
77
          "joint",
78
10
          bp::make_getter(&DataCollectorJoint::joint,
79
10
                          bp::return_value_policy<bp::return_by_value>()),
80
10
          "joint data")
81
10
      .def(CopyableVisitor<DataCollectorJoint>());
82
83
10
  bp::class_<DataCollectorJointActuation, bp::bases<DataCollectorActuation> >(
84
      "DataCollectorJointActuation", "Joint-actuation data collector.\n\n",
85
10
      bp::init<boost::shared_ptr<ActuationDataAbstract>,
86
               boost::shared_ptr<JointDataAbstract> >(
87
20
          bp::args("self", "actuation", "joint"),
88
          "Create joint-actuation data collection.\n\n"
89
          ":param actuation: actuation data"
90
          ":param joint: joint data"))
91
10
      .def(CopyableVisitor<DataCollectorJointActuation>());
92
10
}
93
94
}  // namespace python
95
}  // namespace crocoddyl