GCC Code Coverage Report


Directory: ./
File: python/quadruped_walkgen/quadruped_step_time.cpp
Date: 2024-12-02 00:24:10
Exec Total Coverage
Lines: 0 62 0.0%
Branches: 0 96 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 exposeActionQuadrupedStepTime() {
9 bp::class_<ActionModelQuadrupedStepTime, bp::bases<ActionModelAbstract> >(
10 "ActionModelQuadrupedStepTime",
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", &ActionModelQuadrupedStepTime::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 (ActionModelQuadrupedStepTime::*)(
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", &ActionModelQuadrupedStepTime::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 (ActionModelQuadrupedStepTime::*)(
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", &ActionModelQuadrupedStepTime::createData,
54 bp::args("self"), "Create the quadruped action data.")
55 .def("updateModel", &ActionModelQuadrupedStepTime::update_model,
56 bp::args("self", "l_feet", "velocity", "acceleration", "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(&ActionModelQuadrupedStepTime::get_state_weights,
70 bp::return_internal_reference<>()),
71 bp::make_function(&ActionModelQuadrupedStepTime::set_state_weights),
72 "Weights on the state vector")
73 .add_property("heuristicWeights",
74 bp::make_function(
75 &ActionModelQuadrupedStepTime::get_heuristic_weights,
76 bp::return_internal_reference<>()),
77 bp::make_function(
78 &ActionModelQuadrupedStepTime::set_heuristic_weights),
79 "Weights on the shoulder term")
80 .add_property(
81 "stepWeights",
82 bp::make_function(&ActionModelQuadrupedStepTime::get_step_weights,
83 bp::return_internal_reference<>()),
84 bp::make_function(&ActionModelQuadrupedStepTime::set_step_weights),
85 "Weights on the command norm")
86 .add_property(
87 "symmetry_term",
88 bp::make_function(&ActionModelQuadrupedStepTime::get_symmetry_term,
89 bp::return_value_policy<bp::return_by_value>()),
90 bp::make_function(&ActionModelQuadrupedStepTime::set_symmetry_term),
91 "symmetry term for the foot position heuristic")
92 .add_property(
93 "centrifugal_term",
94 bp::make_function(&ActionModelQuadrupedStepTime::get_centrifugal_term,
95 bp::return_value_policy<bp::return_by_value>()),
96 bp::make_function(
97 &ActionModelQuadrupedStepTime::set_centrifugal_term),
98 "centrifugal term for the foot position heuristic")
99 .add_property(
100 "T_gait",
101 bp::make_function(&ActionModelQuadrupedStepTime::get_T_gait,
102 bp::return_value_policy<bp::return_by_value>()),
103 bp::make_function(&ActionModelQuadrupedStepTime::set_T_gait),
104 "Gait period, used to compute the symmetry term")
105 .add_property(
106 "speed_weight",
107 bp::make_function(&ActionModelQuadrupedStepTime::get_speed_weight,
108 bp::return_value_policy<bp::return_by_value>()),
109 bp::make_function(&ActionModelQuadrupedStepTime::set_speed_weight),
110 "Gait period, used to compute the symmetry term")
111 .add_property(
112 "vlim",
113 bp::make_function(&ActionModelQuadrupedStepTime::get_vlim,
114 bp::return_value_policy<bp::return_by_value>()),
115 bp::make_function(&ActionModelQuadrupedStepTime::set_vlim),
116 "Gait period, used to compute the symmetry term")
117 .add_property(
118 "nb_nodes",
119 bp::make_function(&ActionModelQuadrupedStepTime::get_nb_nodes,
120 bp::return_value_policy<bp::return_by_value>()),
121 bp::make_function(&ActionModelQuadrupedStepTime::set_nb_nodes),
122 "Gait period, used to compute the symmetry term")
123 .add_property(
124 "first_step",
125 bp::make_function(&ActionModelQuadrupedStepTime::get_first_step,
126 bp::return_value_policy<bp::return_by_value>()),
127 bp::make_function(&ActionModelQuadrupedStepTime::set_first_step),
128 "bool thats indicates xhether it is the first step foot, otherwise "
129 "function cost is much simpler")
130 .add_property("Cost",
131 bp::make_function(&ActionModelQuadrupedStepTime::get_cost,
132 bp::return_internal_reference<>()),
133 "get log cost");
134
135 bp::register_ptr_to_python<boost::shared_ptr<ActionDataQuadrupedStepTime> >();
136
137 bp::class_<ActionDataQuadrupedStepTime, bp::bases<ActionDataAbstract> >(
138 "ActionDataQuadrupedStepTime",
139 "Action data for the non linear quadruped system.\n\n"
140 "The quadruped data, apart of common one, contains the cost residuals "
141 "used\n"
142 "for the computation of calc and calcDiff.",
143 bp::init<ActionModelQuadrupedStepTime*>(
144 bp::args("self", "model"),
145 "Create quadruped data.\n\n"
146 ":param model: quadruped action model"));
147 }
148
149 } // namespace python
150 } // namespace quadruped_walkgen
151