Tetrapod Project
miqp_waypoint.h
Go to the documentation of this file.
1 #ifndef miqp_waypoint_h
2 #define miqp_waypoint_h
3 
5 
6 #include "drake/solvers/mathematical_program.h"
7 
8 #include "drake/solvers/osqp_solver.h"
9 
10 #include "drake/solvers/branch_and_bound.h"
11 
12 #include "drake/common/symbolic.h"
13 
14 #include<iostream>
15 
16 #include<fstream>
17 
18 namespace miqp{
19 namespace waypoint{
20 
21 using drake::solvers::MatrixXDecisionVariable;
22 
24 
25 struct DecVars {
26  MatrixXDecisionVariable position_center;
27 
28  MatrixXDecisionVariable position_front_left;
29 
30  MatrixXDecisionVariable position_front_right;
31 
32  MatrixXDecisionVariable position_rear_left;
33 
34  MatrixXDecisionVariable position_rear_right;
35 
36  MatrixXDecisionVariable stone_front_left;
37 
38  MatrixXDecisionVariable stone_front_right;
39 
40  MatrixXDecisionVariable stone_rear_left;
41 
42  MatrixXDecisionVariable stone_rear_right;
43 
44  MatrixXDecisionVariable theta;
45 
46  MatrixXDecisionVariable bin_sin;
47 
48  MatrixXDecisionVariable bin_cos;
49 
50  MatrixXDecisionVariable lin_sin;
51 
52  MatrixXDecisionVariable lin_cos;
53 };
54 
55 struct DecVars_res {
56  Eigen::MatrixXd position_center;
57 
58  Eigen::MatrixXd position_front_left;
59 
60  Eigen::MatrixXd position_front_right;
61 
62  Eigen::MatrixXd position_rear_left;
63 
64  Eigen::MatrixXd position_rear_right;
65 
66  Eigen::MatrixXd stone_front_left;
67 
68  Eigen::MatrixXd stone_front_right;
69 
70  Eigen::MatrixXd stone_rear_left;
71 
72  Eigen::MatrixXd stone_rear_right;
73 
74  Eigen::MatrixXd theta;
75 
76  Eigen::MatrixXd bin_sin;
77 
78  Eigen::MatrixXd bin_cos;
79 
80  Eigen::MatrixXd lin_sin;
81 
82  Eigen::MatrixXd lin_cos;
83 
84  double cost;
85 };
86 
87 DecVars add_decision_variables(drake::solvers::MathematicalProgram &prog, Terrain &terrain, int n_points);
88 
89 void set_initial_and_goal_position(drake::solvers::MathematicalProgram &prog, Eigen::Vector2d &initial_center, Eigen::Vector2d &goal_center, DecVars &decision_variables);
90 
91 void relative_position_limits(drake::solvers::MathematicalProgram &prog, int n_points, double wp_dist, DecVars &decision_variables);
92 
93 void geometry_limits(drake::solvers::MathematicalProgram &prog, int n_points, double length_legs, double bbox_len, DecVars &decision_variables);
94 
95 void theta_limits(drake::solvers::MathematicalProgram &prog, int n_points, DecVars &decision_variables);
96 
97 void one_stone_per_foot(drake::solvers::MathematicalProgram &prog, int n_points, DecVars &decision_variables);
98 
99 void writeMatToFile(Eigen::MatrixXd &mat, std::string filename);
100 
101 void writeDecVarsToFile(DecVars_res &decision_variables, std::string base_name);
102 
103 Eigen::Vector4d get_big_M(Terrain terrain);
104 
105 void foot_in_stepping_stone(drake::solvers::MathematicalProgram &prog, Terrain &terrain, int n_points, DecVars &decision_variables);
106 
107 void minimize_step_length(drake::solvers::MathematicalProgram &prog, int n_points, DecVars &decision_variables);
108 
109 void minimize_theta_change(drake::solvers::MathematicalProgram &prog, int n_points, DecVars &decision_variables);
110 }
111 }
112 
113 #endif
DecVars add_decision_variables(drake::solvers::MathematicalProgram &prog, Terrain &terrain, int n_points)
void set_initial_and_goal_position(drake::solvers::MathematicalProgram &prog, Eigen::Vector2d &initial_center, Eigen::Vector2d &goal_center, DecVars &decision_variables)
void one_stone_per_foot(drake::solvers::MathematicalProgram &prog, int n_points, DecVars &decision_variables)
void foot_in_stepping_stone(drake::solvers::MathematicalProgram &prog, Terrain &terrain, int n_points, DecVars &decision_variables)
void minimize_step_length(drake::solvers::MathematicalProgram &prog, int n_points, DecVars &decision_variables)
Eigen::Vector4d get_big_M(Terrain terrain)
void geometry_limits(drake::solvers::MathematicalProgram &prog, int n_points, double length_legs, double bbox_len, DecVars &decision_variables)
void relative_position_limits(drake::solvers::MathematicalProgram &prog, int n_points, double wp_dist, DecVars &decision_variables)
void writeDecVarsToFile(DecVars_res &decision_variables, std::string base_name)
void theta_limits(drake::solvers::MathematicalProgram &prog, int n_points, DecVars &decision_variables)
void minimize_theta_change(drake::solvers::MathematicalProgram &prog, int n_points, DecVars &decision_variables)
void writeMatToFile(Eigen::MatrixXd &mat, std::string filename)
Eigen::MatrixXd position_front_right
Definition: miqp_waypoint.h:60
Eigen::MatrixXd stone_front_left
Definition: miqp_waypoint.h:66
Eigen::MatrixXd position_center
Definition: miqp_waypoint.h:56
Eigen::MatrixXd position_front_left
Definition: miqp_waypoint.h:58
Eigen::MatrixXd position_rear_left
Definition: miqp_waypoint.h:62
Eigen::MatrixXd stone_rear_right
Definition: miqp_waypoint.h:72
Eigen::MatrixXd stone_rear_left
Definition: miqp_waypoint.h:70
Eigen::MatrixXd position_rear_right
Definition: miqp_waypoint.h:64
Eigen::MatrixXd stone_front_right
Definition: miqp_waypoint.h:68
MatrixXDecisionVariable stone_front_left
Definition: miqp_waypoint.h:36
MatrixXDecisionVariable bin_cos
Definition: miqp_waypoint.h:48
MatrixXDecisionVariable theta
Definition: miqp_waypoint.h:44
MatrixXDecisionVariable stone_front_right
Definition: miqp_waypoint.h:38
MatrixXDecisionVariable position_front_left
Definition: miqp_waypoint.h:28
MatrixXDecisionVariable position_front_right
Definition: miqp_waypoint.h:30
MatrixXDecisionVariable position_rear_right
Definition: miqp_waypoint.h:34
MatrixXDecisionVariable lin_cos
Definition: miqp_waypoint.h:52
MatrixXDecisionVariable stone_rear_right
Definition: miqp_waypoint.h:42
MatrixXDecisionVariable position_center
Definition: miqp_waypoint.h:26
MatrixXDecisionVariable bin_sin
Definition: miqp_waypoint.h:46
MatrixXDecisionVariable lin_sin
Definition: miqp_waypoint.h:50
MatrixXDecisionVariable stone_rear_left
Definition: miqp_waypoint.h:40
MatrixXDecisionVariable position_rear_left
Definition: miqp_waypoint.h:32