GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: python/contact_6d.cpp Lines: 54 63 85.7 %
Date: 2022-12-19 14:14:12 Branches: 76 152 50.0 %

Line Branch Exec Source
1
#include <boost/python.hpp>
2
#include <boost/python/return_internal_reference.hpp>
3
#include <eigenpy/eigenpy.hpp>
4
5
#include "dynacom/contact6d.hpp"
6
#include "dynacom/python.hpp"
7
8
namespace dynacom {
9
namespace python {
10
namespace bp = boost::python;
11
12
5
bp::dict get_settings(Contact6D &self) {
13
✓✗
5
  bp::dict settings;
14
✓✗
10
  Contact6DSettings conf = self.getSettings();
15
✓✗✓✗
5
  settings["frame_name"] = conf.frame_name;
16
✓✗✓✗
5
  settings["gu"] = conf.gu;
17
✓✗✓✗
5
  settings["mu"] = conf.mu;
18
✓✗✓✗
5
  settings["weights"] = conf.weights;
19
✓✗✓✗
5
  settings["half_width"] = conf.half_width;
20
✓✗✓✗
5
  settings["half_length"] = conf.half_length;
21
22
10
  return settings;
23
}
24
25
12
void set_weights(Contact6DSettings &self, Eigen::Matrix<double, 6, 1> w) {
26
12
  self.weights = w;
27
12
}
28
29
1
Eigen::Matrix<double, 6, 1> get_weights(Contact6DSettings &self) {
30
1
  return self.weights;
31
}
32
33
1
void exposeContact6D() {
34
1
  bp::class_<Contact6DSettings>("Contact6DSettings")
35
✓✗
1
      .def_readwrite("frame_name", &Contact6DSettings::frame_name)
36
✓✗
1
      .def_readwrite("gu", &Contact6DSettings::gu)
37
✓✗
1
      .def_readwrite("mu", &Contact6DSettings::mu)
38
✓✗
1
      .add_property("weights", &get_weights, &set_weights)
39
✓✗
1
      .def_readwrite("half_width", &Contact6DSettings::half_width)
40
✓✗
2
      .def_readwrite("half_length", &Contact6DSettings::half_length)
41
✓✗
1
      .def("__repr__", &Contact6DSettings::to_string)
42
✓✗
1
      .def("__eq__", &Contact6DSettings::operator==)
43
✓✗
1
      .def("__ne__", &Contact6DSettings::operator!=);
44
45
✓✗
1
  bp::class_<Contact6D>("Contact6D", bp::init<>())
46
✓✗✓✗
2
      .def("initialize", &Contact6D::initialize, bp::args("self", "settings"))
47
✓✗✓✗
2
      .def("get_settings", &get_settings, bp::args("self"))
48
✓✗✓✗
2
      .def("set_mu", &Contact6D::setMu, bp::args("self", "mu"))
49
✓✗✓✗
2
      .def("set_gu", &Contact6D::setGu, bp::args("self", "gu"))
50
      .def("set_force_weights", &Contact6D::setForceWeights,
51
✓✗✓✗
2
           bp::args("self", "force_weights"))
52
      .def("set_torque_weights", &Contact6D::setTorqueWeights,
53
✓✗✓✗
2
           bp::args("self", "torque_weights"))
54
      .def("set_surface_half_width", &Contact6D::setSurfaceHalfWidth,
55
✓✗✓✗
2
           bp::args("self", "half_width"))
56
      .def("set_surface_half_length", &Contact6D::setSurfaceHalfLength,
57
✓✗✓✗
2
           bp::args("self", "half_length"))
58
      .def("update_NE_matrix", &Contact6D::updateNewtonEuler,
59
✓✗✓✗
2
           bp::args("self", "CoM", "oMf"))
60
      .def("uni_A", &Contact6D::uni_A,
61
           bp::return_value_policy<bp::reference_existing_object>(),
62
✓✗✓✗
2
           bp::args("self"))
63
      .def("uni_b", &Contact6D::uni_b,
64
           bp::return_value_policy<bp::reference_existing_object>(),
65
✓✗✓✗
2
           bp::args("self"))
66
      .def("reg_A", &Contact6D::reg_A,
67
           bp::return_value_policy<bp::reference_existing_object>(),
68
✓✗✓✗
2
           bp::args("self"))
69
      .def("reg_b", &Contact6D::reg_b,
70
           bp::return_value_policy<bp::reference_existing_object>(),
71
✓✗✓✗
2
           bp::args("self"))
72
      .def("fri_A", &Contact6D::fri_A,
73
           bp::return_value_policy<bp::reference_existing_object>(),
74
✓✗✓✗
2
           bp::args("self"))
75
      .def("fri_b", &Contact6D::fri_b,
76
           bp::return_value_policy<bp::reference_existing_object>(),
77
✓✗✓✗
2
           bp::args("self"))
78
      .def("NE_A", &Contact6D::NE_A,
79
           bp::return_value_policy<bp::reference_existing_object>(),
80
✓✗✓✗
2
           bp::args("self"))
81
✓✗✓✗
2
      .def("uni_rows", &Contact6D::uni_rows, bp::args("self"))
82
✓✗✓✗
2
      .def("fri_rows", &Contact6D::fri_rows, bp::args("self"))
83
✓✗✓✗
2
      .def("cols", &Contact6D::cols, bp::args("self"))
84
✓✗✓✗
2
      .def("get_frame_id", &Contact6D::getFrameID, bp::args("self"))
85
✓✗✓✗
2
      .def("toWorldForces", &Contact6D::toWorldForces, bp::args("self"))
86
✓✗✓✗
2
      .def("toCoMForces", &Contact6D::toCoMForces, bp::args("self"))
87
✓✗✓✗
2
      .def("set_frame_id", &Contact6D::setFrameID, bp::args("self"))
88
✓✗✓✗
2
      .def("applyForce", &Contact6D::applyForce, bp::args("self", "force"))
89
      .def("appliedForce", &Contact6D::appliedForce,
90
           bp::return_value_policy<bp::reference_existing_object>(),
91
✓✗✓✗
2
           bp::args("self"))
92
      .def("get_pose", &Contact6D::getPose,
93
           bp::return_value_policy<bp::reference_existing_object>(),
94
✓✗✓✗
1
           bp::args("self"));
95
1
}
96
}  // namespace python
97
}  // namespace dynacom