Tetrapod Project
miqp_quadruped.h
Go to the documentation of this file.
1 #ifndef miqp_quadruped_h
2 #define miqp_quadruped_h
3 
4 #include<Eigen/Core>
5 
7 
8 #include "drake/solvers/mathematical_program.h"
9 
10 #include "drake/solvers/osqp_solver.h"
11 
12 #include "drake/solvers/branch_and_bound.h"
13 
14 #include "drake/common/symbolic.h"
15 
16 #include<iostream>
17 
18 #include<fstream>
19 
20 namespace miqp{
21 namespace quadruped{
22 
23 using drake::solvers::MatrixXDecisionVariable;
24 
25 
27 
28 // Trying slightly different representation of step sequence: More compact, less unnecessary copy of states and equality constraints
29 
30 struct DecVars
31 {
32  MatrixXDecisionVariable position;
33 
34  MatrixXDecisionVariable theta;
35 
36  MatrixXDecisionVariable stone;
37 
38  //MatrixXDecisionVariable sequence_offset;
39 
40  MatrixXDecisionVariable bin_sin;
41 
42  MatrixXDecisionVariable bin_cos;
43 
44  MatrixXDecisionVariable lin_sin;
45 
46  MatrixXDecisionVariable lin_cos;
47 };
48 
50 {
51  Eigen::MatrixXd position;
52 
53  Eigen::MatrixXd theta;
54 
55  Eigen::MatrixXd stone;
56 
57  Eigen::MatrixXd sequence_offset;
58 
59  Eigen::MatrixXd bin_sin;
60 
61  Eigen::MatrixXd bin_cos;
62 
63  Eigen::MatrixXd lin_sin;
64 
65  Eigen::MatrixXd lin_cos;
66 
67  double cost;
68 
69  bool success;
70 };
71 
73 {
74  Eigen::MatrixXd position_front_left;
75 
76  Eigen::MatrixXd position_front_right;
77 
78  Eigen::MatrixXd position_rear_left;
79 
80  Eigen::MatrixXd position_rear_right;
81 
82  Eigen::MatrixXd stone_front_left;
83 
84  Eigen::MatrixXd stone_front_right;
85 
86  Eigen::MatrixXd stone_rear_left;
87 
88  Eigen::MatrixXd stone_rear_right;
89 
90  Eigen::MatrixXd position_ts;
91 
92  bool first_left;
93 
95 
96  double cost;
97 
98  bool success;
99 };
100 
101 DecVars add_decision_variables(drake::solvers::MathematicalProgram &prog, Terrain &terrain, int n_steps, int n_legs);
102 
103 void set_initial_and_goal_position(drake::solvers::MathematicalProgram &prog, int n_steps, double length_legs, Leg step_sequence[], Terrain &terrain, DecVars &decision_variables, bool enforce_goal_hard=true);
104 
105 void geometry_limits(drake::solvers::MathematicalProgram &prog, int n_steps, int n_legs, double length_legs, Leg step_sequence[], Terrain &terrain, double bbox_len, DecVars &decision_variables);
106 
107 void theta_limits(drake::solvers::MathematicalProgram &prog, int n_steps, int n_legs, DecVars &decision_variables);
108 
109 void relative_position_limits(drake::solvers::MathematicalProgram &prog, int n_steps, int n_legs, double step_span, double step_height, DecVars &decision_variables);
110 
111 void one_stone_per_foot(drake::solvers::MathematicalProgram &prog, int n_steps, DecVars &decision_variables);
112 
113 Eigen::Vector4d get_big_M(Terrain terrain);
114 
115 void foot_in_stepping_stone(drake::solvers::MathematicalProgram &prog, Terrain &terrain, int n_steps, DecVars &decision_variables);
116 
117 void minimize_step_length(drake::solvers::MathematicalProgram &prog, int n_steps, int n_legs, DecVars &decision_variables);
118 
119 void minimize_remaining_length(drake::solvers::MathematicalProgram &prog, Terrain &terrain, int n_steps, int n_legs, DecVars &decision_variables);
120 
121 Eigen::Array<Eigen::MatrixXd, Eigen::Dynamic, 1> get_uncompressed_arrays(Eigen::MatrixXd &arr, Eigen::MatrixXd &sequence_offset, int n_steps, int n_legs, Leg step_sequence[]);
122 
123 DecVars_res get_decvars_res(DecVars_res_raw &decision_variables_raw, int n_steps, int n_legs, Leg step_sequence[]);
124 
125 void writeDecVarsToFile(DecVars_res &decision_variables, std::string base_name="footstep_planner");
126 
127 void writeMatToFile(Eigen::MatrixXd &mat, std::string filename);
128 }
129 }
130 #endif
void step_sequence(drake::solvers::MathematicalProgram &prog, int n_steps, double step_span, DecVars &decision_variables)
Definition: miqp_biped.cpp:93
void theta_limits(drake::solvers::MathematicalProgram &prog, int n_steps, int n_legs, DecVars &decision_variables)
DecVars_res get_decvars_res(DecVars_res_raw &decision_variables_raw, int n_steps, int n_legs, Leg step_sequence[])
Eigen::Vector4d get_big_M(Terrain terrain)
void one_stone_per_foot(drake::solvers::MathematicalProgram &prog, int n_steps, DecVars &decision_variables)
void minimize_step_length(drake::solvers::MathematicalProgram &prog, int n_steps, int n_legs, DecVars &decision_variables)
void relative_position_limits(drake::solvers::MathematicalProgram &prog, int n_steps, int n_legs, double step_span, double step_height, DecVars &decision_variables)
void foot_in_stepping_stone(drake::solvers::MathematicalProgram &prog, Terrain &terrain, int n_steps, DecVars &decision_variables)
DecVars add_decision_variables(drake::solvers::MathematicalProgram &prog, Terrain &terrain, int n_steps, int n_legs)
Eigen::Array< Eigen::MatrixXd, Eigen::Dynamic, 1 > get_uncompressed_arrays(Eigen::MatrixXd &arr, Eigen::MatrixXd &sequence_offset, int n_steps, int n_legs, Leg step_sequence[])
void set_initial_and_goal_position(drake::solvers::MathematicalProgram &prog, int n_steps, double length_legs, Leg step_sequence[], Terrain &terrain, DecVars &decision_variables, bool enforce_goal_hard=true)
void writeMatToFile(Eigen::MatrixXd &mat, std::string filename)
void geometry_limits(drake::solvers::MathematicalProgram &prog, int n_steps, int n_legs, double length_legs, Leg step_sequence[], Terrain &terrain, double bbox_len, DecVars &decision_variables)
void writeDecVarsToFile(DecVars_res &decision_variables, std::string base_name="footstep_planner")
void minimize_remaining_length(drake::solvers::MathematicalProgram &prog, Terrain &terrain, int n_steps, int n_legs, DecVars &decision_variables)
int step_span
Definition: visualize.py:14
Eigen::MatrixXd stone_rear_right
Eigen::MatrixXd position_rear_left
Eigen::MatrixXd position_rear_right
Eigen::MatrixXd position_front_right
Eigen::MatrixXd stone_front_right
Eigen::MatrixXd stone_rear_left
Eigen::MatrixXd stone_front_left
Eigen::MatrixXd position_front_left
MatrixXDecisionVariable position
MatrixXDecisionVariable bin_cos
MatrixXDecisionVariable stone
MatrixXDecisionVariable bin_sin
MatrixXDecisionVariable lin_sin
MatrixXDecisionVariable theta
MatrixXDecisionVariable lin_cos