1111#include < iostream>
1212#include < ctime>
1313#include < limits>
14+ #include < cmath>
15+ #include < memory>
16+ #include < random>
17+
18+ #include " ortools/linear_solver/linear_solver.h"
1419
1520#include " consts.hpp"
16- #include " diff_drive .hpp"
21+ #include " dynamics .hpp"
1722#include " geometry.hpp"
23+ #include " orca_lines.hpp"
1824
1925namespace mppica {
2026 using std::cout;
@@ -38,16 +44,9 @@ namespace mppica {
3844 double ma_dist_weight = 1000.0 ;
3945 double ma_collision_value = 10000.0 ;
4046 double ma_dist_threshold = 2.0 ;
41-
42- size_t max_safe_distr_step; // TODO
43- size_t max_bvc_cost_step; // TODO
44- double bvc_weight; // TODO
45- double bvc_w_base; // TODO
46- double bvc_w_mean; // TODO
47- double bvc_w_std; // TODO
48-
49- bool importance_sampl_en; // TODO importance sampling
50- double alpha; // TODO sampling from zero alpha % of batches
47+ int max_safe_distr_step = 0 ;
48+ bool car_like_dyn = false ;
49+ double alpha; // TODO: Sampling with initial mean value in alpha% of batches
5150 };
5251
5352 struct AgentParams {
@@ -60,15 +59,13 @@ namespace mppica {
6059 double dd_w_min = -2.0 ;
6160 };
6261
63- // xt::xtensor<double, 2> control_limits;
64-
6562
6663 class Controller {
6764 public:
6865 Controller ();
6966
7067 auto nextStep (const xt::xtensor<double , 1 > &curr_state, const xt::xtensor<double , 2 > &neighbors_states,
71- const xt::xtensor<double , 1 > &goal_state) -> xt::xtensor<double, 1>;
68+ const xt::xtensor<double , 1 > &goal_state) -> std::tuple< xt::xtensor<double, 1>, xt::xtensor<double, 3> >;
7269
7370 void setAgentParams (AgentParams ag_params);
7471
@@ -118,18 +115,31 @@ namespace mppica {
118115
119116 void multiAgentCost (size_t batch, size_t time_step, const xt::xtensor<double , 1 > &goal_state);
120117
118+ void computeLinearConstraintsForState (const xt::xtensor<double , 1 > &state,
119+ const xt::xtensor<double , 2 > &neighbors_states);
120+
121+ void resampleInitialWithConstraints ();
122+
123+
124+ std::tuple<bool , double , double > computeNewDistr (const xt::xtensor<double , 1 > &state, const xt::xtensor<double , 1 > &control);
125+
126+ std::tuple<xt::xtensor<double , 1 >, xt::xtensor<double , 1 >> translateConstraintsToControlBounds (const xt::xtensor<double , 1 > &state);
121127
122128 bool computationShouldStop (); // TODO
123129 void updateStopComputationConditions (); // TODO
124130 void computeMainTrajectory (); // TODO
125131
126132
133+ size_t step; // For debug purpuses
134+ size_t controller_id; // For debug purpuses
135+
127136 bool ma_cost_en;
128137 size_t max_neighbors_num;
129138 size_t neighbors_num;
130139 double ma_dist_weight;
131140 double ma_collision_value;
132141 double ma_dist_threshold;
142+ int max_safe_distr_step;
133143
134144 size_t batch_size;
135145 size_t time_steps;
@@ -148,17 +158,26 @@ namespace mppica {
148158 xt::xtensor<double , 2 > control_sequence;
149159 xt::xtensor<double , 3 > generated_trajectories;
150160 xt::xtensor<double , 1 > traj_costs;
151-
152161 xt::xtensor<double , 3 > neighbors_traj;
162+ xt::xtensor<double , 2 > linear_constraints;
163+ std::vector<ORCALine> orca_lines;
164+ bool orca_complete = true ;
165+
166+
153167
154168 double common_run_cost_weight;
155169 double common_terminal_cost_weight;
156170
157171 double agent_size;
158172 double vis_radius;
173+ double rad_eps;
159174
175+ bool use_car_like_dyn;
160176
161177 DiffDrive dyn_model; // TODO Generalize for other models
178+ CarLike car_like_dyn;
179+
180+
162181 };
163182
164183}
0 commit comments