GCC Code Coverage Report


Directory: ./
File: python/quadruped_walkgen/quadruped_nl.cpp
Date: 2024-12-02 00:24:10
Exec Total Coverage
Lines: 0 74 0.0%
Branches: 0 112 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 exposeActionQuadrupedNonLinear() {
9 ✗ bp::class_<ActionModelQuadrupedNonLinear, bp::bases<ActionModelAbstract>>(
10 "ActionModelQuadrupedNonLinear",
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<Eigen::Matrix<double, 3, 1>>(
22 ✗ bp::args("self", "offset_CoM"),
23 "Initialize the quadruped action model."))
24 ✗ .def("calc", &ActionModelQuadrupedNonLinear::calc,
25 ✗ bp::args("self", "data", "x", "u"),
26 "Compute the next state and cost value.\n\n"
27 "It describes the time-discrete evolution of the quadruped system.\n"
28 "Additionally it computes the cost value associated to this "
29 "discrete\n"
30 "state and control pair.\n"
31 ":param data: action data\n"
32 ":param x: time-discrete state vector\n"
33 ":param u: time-discrete control input")
34 .def<void (ActionModelQuadrupedNonLinear::*)(
35 const boost::shared_ptr<ActionDataAbstract>&,
36 ✗ const Eigen::Ref<const Eigen::VectorXd>&)>(
37 ✗ "calc", &ActionModelAbstract::calc, bp::args("self", "data", "x"))
38 ✗ .def("calcDiff", &ActionModelQuadrupedNonLinear::calcDiff,
39 ✗ bp::args("self", "data", "x", "u"),
40 "Compute the derivatives of the quadruped dynamics and cost "
41 "functions.\n\n"
42 "It computes the partial derivatives of the quadruped system and "
43 "the\n"
44 "cost function. It assumes that calc has been run first.\n"
45 "This function builds a quadratic approximation of the\n"
46 "action model (i.e. dynamical system and cost function).\n"
47 ":param data: action data\n"
48 ":param x: time-discrete state vector\n"
49 ":param u: time-discrete control input\n")
50 .def<void (ActionModelQuadrupedNonLinear::*)(
51 const boost::shared_ptr<ActionDataAbstract>&,
52 ✗ const Eigen::Ref<const Eigen::VectorXd>&)>(
53 "calcDiff", &ActionModelAbstract::calcDiff,
54 ✗ bp::args("self", "data", "x"))
55 ✗ .def("createData", &ActionModelQuadrupedNonLinear::createData,
56 ✗ bp::args("self"), "Create the quadruped action data.")
57 ✗ .def("updateModel", &ActionModelQuadrupedNonLinear::update_model,
58 ✗ bp::args("self", "l_feet", "xref", "S"),
59 "Update the quadruped model depending on the position of the foot "
60 "in the local frame\n\n"
61 ":param l_feet : 3x4, Matrix representing the position of the foot "
62 "in the local frame \n "
63 " Each colum represents the position of one foot : "
64 "x,y,z"
65 ":param xref : 12x1, Vector representing the reference state."
66 ":param S : 4x1, Vector representing the foot in contact with the "
67 "ground."
68 " S = [1 0 0 1] --> Foot 1 and 4 in contact.")
69 ✗ .add_property(
70 "forceWeights",
71 ✗ bp::make_function(&ActionModelQuadrupedNonLinear::get_force_weights,
72 ✗ bp::return_internal_reference<>()),
73 ✗ bp::make_function(&ActionModelQuadrupedNonLinear::set_force_weights),
74 "Weights on the control input : ground reaction forces")
75 ✗ .add_property(
76 "stateWeights",
77 ✗ bp::make_function(&ActionModelQuadrupedNonLinear::get_state_weights,
78 ✗ bp::return_internal_reference<>()),
79 ✗ bp::make_function(&ActionModelQuadrupedNonLinear::set_state_weights),
80 "Weights on the state vector")
81 ✗ .add_property(
82 "frictionWeights",
83 ✗ bp::make_function(&ActionModelQuadrupedNonLinear::get_friction_weight,
84 ✗ bp::return_value_policy<bp::return_by_value>()),
85 ✗ bp::make_function(
86 &ActionModelQuadrupedNonLinear::set_friction_weight),
87 "Weight on friction cone term")
88 ✗ .add_property(
89 "mu",
90 ✗ bp::make_function(&ActionModelQuadrupedNonLinear::get_mu,
91 ✗ bp::return_value_policy<bp::return_by_value>()),
92 ✗ bp::make_function(&ActionModelQuadrupedNonLinear::set_mu),
93 "Friction coefficient")
94 ✗ .add_property(
95 "mass",
96 ✗ bp::make_function(&ActionModelQuadrupedNonLinear::get_mass,
97 ✗ bp::return_value_policy<bp::return_by_value>()),
98 ✗ bp::make_function(&ActionModelQuadrupedNonLinear::set_mass),
99 "Mass \n Warning : The model needs to be updated")
100 ✗ .add_property(
101 "shoulder_hlim",
102 ✗ bp::make_function(&ActionModelQuadrupedNonLinear::get_shoulder_hlim,
103 ✗ bp::return_value_policy<bp::return_by_value>()),
104 ✗ bp::make_function(&ActionModelQuadrupedNonLinear::set_shoulder_hlim),
105 "Shoulder height limit ")
106 ✗ .add_property(
107 "shoulderWeights",
108 ✗ bp::make_function(&ActionModelQuadrupedNonLinear::get_shoulder_weight,
109 ✗ bp::return_value_policy<bp::return_by_value>()),
110 ✗ bp::make_function(
111 &ActionModelQuadrupedNonLinear::set_shoulder_weight),
112 "shoulder Weight term (scalar) ")
113 ✗ .add_property(
114 "dt",
115 ✗ bp::make_function(&ActionModelQuadrupedNonLinear::get_dt,
116 ✗ bp::return_value_policy<bp::return_by_value>()),
117 ✗ bp::make_function(&ActionModelQuadrupedNonLinear::set_dt),
118 "Minimum normal force allowed for feet in contact with the ground \n "
119 "Warning : The model needs to be "
120 "updated")
121 ✗ .add_property(
122 "min_fz",
123 ✗ bp::make_function(&ActionModelQuadrupedNonLinear::get_min_fz_contact,
124 ✗ bp::return_value_policy<bp::return_by_value>()),
125 ✗ bp::make_function(&ActionModelQuadrupedNonLinear::set_min_fz_contact),
126 "dt \n Warning : The model needs to be updated")
127 ✗ .add_property(
128 "max_fz",
129 ✗ bp::make_function(&ActionModelQuadrupedNonLinear::get_max_fz_contact,
130 ✗ bp::return_value_policy<bp::return_by_value>()),
131 ✗ bp::make_function(&ActionModelQuadrupedNonLinear::set_max_fz_contact),
132 "dt \n Warning : The model needs to be updated")
133 ✗ .add_property(
134 "gI",
135 ✗ bp::make_function(&ActionModelQuadrupedNonLinear::get_gI,
136 ✗ bp::return_value_policy<bp::return_by_value>()),
137 ✗ bp::make_function(&ActionModelQuadrupedNonLinear::set_gI),
138 "Inertia matrix of the robot in body frame (found in urdf) \n "
139 "Warning : The model needs to be updated")
140 ✗ .add_property(
141 "relative_forces",
142 ✗ bp::make_function(&ActionModelQuadrupedNonLinear::get_relative_forces,
143 ✗ bp::return_value_policy<bp::return_by_value>()),
144 ✗ bp::make_function(
145 &ActionModelQuadrupedNonLinear::set_relative_forces),
146 "relative norm ")
147 ✗ .add_property("A",
148 ✗ bp::make_function(&ActionModelQuadrupedNonLinear::get_A,
149 ✗ bp::return_internal_reference<>()),
150 "get A matrix")
151 ✗ .add_property("B",
152 ✗ bp::make_function(&ActionModelQuadrupedNonLinear::get_B,
153 ✗ bp::return_internal_reference<>()),
154 "get B matrix");
155
156 ✗ bp::register_ptr_to_python<boost::shared_ptr<ActionDataQuadrupedNonLinear>>();
157
158 ✗ bp::class_<ActionDataQuadrupedNonLinear, bp::bases<ActionDataAbstract>>(
159 "ActionDataQuadrupedNonLinear",
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<ActionModelQuadrupedNonLinear*>(
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