GCC Code Coverage Report


Directory: ./
File: python/quadruped_walkgen/quadruped.cpp
Date: 2024-12-02 00:24:10
Exec Total Coverage
Lines: 0 76 0.0%
Branches: 0 118 0.0%

Line Branch Exec Source
1
2 #include "action-base.hpp"
3 #include "core.hpp"
4
5 namespace quadruped_walkgen {
6 namespace python {
7
8 void exposeActionQuadruped() {
9 bp::class_<ActionModelQuadruped, bp::bases<ActionModelAbstract>>(
10 "ActionModelQuadruped",
11 "Quadruped action model.\n\n"
12 "The model is based on simplified dynamic model\n"
13 " xnext = Ax + Bu + g,\n"
14 "where x i the state vector defined as : \n"
15 "x = [x , y, z, rool, pitch, yaw, Vx, Vy, Vz, Vrool, Vpitch, Vyaw] , 12x "
16 "\n\n"
17 "and u is the groud reaction forces at each 4 foot, defined as : \n"
18 "u = [fx1 , fy1, fz1, ... fz4], 12x",
19 bp::init<Eigen::Matrix<double, 3, 1>>(
20 bp::args("self", "offset_CoM"),
21 "Initialize the quadruped action model."))
22 .def("calc", &ActionModelQuadruped::calc,
23 bp::args("self", "data", "x", "u"),
24 "Compute the next state and cost value.\n\n"
25 "It describes the time-discrete evolution of the quadruped system.\n"
26 "Additionally it computes the cost value associated to this "
27 "discrete\n"
28 "state and control pair.\n"
29 ":param data: action data\n"
30 ":param x: time-discrete state vector\n"
31 ":param u: time-discrete control input")
32 .def<void (ActionModelQuadruped::*)(
33 const boost::shared_ptr<ActionDataAbstract>&,
34 const Eigen::Ref<const Eigen::VectorXd>&)>(
35 "calc", &ActionModelAbstract::calc, bp::args("self", "data", "x"))
36 .def("calcDiff", &ActionModelQuadruped::calcDiff,
37 bp::args("self", "data", "x", "u"),
38 "Compute the derivatives of the quadruped dynamics and cost "
39 "functions.\n\n"
40 "It computes the partial derivatives of the quadruped system and "
41 "the\n"
42 "cost function. It assumes that calc has been run first.\n"
43 "This function builds a quadratic approximation of the\n"
44 "action model (i.e. dynamical system and cost function).\n"
45 ":param data: action data\n"
46 ":param x: time-discrete state vector\n"
47 ":param u: time-discrete control input\n")
48 .def<void (ActionModelQuadruped::*)(
49 const boost::shared_ptr<ActionDataAbstract>&,
50 const Eigen::Ref<const Eigen::VectorXd>&)>(
51 "calcDiff", &ActionModelAbstract::calcDiff,
52 bp::args("self", "data", "x"))
53 .def("createData", &ActionModelQuadruped::createData, bp::args("self"),
54 "Create the quadruped action data.")
55 .def("updateModel", &ActionModelQuadruped::update_model,
56 bp::args("self", "l_feet", "xref", "S"),
57 "Update the quadruped model depending on the position of the foot "
58 "in the local frame\n\n"
59 ":param l_feet : 3x4, Matrix representing the position of the foot "
60 "in the local frame \n "
61 " Each colum represents the position of one foot : "
62 "x,y,z"
63 ":param xref : 12x1, Vector representing the reference state."
64 ":param S : 4x1, Vector representing the foot in contact with the "
65 "ground."
66 " S = [1 0 0 1] --> Foot 1 and 4 in contact.")
67 .add_property("forceWeights",
68 bp::make_function(&ActionModelQuadruped::get_force_weights,
69 bp::return_internal_reference<>()),
70 bp::make_function(&ActionModelQuadruped::set_force_weights),
71 "Weights on the control input : ground reaction forces")
72 .add_property("stateWeights",
73 bp::make_function(&ActionModelQuadruped::get_state_weights,
74 bp::return_internal_reference<>()),
75 bp::make_function(&ActionModelQuadruped::set_state_weights),
76 "Weights on the state vector")
77 .add_property(
78 "frictionWeights",
79 bp::make_function(&ActionModelQuadruped::get_friction_weight,
80 bp::return_value_policy<bp::return_by_value>()),
81 bp::make_function(&ActionModelQuadruped::set_friction_weight),
82 "Weight on friction cone term")
83 .add_property(
84 "mu",
85 bp::make_function(&ActionModelQuadruped::get_mu,
86 bp::return_value_policy<bp::return_by_value>()),
87 bp::make_function(&ActionModelQuadruped::set_mu),
88 "Friction coefficient")
89 .add_property(
90 "mass",
91 bp::make_function(&ActionModelQuadruped::get_mass,
92 bp::return_value_policy<bp::return_by_value>()),
93 bp::make_function(&ActionModelQuadruped::set_mass),
94 "Mass \n Warning : The model needs to be updated")
95 .add_property(
96 "dt",
97 bp::make_function(&ActionModelQuadruped::get_dt,
98 bp::return_value_policy<bp::return_by_value>()),
99 bp::make_function(&ActionModelQuadruped::set_dt),
100 "Minimum normal force allowed for feet in contact with the ground \n "
101 "Warning : The model needs to "
102 "be updated")
103 .add_property(
104 "shoulder_hlim",
105 bp::make_function(&ActionModelQuadruped::get_shoulder_hlim,
106 bp::return_value_policy<bp::return_by_value>()),
107 bp::make_function(&ActionModelQuadruped::set_shoulder_hlim),
108 "Shoulder height limit ")
109 .add_property(
110 "shoulderWeights",
111 bp::make_function(&ActionModelQuadruped::get_shoulder_weight,
112 bp::return_value_policy<bp::return_by_value>()),
113 bp::make_function(&ActionModelQuadruped::set_shoulder_weight),
114 "shoulder Weight term (scalar) ")
115 .add_property(
116 "min_fz",
117 bp::make_function(&ActionModelQuadruped::get_min_fz_contact,
118 bp::return_value_policy<bp::return_by_value>()),
119 bp::make_function(&ActionModelQuadruped::set_min_fz_contact),
120 "dt \n Warning : The model needs to be updated")
121 .add_property(
122 "max_fz",
123 bp::make_function(&ActionModelQuadruped::get_max_fz_contact,
124 bp::return_value_policy<bp::return_by_value>()),
125 bp::make_function(&ActionModelQuadruped::set_max_fz_contact),
126 "dt \n Warning : The model needs to be updated")
127 .add_property(
128 "gI",
129 bp::make_function(&ActionModelQuadruped::get_gI,
130 bp::return_value_policy<bp::return_by_value>()),
131 bp::make_function(&ActionModelQuadruped::set_gI),
132 "Inertia matrix of the robot in body frame (found in urdf) \n "
133 "Warning : The model needs to be updated")
134 .add_property("A",
135 bp::make_function(&ActionModelQuadruped::get_A,
136 bp::return_internal_reference<>()),
137 "get A matrix")
138 .add_property(
139 "relative_forces",
140 bp::make_function(&ActionModelQuadruped::get_relative_forces,
141 bp::return_value_policy<bp::return_by_value>()),
142 bp::make_function(&ActionModelQuadruped::set_relative_forces),
143 "relative norm ")
144 .add_property(
145 "implicit_integration",
146 bp::make_function(&ActionModelQuadruped::get_implicit_integration,
147 bp::return_value_policy<bp::return_by_value>()),
148 bp::make_function(&ActionModelQuadruped::set_implicit_integration),
149 "Bool : to set implicit integration : P+ = P + dt*V+")
150 .add_property("B",
151 bp::make_function(&ActionModelQuadruped::get_B,
152 bp::return_internal_reference<>()),
153 "get B matrix");
154
155 bp::register_ptr_to_python<boost::shared_ptr<ActionDataQuadruped>>();
156
157 bp::class_<ActionDataQuadruped, bp::bases<ActionDataAbstract>>(
158 "ActionDataQuadruped",
159 "Action data for the quadruped system.\n\n"
160 "The quadruped data, apart of common one, contains the cost residuals "
161 "used\n"
162 "for the computation of calc and calcDiff.",
163 bp::init<ActionModelQuadruped*>(bp::args("self", "model"),
164 "Create quadruped data.\n\n"
165 ":param model: quadruped action model"));
166 }
167
168 } // namespace python
169 } // namespace quadruped_walkgen
170