aboutsummaryrefslogtreecommitdiffstats
path: root/problem.hpp
diff options
context:
space:
mode:
authorAlex Auvolat <alex.auvolat@ens.fr>2015-02-01 14:57:56 +0100
committerAlex Auvolat <alex.auvolat@ens.fr>2015-02-01 14:57:56 +0100
commite645b307a7a32c3c3d12989ccf6d60e324392d60 (patch)
tree0951cf98cba65b5dd547845d59d4601ed6a9ec32 /problem.hpp
parent97cb291cc348acb925e99144c725869e05ff4f46 (diff)
downloadRobotique-Projet-e645b307a7a32c3c3d12989ccf6d60e324392d60.tar.gz
Robotique-Projet-e645b307a7a32c3c3d12989ccf6d60e324392d60.zip
Begin work on UI
Diffstat (limited to 'problem.hpp')
-rw-r--r--problem.hpp50
1 files changed, 41 insertions, 9 deletions
diff --git a/problem.hpp b/problem.hpp
index 7097e0c..a41e47a 100644
--- a/problem.hpp
+++ b/problem.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <vector>
+#include <map>
#include "geom.hpp"
@@ -8,10 +9,14 @@ struct obstacle {
circle c;
};
-struct hilare_a { // System A
+struct hilare_a_param {
// paramètres globaux
double l;
double r_c_car, r_c_trolley;
+};
+
+struct hilare_a { // System A
+ hilare_a_param *param;
// position actuelle
double x, y, theta, phi;
@@ -19,16 +24,16 @@ struct hilare_a { // System A
vec pos() const { return vec(x, y); }
vec dir() const { return vec::from_polar(1, theta); }
- vec pos_trolley() const {
- return pos() + vec::from_polar(l, theta + phi + M_PI);
- }
vec dir_trolley() const {
- return vec::from_polar(1, theta + phi);
+ return vec::from_polar(1, theta + phi + M_PI);
+ }
+ vec pos_trolley() const {
+ return pos() + param->l * dir_trolley();
}
};
struct problem {
- std::vector<obstacle> map;
+ std::vector<obstacle> obstacles;
hilare_a begin_pos, end_pos;
};
@@ -45,10 +50,18 @@ struct hilare_a_mvt {
// - avancer/reculer sur le cercle (c'est l'angle domega)
hilare_a from, to;
- vec center;
+
+ bool is_arc; // true = circle arc ; false = straight line (phi = 0)
+
double dtheta_before; // rotation de la voiture sur elle-même avant
+
+ // CAS D'UN ARC DE CERCLE
+ vec center;
double domega; // angle parcouru sur le cercle de centre center
+ // CAS D'UN DEPLACEMENT EN LIGNE DROITE
+ double ds; // longueur par
+
double length(); // length of a movement
bool intersects(const obstacle& o) const; // intersects an obstacle ?
@@ -57,6 +70,7 @@ struct hilare_a_mvt {
struct solution {
std::vector<hilare_a_mvt> movement;
+ solution() {}
solution(const std::vector<hilare_a_mvt> &m) : movement(m) {}
// simple direct solution from A to B, takes into account no obstacles
@@ -64,9 +78,27 @@ struct solution {
// check if a solution intersects an obstacle of problem
bool intersects(const problem &p) const;
+};
+
+struct solver_internal {
+ // intermediate data for the solver
+ // represents a graph of randomly chosen positions and simple solutions between them
+ std::vector<hilare_a> pts;
+ std::map<int, std::map<int, hilare_a_mvt> > paths;
+};
+
+class solver {
+ // mutex-protected asynchronous structure
+
+ private:
+ //todo
+
+ public:
+ solver();
- // calculate a solution
- static solution make_solution(const problem &p);
+ void start(const problem &p);
+ bool finished();
+ solution get_solution();
};