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 exposeActionQuadrupedStepPeriod() { |
9 |
|
✗ |
bp::class_<ActionModelQuadrupedStepPeriod, bp::bases<ActionModelAbstract> >( |
10 |
|
|
"ActionModelQuadrupedStepPeriod", |
11 |
|
|
"Quadruped action model, non linear.\n\n" |
12 |
|
|
"The model is based on simplified dynamic model\n" |
13 |
|
|
" xnext = Ax + Bu + g,\n" |
14 |
|
|
"The lever arms assumption is not take into account : the B matrix and " |
15 |
|
|
"its derivative depends on the state x\n" |
16 |
|
|
"where x i the state vector defined as : \n" |
17 |
|
|
"x = [x , y, z, rool, pitch, yaw, Vx, Vy, Vz, Vrool, Vpitch, Vyaw] , 12x " |
18 |
|
|
"\n\n" |
19 |
|
|
"and u is the groud reaction forces at each 4 foot, defined as : \n" |
20 |
|
|
"u = [fx1 , fy1, fz1, ... fz4], 12x", |
21 |
|
✗ |
bp::init<>(bp::args("self"), "Initialize the quadruped action model.")) |
22 |
|
✗ |
.def("calc", &ActionModelQuadrupedStepPeriod::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 (ActionModelQuadrupedStepPeriod::*)( |
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", &ActionModelQuadrupedStepPeriod::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 (ActionModelQuadrupedStepPeriod::*)( |
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", &ActionModelQuadrupedStepPeriod::createData, |
54 |
|
✗ |
bp::args("self"), "Create the quadruped action data.") |
55 |
|
✗ |
.def("updateModel", &ActionModelQuadrupedStepPeriod::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( |
68 |
|
|
"stateWeights", |
69 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStepPeriod::get_state_weights, |
70 |
|
✗ |
bp::return_internal_reference<>()), |
71 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStepPeriod::set_state_weights), |
72 |
|
|
"Weights on the state vector") |
73 |
|
✗ |
.add_property("shoulderWeights", |
74 |
|
✗ |
bp::make_function( |
75 |
|
|
&ActionModelQuadrupedStepPeriod::get_shoulder_weights, |
76 |
|
✗ |
bp::return_internal_reference<>()), |
77 |
|
✗ |
bp::make_function( |
78 |
|
|
&ActionModelQuadrupedStepPeriod::set_shoulder_weights), |
79 |
|
|
"Weights on the shoulder term") |
80 |
|
✗ |
.add_property( |
81 |
|
|
"stepWeights", |
82 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStepPeriod::get_step_weights, |
83 |
|
✗ |
bp::return_internal_reference<>()), |
84 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStepPeriod::set_step_weights), |
85 |
|
|
"Weights on the command norm") |
86 |
|
✗ |
.add_property( |
87 |
|
|
"symmetry_term", |
88 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStepPeriod::get_symmetry_term, |
89 |
|
✗ |
bp::return_value_policy<bp::return_by_value>()), |
90 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStepPeriod::set_symmetry_term), |
91 |
|
|
"symmetry term for the foot position heuristic") |
92 |
|
✗ |
.add_property("centrifugal_term", |
93 |
|
✗ |
bp::make_function( |
94 |
|
|
&ActionModelQuadrupedStepPeriod::get_centrifugal_term, |
95 |
|
✗ |
bp::return_value_policy<bp::return_by_value>()), |
96 |
|
✗ |
bp::make_function( |
97 |
|
|
&ActionModelQuadrupedStepPeriod::set_centrifugal_term), |
98 |
|
|
"centrifugal term for the foot position heuristic") |
99 |
|
✗ |
.add_property( |
100 |
|
|
"T_gait", |
101 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStepPeriod::get_T_gait, |
102 |
|
✗ |
bp::return_value_policy<bp::return_by_value>()), |
103 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStepPeriod::set_T_gait), |
104 |
|
|
"Gait period, used to compute the symmetry term") |
105 |
|
✗ |
.add_property( |
106 |
|
|
"dt_ref", |
107 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStepPeriod::get_dt_ref, |
108 |
|
✗ |
bp::return_value_policy<bp::return_by_value>()), |
109 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStepPeriod::set_dt_ref), |
110 |
|
|
"dt_ref used on the dt reference : || dt - dt_ref||^2 ") |
111 |
|
✗ |
.add_property( |
112 |
|
|
"dt_min", |
113 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStepPeriod::get_dt_min, |
114 |
|
✗ |
bp::return_value_policy<bp::return_by_value>()), |
115 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStepPeriod::set_dt_min), |
116 |
|
|
"Minimum dt") |
117 |
|
✗ |
.add_property( |
118 |
|
|
"dt_max", |
119 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStepPeriod::get_dt_max, |
120 |
|
✗ |
bp::return_value_policy<bp::return_by_value>()), |
121 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStepPeriod::set_dt_max), |
122 |
|
|
"Maximum dt") |
123 |
|
✗ |
.add_property( |
124 |
|
|
"dt_weight", |
125 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStepPeriod::get_dt_weight, |
126 |
|
✗ |
bp::return_value_policy<bp::return_by_value>()), |
127 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStepPeriod::set_dt_weight), |
128 |
|
|
"Weight on the dt reference : || dt - dt_ref||^2 ") |
129 |
|
✗ |
.add_property("dt_weight_bound", |
130 |
|
✗ |
bp::make_function( |
131 |
|
|
&ActionModelQuadrupedStepPeriod::get_dt_bound_weight, |
132 |
|
✗ |
bp::return_value_policy<bp::return_by_value>()), |
133 |
|
✗ |
bp::make_function( |
134 |
|
|
&ActionModelQuadrupedStepPeriod::set_dt_bound_weight), |
135 |
|
|
"Weight on the dt limit : || dt_min - dt||^2 etc..") |
136 |
|
✗ |
.add_property( |
137 |
|
|
"nb_nodes", |
138 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStepPeriod::get_nb_nodes, |
139 |
|
✗ |
bp::return_value_policy<bp::return_by_value>()), |
140 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStepPeriod::set_nb_nodes), |
141 |
|
|
"Nb of nodes during flying phase") |
142 |
|
✗ |
.add_property( |
143 |
|
|
"vlim", |
144 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStepPeriod::get_vlim, |
145 |
|
✗ |
bp::return_value_policy<bp::return_by_value>()), |
146 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStepPeriod::set_vlim), |
147 |
|
|
"Speed limit of the x and y foot trajectory") |
148 |
|
✗ |
.add_property( |
149 |
|
|
"speed_weight", |
150 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStepPeriod::get_speed_weight, |
151 |
|
✗ |
bp::return_value_policy<bp::return_by_value>()), |
152 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStepPeriod::set_speed_weight), |
153 |
|
|
"Speed limit of the x and y foot trajectory"); |
154 |
|
|
|
155 |
|
|
bp::register_ptr_to_python< |
156 |
|
✗ |
boost::shared_ptr<ActionDataQuadrupedStepPeriod> >(); |
157 |
|
|
|
158 |
|
✗ |
bp::class_<ActionDataQuadrupedStepPeriod, bp::bases<ActionDataAbstract> >( |
159 |
|
|
"ActionDataQuadrupedStepPeriod", |
160 |
|
|
"Action data for the non linear quadruped system.\n\n" |
161 |
|
|
"The quadruped data, apart of common one, contains the cost residuals " |
162 |
|
|
"used\n" |
163 |
|
|
"for the computation of calc and calcDiff.", |
164 |
|
✗ |
bp::init<ActionModelQuadrupedStepPeriod*>( |
165 |
|
✗ |
bp::args("self", "model"), |
166 |
|
|
"Create quadruped data.\n\n" |
167 |
|
|
":param model: quadruped action model")); |
168 |
|
|
} |
169 |
|
|
|
170 |
|
|
} // namespace python |
171 |
|
|
} // namespace quadruped_walkgen |
172 |
|
|
|