| 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 exposeActionQuadrupedStep() { |
| 9 |
|
✗ |
bp::class_<ActionModelQuadrupedStep, bp::bases<ActionModelAbstract> >( |
| 10 |
|
|
"ActionModelQuadrupedStep", |
| 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", &ActionModelQuadrupedStep::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 (ActionModelQuadrupedStep::*)( |
| 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", &ActionModelQuadrupedStep::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 (ActionModelQuadrupedStep::*)( |
| 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", &ActionModelQuadrupedStep::createData, |
| 54 |
|
✗ |
bp::args("self"), "Create the quadruped action data.") |
| 55 |
|
✗ |
.def("updateModel", &ActionModelQuadrupedStep::update_model, |
| 56 |
|
✗ |
bp::args("self", "l_feet", "xref", "S", "position", "velocity", |
| 57 |
|
|
"acceleration", "oRh", "oth", "Dt"), |
| 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 |
|
|
|
| 69 |
|
✗ |
.def("set_sample_feet_traj", |
| 70 |
|
|
&ActionModelQuadrupedStep::set_sample_feet_traj, |
| 71 |
|
✗ |
bp::args("self", "n_sampling"), |
| 72 |
|
|
"Modify the number of sample to approximate the feet polynomial " |
| 73 |
|
|
"trajectories \n\n" |
| 74 |
|
|
":param n_sampling : int, Number of sample") |
| 75 |
|
✗ |
.add_property( |
| 76 |
|
|
"stateWeights", |
| 77 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStep::get_state_weights, |
| 78 |
|
✗ |
bp::return_internal_reference<>()), |
| 79 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStep::set_state_weights), |
| 80 |
|
|
"Weights on the state vector") |
| 81 |
|
✗ |
.add_property( |
| 82 |
|
|
"heuristicWeights", |
| 83 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStep::get_heuristic_weights, |
| 84 |
|
✗ |
bp::return_internal_reference<>()), |
| 85 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStep::set_heuristic_weights), |
| 86 |
|
|
"Weights on the heuristic term") |
| 87 |
|
✗ |
.add_property( |
| 88 |
|
|
"stepWeights", |
| 89 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStep::get_step_weights, |
| 90 |
|
✗ |
bp::return_internal_reference<>()), |
| 91 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStep::set_step_weights), |
| 92 |
|
|
"Weights on the command norm") |
| 93 |
|
✗ |
.add_property( |
| 94 |
|
|
"symmetry_term", |
| 95 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStep::get_symmetry_term, |
| 96 |
|
✗ |
bp::return_value_policy<bp::return_by_value>()), |
| 97 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStep::set_symmetry_term), |
| 98 |
|
|
"symmetry term for the foot position heuristic") |
| 99 |
|
✗ |
.add_property( |
| 100 |
|
|
"centrifugal_term", |
| 101 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStep::get_centrifugal_term, |
| 102 |
|
✗ |
bp::return_value_policy<bp::return_by_value>()), |
| 103 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStep::set_centrifugal_term), |
| 104 |
|
|
"centrifugal term for the foot position heuristic") |
| 105 |
|
✗ |
.add_property( |
| 106 |
|
|
"T_gait", |
| 107 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStep::get_T_gait, |
| 108 |
|
✗ |
bp::return_value_policy<bp::return_by_value>()), |
| 109 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStep::set_T_gait), |
| 110 |
|
|
"Gait period, used to compute the symmetry term") |
| 111 |
|
✗ |
.add_property( |
| 112 |
|
|
"is_acc_activated", |
| 113 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStep::get_acc_activated, |
| 114 |
|
✗ |
bp::return_value_policy<bp::return_by_value>()), |
| 115 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStep::set_acc_activated), |
| 116 |
|
|
"Boolean whereas the cost on the acceleration is activated") |
| 117 |
|
✗ |
.add_property( |
| 118 |
|
|
"acc_limit", |
| 119 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStep::get_acc_lim, |
| 120 |
|
✗ |
bp::return_value_policy<bp::return_by_value>()), |
| 121 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStep::set_acc_lim), |
| 122 |
|
|
"Vector x2 containing the limit acceleration in x and y axis where " |
| 123 |
|
|
"the quadratic cost is activated") |
| 124 |
|
✗ |
.add_property( |
| 125 |
|
|
"acc_weight", |
| 126 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStep::get_acc_weight, |
| 127 |
|
✗ |
bp::return_value_policy<bp::return_by_value>()), |
| 128 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStep::set_acc_weight), |
| 129 |
|
|
"Weight to penalize the acceleration of the flying feet, (float)") |
| 130 |
|
✗ |
.add_property( |
| 131 |
|
|
"is_vel_activated", |
| 132 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStep::get_vel_activated, |
| 133 |
|
✗ |
bp::return_value_policy<bp::return_by_value>()), |
| 134 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStep::set_vel_activated), |
| 135 |
|
|
"Boolean whereas the cost on the velocity is activated") |
| 136 |
|
✗ |
.add_property( |
| 137 |
|
|
"vel_limit", |
| 138 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStep::get_vel_lim, |
| 139 |
|
✗ |
bp::return_value_policy<bp::return_by_value>()), |
| 140 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStep::set_vel_lim), |
| 141 |
|
|
"Vector x2 containing the limit velocity in x and y axis where the " |
| 142 |
|
|
"quadratic cost is activated") |
| 143 |
|
✗ |
.add_property( |
| 144 |
|
|
"vel_weight", |
| 145 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStep::get_vel_weight, |
| 146 |
|
✗ |
bp::return_value_policy<bp::return_by_value>()), |
| 147 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStep::set_vel_weight), |
| 148 |
|
|
"Weight to penalize the velocity of the flying feet, (float)") |
| 149 |
|
✗ |
.add_property( |
| 150 |
|
|
"jerk_weight", |
| 151 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStep::get_jerk_weight, |
| 152 |
|
✗ |
bp::return_value_policy<bp::return_by_value>()), |
| 153 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStep::set_jerk_weight), |
| 154 |
|
|
"Weight to penalize the jerk of the flying feet, (float)") |
| 155 |
|
✗ |
.add_property( |
| 156 |
|
|
"is_jerk_activated", |
| 157 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStep::get_jerk_activated, |
| 158 |
|
✗ |
bp::return_value_policy<bp::return_by_value>()), |
| 159 |
|
✗ |
bp::make_function(&ActionModelQuadrupedStep::set_jerk_activated), |
| 160 |
|
|
"Boolean whereas the cost on the jerk is activated"); |
| 161 |
|
|
|
| 162 |
|
✗ |
bp::register_ptr_to_python<boost::shared_ptr<ActionDataQuadrupedStep> >(); |
| 163 |
|
|
|
| 164 |
|
✗ |
bp::class_<ActionDataQuadrupedStep, bp::bases<ActionDataAbstract> >( |
| 165 |
|
|
"ActionDataQuadrupedStep", |
| 166 |
|
|
"Action data for the non linear quadruped system.\n\n" |
| 167 |
|
|
"The quadruped data, apart of common one, contains the cost residuals " |
| 168 |
|
|
"used\n" |
| 169 |
|
|
"for the computation of calc and calcDiff.", |
| 170 |
|
✗ |
bp::init<ActionModelQuadrupedStep*>( |
| 171 |
|
✗ |
bp::args("self", "model"), |
| 172 |
|
|
"Create quadruped data.\n\n" |
| 173 |
|
|
":param model: quadruped action model")); |
| 174 |
|
|
} |
| 175 |
|
|
|
| 176 |
|
|
} // namespace python |
| 177 |
|
|
} // namespace quadruped_walkgen |
| 178 |
|
|
|