GCC Code Coverage Report


Directory: ./
File: python/quadruped_walkgen/quadruped_augmented_time.cpp
Date: 2024-12-02 00:24:10
Exec Total Coverage
Lines: 0 104 0.0%
Branches: 0 158 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 exposeActionQuadrupedAugmentedTime() {
9 bp::class_<ActionModelQuadrupedAugmentedTime,
10 bp::bases<ActionModelAbstract> >(
11 "ActionModelQuadrupedAugmentedTime",
12 "Quadruped action model, non linear.\n\n"
13 "The model is based on simplified dynamic model\n"
14 " xnext = Ax + Bu + g,\n"
15 "The lever arms assumption is not take into account : the B matrix and "
16 "its derivative depends on the state x\n"
17 "where x i the state vector defined as : \n"
18 "x = [x , y, z, rool, pitch, yaw, Vx, Vy, Vz, Vrool, Vpitch, Vyaw] , 12x "
19 "\n\n"
20 "and u is the groud reaction forces at each 4 foot, defined as : \n"
21 "u = [fx1 , fy1, fz1, ... fz4], 12x",
22 bp::init<>(bp::args("self"), "Initialize the quadruped action model."))
23 .def("calc", &ActionModelQuadrupedAugmentedTime::calc,
24 bp::args("self", "data", "x", "u"),
25 "Compute the next state and cost value.\n\n"
26 "It describes the time-discrete evolution of the quadruped system.\n"
27 "Additionally it computes the cost value associated to this "
28 "discrete\n"
29 "state and control pair.\n"
30 ":param data: action data\n"
31 ":param x: time-discrete state vector\n"
32 ":param u: time-discrete control input")
33 .def<void (ActionModelQuadrupedAugmentedTime::*)(
34 const boost::shared_ptr<ActionDataAbstract>&,
35 const Eigen::Ref<const Eigen::VectorXd>&)>(
36 "calc", &ActionModelAbstract::calc, bp::args("self", "data", "x"))
37 .def("calcDiff", &ActionModelQuadrupedAugmentedTime::calcDiff,
38 bp::args("self", "data", "x", "u"),
39 "Compute the derivatives of the quadruped dynamics and cost "
40 "functions.\n\n"
41 "It computes the partial derivatives of the quadruped system and "
42 "the\n"
43 "cost function. It assumes that calc has been run first.\n"
44 "This function builds a quadratic approximation of the\n"
45 "action model (i.e. dynamical system and cost function).\n"
46 ":param data: action data\n"
47 ":param x: time-discrete state vector\n"
48 ":param u: time-discrete control input\n")
49 .def<void (ActionModelQuadrupedAugmentedTime::*)(
50 const boost::shared_ptr<ActionDataAbstract>&,
51 const Eigen::Ref<const Eigen::VectorXd>&)>(
52 "calcDiff", &ActionModelAbstract::calcDiff,
53 bp::args("self", "data", "x"))
54 .def("createData", &ActionModelQuadrupedAugmentedTime::createData,
55 bp::args("self"), "Create the quadruped action data.")
56 .def("updateModel", &ActionModelQuadrupedAugmentedTime::update_model,
57 bp::args("self", "l_feet", "xref", "S"),
58 "Update the quadruped model depending on the position of the foot "
59 "in the local frame\n\n"
60 ":param l_feet : 3x4, Matrix representing the position of the foot "
61 "in the local frame \n "
62 " Each colum represents the position of one foot : "
63 "x,y,z"
64 ":param xref : 12x1, Vector representing the reference state."
65 ":param S : 4x1, Vector representing the foot in contact with the "
66 "ground."
67 " S = [1 0 0 1] --> Foot 1 and 4 in contact.")
68 .add_property("forceWeights",
69 bp::make_function(
70 &ActionModelQuadrupedAugmentedTime::get_force_weights,
71 bp::return_internal_reference<>()),
72 bp::make_function(
73 &ActionModelQuadrupedAugmentedTime::set_force_weights),
74 "Weights on the control input : ground reaction forces")
75 .add_property("stateWeights",
76 bp::make_function(
77 &ActionModelQuadrupedAugmentedTime::get_state_weights,
78 bp::return_internal_reference<>()),
79 bp::make_function(
80 &ActionModelQuadrupedAugmentedTime::set_state_weights),
81 "Weights on the state vector")
82 .add_property(
83 "heuristicWeights",
84 bp::make_function(
85 &ActionModelQuadrupedAugmentedTime::get_heuristic_weights,
86 bp::return_internal_reference<>()),
87 bp::make_function(
88 &ActionModelQuadrupedAugmentedTime::set_heuristic_weights),
89 "Weights on the heuristic position of the feet")
90 .add_property("stopWeights",
91 bp::make_function(
92 &ActionModelQuadrupedAugmentedTime::get_stop_weights,
93 bp::return_internal_reference<>()),
94 bp::make_function(
95 &ActionModelQuadrupedAugmentedTime::set_stop_weights),
96 "Weights on the last position term")
97 .add_property(
98 "frictionWeights",
99 bp::make_function(
100 &ActionModelQuadrupedAugmentedTime::get_friction_weight,
101 bp::return_value_policy<bp::return_by_value>()),
102 bp::make_function(
103 &ActionModelQuadrupedAugmentedTime::set_friction_weight),
104 "Weight on friction cone term")
105 .add_property(
106 "mu",
107 bp::make_function(&ActionModelQuadrupedAugmentedTime::get_mu,
108 bp::return_value_policy<bp::return_by_value>()),
109 bp::make_function(&ActionModelQuadrupedAugmentedTime::set_mu),
110 "Friction coefficient")
111 .add_property(
112 "mass",
113 bp::make_function(&ActionModelQuadrupedAugmentedTime::get_mass,
114 bp::return_value_policy<bp::return_by_value>()),
115 bp::make_function(&ActionModelQuadrupedAugmentedTime::set_mass),
116 "Mass \n Warning : The model needs to be updated")
117 .add_property(
118 "dt_min",
119 bp::make_function(&ActionModelQuadrupedAugmentedTime::get_dt_min,
120 bp::return_value_policy<bp::return_by_value>()),
121 bp::make_function(&ActionModelQuadrupedAugmentedTime::set_dt_min),
122 "dt lower bound")
123 .add_property(
124 "dt_max",
125 bp::make_function(&ActionModelQuadrupedAugmentedTime::get_dt_max,
126 bp::return_value_policy<bp::return_by_value>()),
127 bp::make_function(&ActionModelQuadrupedAugmentedTime::set_dt_max),
128 "dt upper bound")
129 .add_property(
130 "min_fz",
131 bp::make_function(
132 &ActionModelQuadrupedAugmentedTime::get_min_fz_contact,
133 bp::return_value_policy<bp::return_by_value>()),
134 bp::make_function(
135 &ActionModelQuadrupedAugmentedTime::set_min_fz_contact),
136 "min normal force \n Warning : The model needs to be updated")
137 .add_property(
138 "max_fz",
139 bp::make_function(
140 &ActionModelQuadrupedAugmentedTime::get_max_fz_contact,
141 bp::return_value_policy<bp::return_by_value>()),
142 bp::make_function(
143 &ActionModelQuadrupedAugmentedTime::set_max_fz_contact),
144 "max normal force \n Warning : The model needs to be updated")
145 .add_property(
146 "gI",
147 bp::make_function(&ActionModelQuadrupedAugmentedTime::get_gI,
148 bp::return_value_policy<bp::return_by_value>()),
149 bp::make_function(&ActionModelQuadrupedAugmentedTime::set_gI),
150 "Inertia matrix of the robot in body frame (found in urdf) \n "
151 "Warning : The model needs to be updated")
152 .add_property("A",
153 bp::make_function(&ActionModelQuadrupedAugmentedTime::get_A,
154 bp::return_internal_reference<>()),
155 "get A matrix")
156 .add_property("B",
157 bp::make_function(&ActionModelQuadrupedAugmentedTime::get_B,
158 bp::return_internal_reference<>()),
159 "get B matrix")
160 .add_property(
161 "Cost",
162 bp::make_function(&ActionModelQuadrupedAugmentedTime::get_cost,
163 bp::return_internal_reference<>()),
164 "get log cost")
165 .add_property("shoulder_hlim",
166 bp::make_function(
167 &ActionModelQuadrupedAugmentedTime::get_shoulder_hlim,
168 bp::return_value_policy<bp::return_by_value>()),
169 bp::make_function(
170 &ActionModelQuadrupedAugmentedTime::set_shoulder_hlim),
171 "Shoulder height limit ")
172 .add_property(
173 "shoulderContactWeight",
174 bp::make_function(
175 &ActionModelQuadrupedAugmentedTime::get_shoulder_contact_weight,
176 bp::return_value_policy<bp::return_by_value>()),
177 bp::make_function(
178 &ActionModelQuadrupedAugmentedTime::set_shoulder_contact_weight),
179 "shoulder Weight term (scalar) ")
180 .add_property(
181 "relative_forces",
182 bp::make_function(
183 &ActionModelQuadrupedAugmentedTime::get_relative_forces,
184 bp::return_value_policy<bp::return_by_value>()),
185 bp::make_function(
186 &ActionModelQuadrupedAugmentedTime::set_relative_forces),
187 "relative norm ")
188 .add_property("symmetry_term",
189 bp::make_function(
190 &ActionModelQuadrupedAugmentedTime::get_symmetry_term,
191 bp::return_value_policy<bp::return_by_value>()),
192 bp::make_function(
193 &ActionModelQuadrupedAugmentedTime::set_symmetry_term),
194 "symmetry term for the foot position heuristic")
195 .add_property(
196 "centrifugal_term",
197 bp::make_function(
198 &ActionModelQuadrupedAugmentedTime::get_centrifugal_term,
199 bp::return_value_policy<bp::return_by_value>()),
200 bp::make_function(
201 &ActionModelQuadrupedAugmentedTime::set_centrifugal_term),
202 "centrifugal term for the foot position heuristic")
203 .add_property(
204 "T_gait",
205 bp::make_function(&ActionModelQuadrupedAugmentedTime::get_T_gait,
206 bp::return_value_policy<bp::return_by_value>()),
207 bp::make_function(&ActionModelQuadrupedAugmentedTime::set_T_gait),
208 "Gait period, used to compute the symmetry term")
209 .add_property(
210 "dt_weight_bound",
211 bp::make_function(
212 &ActionModelQuadrupedAugmentedTime::get_dt_bound_weight,
213 bp::return_value_policy<bp::return_by_value>()),
214 bp::make_function(
215 &ActionModelQuadrupedAugmentedTime::set_dt_bound_weight),
216 "Weight to penal");
217
218 bp::register_ptr_to_python<
219 boost::shared_ptr<ActionDataQuadrupedAugmentedTime> >();
220
221 bp::class_<ActionDataQuadrupedAugmentedTime, bp::bases<ActionDataAbstract> >(
222 "ActionDataQuadrupedAugmentedTime",
223 "Action data for the non linear quadruped system.\n\n"
224 "The quadruped data, apart of common one, contains the cost residuals "
225 "used\n"
226 "for the computation of calc and calcDiff.",
227 bp::init<ActionModelQuadrupedAugmentedTime*>(
228 bp::args("self", "model"),
229 "Create quadruped data.\n\n"
230 ":param model: quadruped action model"));
231 }
232
233 } // namespace python
234 } // namespace quadruped_walkgen
235