GCC Code Coverage Report


Directory: ./
File: python/quadruped_walkgen/quadruped_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 exposeActionQuadrupedTime() {
9 bp::class_<ActionModelQuadrupedTime, bp::bases<ActionModelAbstract> >(
10 "ActionModelQuadrupedTime",
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", &ActionModelQuadrupedTime::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 (ActionModelQuadrupedTime::*)(
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", &ActionModelQuadrupedTime::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 (ActionModelQuadrupedTime::*)(
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", &ActionModelQuadrupedTime::createData,
54 bp::args("self"), "Create the quadruped action data.")
55 .def("updateModel", &ActionModelQuadrupedTime::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(&ActionModelQuadrupedTime::get_state_weights,
70 bp::return_internal_reference<>()),
71 bp::make_function(&ActionModelQuadrupedTime::set_state_weights),
72 "Weights on the state vector")
73 .add_property(
74 "heuristicWeights",
75 bp::make_function(&ActionModelQuadrupedTime::get_heuristic_weights,
76 bp::return_internal_reference<>()),
77 bp::make_function(&ActionModelQuadrupedTime::set_heuristic_weights),
78 "Weights on the heuristic position of the shoulder term to lead the "
79 "optimisation")
80 .add_property(
81 "symmetry_term",
82 bp::make_function(&ActionModelQuadrupedTime::get_symmetry_term,
83 bp::return_value_policy<bp::return_by_value>()),
84 bp::make_function(&ActionModelQuadrupedTime::set_symmetry_term),
85 "symmetry term for the foot position heuristic")
86 .add_property(
87 "centrifugal_term",
88 bp::make_function(&ActionModelQuadrupedTime::get_centrifugal_term,
89 bp::return_value_policy<bp::return_by_value>()),
90 bp::make_function(&ActionModelQuadrupedTime::set_centrifugal_term),
91 "centrifugal term for the foot position heuristic")
92 .add_property(
93 "T_gait",
94 bp::make_function(&ActionModelQuadrupedTime::get_T_gait,
95 bp::return_value_policy<bp::return_by_value>()),
96 bp::make_function(&ActionModelQuadrupedTime::set_T_gait),
97 "Gait period, used to compute the symmetry term")
98 .add_property(
99 "dt_ref",
100 bp::make_function(&ActionModelQuadrupedTime::get_dt_ref,
101 bp::return_value_policy<bp::return_by_value>()),
102 bp::make_function(&ActionModelQuadrupedTime::set_dt_ref),
103 "To fix the integration time using the cost weight*||u-dt_ref||^2")
104 .add_property(
105 "dt_min",
106 bp::make_function(&ActionModelQuadrupedTime::get_dt_min,
107 bp::return_value_policy<bp::return_by_value>()),
108 bp::make_function(&ActionModelQuadrupedTime::set_dt_min),
109 "Lower bound for integration time")
110 .add_property(
111 "dt_max",
112 bp::make_function(&ActionModelQuadrupedTime::get_dt_max,
113 bp::return_value_policy<bp::return_by_value>()),
114 bp::make_function(&ActionModelQuadrupedTime::set_dt_max),
115 "Upper bound for integration time")
116 .add_property(
117 "dt_weight_cmd",
118 bp::make_function(&ActionModelQuadrupedTime::get_dt_weight_cmd,
119 bp::return_value_policy<bp::return_by_value>()),
120 bp::make_function(&ActionModelQuadrupedTime::set_dt_weight_cmd),
121 "To fix the integration time using the cost "
122 "dt_weight_cmd*||u-dt_ref||^2")
123 .add_property(
124 "dt_weight_bound_cmd",
125 bp::make_function(&ActionModelQuadrupedTime::get_dt_bound_weight_cmd,
126 bp::return_value_policy<bp::return_by_value>()),
127 bp::make_function(&ActionModelQuadrupedTime::set_dt_bound_weight_cmd),
128 "Penalisation weight for upper/lower bound of the integration time")
129 .add_property("Cost",
130 bp::make_function(&ActionModelQuadrupedTime::get_cost,
131 bp::return_internal_reference<>()),
132 "Access to the cost, Array ");
133
134 bp::register_ptr_to_python<boost::shared_ptr<ActionDataQuadrupedTime> >();
135
136 bp::class_<ActionDataQuadrupedTime, bp::bases<ActionDataAbstract> >(
137 "ActionDataQuadrupedTime",
138 "Action data for the non linear quadruped system.\n\n"
139 "The quadruped data, apart of common one, contains the cost residuals "
140 "used\n"
141 "for the computation of calc and calcDiff.",
142 bp::init<ActionModelQuadrupedTime*>(
143 bp::args("self", "model"),
144 "Create quadruped data.\n\n"
145 ":param model: quadruped action model"));
146 }
147
148 } // namespace python
149 } // namespace quadruped_walkgen
150