1 |
|
|
#include "aig/dyna_com.hpp" |
2 |
|
|
|
3 |
|
|
#include <pinocchio/multibody/fwd.hpp> |
4 |
|
|
// Must be included first! |
5 |
|
|
#include <boost/python.hpp> |
6 |
|
|
#include <boost/python/return_internal_reference.hpp> |
7 |
|
|
#include <boost/python/suite/indexing/vector_indexing_suite.hpp> |
8 |
|
|
#include <eigenpy/eigenpy.hpp> |
9 |
|
|
|
10 |
|
|
#include "aig/contact6d.hpp" |
11 |
|
|
#include "aig/python.hpp" |
12 |
|
|
|
13 |
|
|
namespace aig { |
14 |
|
|
namespace python { |
15 |
|
|
namespace bp = boost::python; |
16 |
|
|
|
17 |
|
|
bp::dict get_settings(DynaCoM &self) { |
18 |
|
|
bp::dict settings; |
19 |
|
|
DynaCoMSettings conf = self.getSettings(); |
20 |
|
|
settings["urdf"] = conf.urdf; |
21 |
|
|
|
22 |
|
|
return settings; |
23 |
|
|
} |
24 |
|
|
|
25 |
|
|
std::shared_ptr<Contact6D> getContact(DynaCoM &self, std::string name) { |
26 |
|
|
return boost::ref(self.getContact(name)); |
27 |
|
|
} |
28 |
|
|
|
29 |
|
|
void exposeDynaCoM() { |
30 |
|
|
bp::class_<std::vector<std::string> >("names_vector") |
31 |
|
|
.def(bp::vector_indexing_suite<std::vector<std::string> >()); |
32 |
|
|
|
33 |
|
|
bp::class_<DynaCoMSettings>("DynaCoMSettings") |
34 |
|
|
.def_readwrite("urdf", &DynaCoMSettings::urdf); |
35 |
|
|
|
36 |
|
|
bp::class_<DynaCoM, boost::noncopyable>("DynaCoM", bp::init<>()) |
37 |
|
|
.def("initialize", &DynaCoM::initialize, bp::args("self", "settings")) |
38 |
|
|
.def("computeDynamics", &DynaCoM::computeDynamics, |
39 |
|
|
(bp::arg("self"), bp::arg("posture"), bp::arg("velocity"), |
40 |
|
|
bp::arg("aceleration"), bp::arg("extWrench"), |
41 |
|
|
bp::arg("flatHorizontalGround") = true)) |
42 |
|
|
.def<void (DynaCoM::*)(const double &, const Eigen::VectorXd &, |
43 |
|
|
const Eigen::VectorXd &, const Eigen::VectorXd &, |
44 |
|
|
const Eigen::Matrix<double, 6, 1> &, |
45 |
|
|
bool flatHorizontalGround)>( |
46 |
|
|
"computeNL", &DynaCoM::computeNL, |
47 |
|
|
bp::args("self", "posture", "velocity", "aceleration", "extWrench", |
48 |
|
|
"flatHorizontalGround")) |
49 |
|
|
.def<void (DynaCoM::*)(const double &)>("computeNL", &DynaCoM::computeNL, |
50 |
|
|
bp::args("self")) |
51 |
|
|
.def("addContact6d", &DynaCoM::addContact6d, |
52 |
|
|
(bp::arg("self"), bp::arg("contact"), bp::arg("name"), |
53 |
|
|
bp::arg("active") = true)) |
54 |
|
|
.def("removeContact6d", &DynaCoM::removeContact6d, |
55 |
|
|
bp::args("self", "name")) |
56 |
|
|
.def("activateContact6d", &DynaCoM::activateContact6d, |
57 |
|
|
bp::args("self", "name")) |
58 |
|
|
.def("deactivateContact6d", &DynaCoM::deactivateContact6d, |
59 |
|
|
bp::args("self", "name")) |
60 |
|
|
.def("distributeForce", &DynaCoM::distributeForce, |
61 |
|
|
bp::args("self", "groundCoMForce", "groundCoMTorque", "CoM")) |
62 |
|
|
.def("getContact", &getContact, bp::args("self", "name")) |
63 |
|
|
.def("getActiveContacts", &DynaCoM::getActiveContacts, |
64 |
|
|
bp::return_value_policy<bp::copy_const_reference>(), |
65 |
|
|
bp::args("self")) |
66 |
|
|
.def("uni_A", &DynaCoM::uni_A, bp::args("self")) |
67 |
|
|
.def("uni_b", &DynaCoM::uni_b, bp::args("self")) |
68 |
|
|
.def("fri_A", &DynaCoM::fri_A, bp::args("self")) |
69 |
|
|
.def("fri_b", &DynaCoM::fri_b, bp::args("self")) |
70 |
|
|
.def("reg_A", &DynaCoM::reg_A, bp::args("self")) |
71 |
|
|
.def("reg_b", &DynaCoM::reg_b, bp::args("self")) |
72 |
|
|
.def("NE_A", &DynaCoM::NE_A, bp::args("self")) |
73 |
|
|
.def("NE_b", &DynaCoM::NE_b, |
74 |
|
|
bp::return_value_policy<bp::reference_existing_object>(), |
75 |
|
|
bp::args("self")) |
76 |
|
|
.def("allForces", &DynaCoM::allForces, |
77 |
|
|
bp::return_value_policy<bp::reference_existing_object>(), |
78 |
|
|
bp::args("self")) |
79 |
|
|
.def("model", &DynaCoM::getModel, |
80 |
|
|
bp::return_value_policy<bp::reference_existing_object>(), |
81 |
|
|
bp::args("self")) |
82 |
|
|
.def("data", &DynaCoM::getData, |
83 |
|
|
bp::return_value_policy<bp::reference_existing_object>(), |
84 |
|
|
bp::args("self")) |
85 |
|
|
.def("getCoM", &DynaCoM::getCoM, |
86 |
|
|
bp::return_value_policy<bp::reference_existing_object>(), |
87 |
|
|
bp::args("self")) |
88 |
|
|
.def("getVCoM", &DynaCoM::getVCoM, |
89 |
|
|
bp::return_value_policy<bp::reference_existing_object>(), |
90 |
|
|
bp::args("self")) |
91 |
|
|
.def("getACoM", &DynaCoM::getACoM, |
92 |
|
|
bp::return_value_policy<bp::reference_existing_object>(), |
93 |
|
|
bp::args("self")) |
94 |
|
|
.def("getAM", &DynaCoM::getAM, |
95 |
|
|
bp::return_value_policy<bp::reference_existing_object>(), |
96 |
|
|
bp::args("self")) |
97 |
|
|
.def("getCoP", &DynaCoM::getCoP, |
98 |
|
|
bp::return_value_policy<bp::reference_existing_object>(), |
99 |
|
|
bp::args("self")) |
100 |
|
|
.def("getNL", &DynaCoM::getNL, |
101 |
|
|
bp::return_value_policy<bp::reference_existing_object>(), |
102 |
|
|
bp::args("self")) |
103 |
|
|
.def("getGroundCoMForce", &DynaCoM::getGroundCoMForce, |
104 |
|
|
bp::return_value_policy<bp::reference_existing_object>(), |
105 |
|
|
bp::args("self")) |
106 |
|
|
.def("getGroundCoMTorque", &DynaCoM::getGroundCoMTorque, |
107 |
|
|
bp::return_value_policy<bp::reference_existing_object>(), |
108 |
|
|
bp::args("self")); |
109 |
|
|
} |
110 |
|
|
} // namespace python |
111 |
|
|
} // namespace aig |