Skip to content

Commit ed4a623

Browse files
author
ClementRolinat
committed
finished path-planning-mov
1 parent 3f29157 commit ed4a623

15 files changed

+46
-13
lines changed

Diff for: collision-detect-fix

21.9 KB
Binary file not shown.

Diff for: collision-detect-fix.o

0 Bytes
Binary file not shown.

Diff for: collision-detect-mov

-436 KB
Binary file not shown.

Diff for: collision-detect-mov.o

-276 KB
Binary file not shown.

Diff for: collision-detect-waypts

-427 KB
Binary file not shown.

Diff for: collision-detect-waypts.o

-283 KB
Binary file not shown.

Diff for: makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ LIBS = $(shell pkg-config --libs ibex)
1111
ifeq ($(DEBUG), yes)
1212
CXXFLAGS := $(CXXFLAGS) -O0 -g -pg -Wall
1313
else
14-
CXXFLAGS := $(CXXFLAGS)
14+
CXXFLAGS := $(CXXFLAGS)
1515
endif
1616

1717
collision-detect-fix: collision-detect-fix.o vibes.o tools.o node.o

Diff for: node.o

1.16 KB
Binary file not shown.

Diff for: path-planning-fix

-457 KB
Binary file not shown.

Diff for: path-planning-fix.o

-398 KB
Binary file not shown.

Diff for: path-planning-mov

8.55 KB
Binary file not shown.

Diff for: path-planning-mov.cpp

+45-12
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,20 @@
55
using namespace std;
66
using namespace ibex;
77

8+
IntervalVector findClosest(vector<IntervalVector> listBoxes, IntervalVector boatSpeed){
9+
double dist = 1000000000;
10+
IntervalVector outputBox(2);
11+
for ( int i = 0; i < listBoxes.size(); i++){
12+
if (distance(boatSpeed, listBoxes[i]) < dist){
13+
dist = distance(boatSpeed, listBoxes[i]);
14+
outputBox = listBoxes[i];
15+
}
16+
}
17+
return outputBox;
18+
}
819

9-
10-
void pavingMov(IntervalVector speed, vector<SepInter*> listSep){
11-
if (width(speed) < 0.2){
20+
void pavingMov(IntervalVector speed, vector<SepInter*> listSep, vector<IntervalVector>& listBoxes){
21+
if (speed.max_diam() < 0.2){
1222
return;
1323
}
1424
IntervalVector XinEnd(2);
@@ -19,11 +29,11 @@ void pavingMov(IntervalVector speed, vector<SepInter*> listSep){
1929
vector<IntervalVector> listXin;
2030

2131

22-
vibes::drawBoxes({{speed[0].lb(), speed[0].ub(), speed[1].lb(), speed[1].ub()}}, "[cyan]");
32+
//vibes::drawBoxes({{speed[0].lb(), speed[0].ub(), speed[1].lb(), speed[1].ub()}}, "[cyan]");
33+
//sleep(1);
2334

2435
for (int i = 0; i < listSep.size(); i++){
2536
listSep[i]->SepInter::separate(Xin, Xout);
26-
//cout << "test2" << endl;
2737
listXout.push_back(Xout);
2838
Xin = speed;
2939
Xout = speed;
@@ -35,8 +45,23 @@ void pavingMov(IntervalVector speed, vector<SepInter*> listSep){
3545
XoutEnd = XoutEnd | listXout[i];
3646
}
3747

48+
IntervalVector newBox(2);
49+
50+
IntervalVector* ListComplementary;
51+
52+
int size = XoutEnd.complementary(ListComplementary);
53+
54+
for ( int i = 0; i < size; i++){
55+
newBox = ListComplementary[i]&speed;
56+
if (!newBox.is_flat()){
57+
listBoxes.push_back(newBox);
58+
vibes::drawBoxes({{newBox[0].lb(), newBox[0].ub(), newBox[1].lb(), newBox[1].ub()}}, "[cyan]");
59+
}
60+
}
3861

62+
3963
vibes::drawBoxes({{XoutEnd[0].lb(), XoutEnd[0].ub(), XoutEnd[1].lb(), XoutEnd[1].ub()}}, "[red]");
64+
//sleep(1);
4065

4166
Xin = XoutEnd;
4267
Xout = XoutEnd;
@@ -55,9 +80,10 @@ void pavingMov(IntervalVector speed, vector<SepInter*> listSep){
5580
}
5681

5782
vibes::drawBoxes({{XinEnd[0].lb(), XinEnd[0].ub(), XinEnd[1].lb(), XinEnd[1].ub()}}, "[yellow]");
83+
//sleep(1);
5884

59-
pavingMov(left(XinEnd), listSep);
60-
pavingMov(right(XinEnd), listSep);
85+
pavingMov(left(XinEnd), listSep, listBoxes);
86+
pavingMov(right(XinEnd), listSep, listBoxes);
6187
}
6288

6389

@@ -68,6 +94,9 @@ int main(int argc, char** argv) {
6894
double pos[2][2] ={{-1,1},{-1,1}};
6995
IntervalVector boatInitPos(2, pos);
7096

97+
double _boatSpeed[2][2] = {{4,4.5}, {2,2.5}};
98+
IntervalVector boatSpeed(2,_boatSpeed);
99+
71100

72101
vector<IntervalVector> obstacles;
73102
double pos1[4][2] = {{2, 2.4}, {30, 35}, {-10, -8}, {2.9, 3.5}}; // {speed, posInitx, posInity, heading}
@@ -93,10 +122,7 @@ int main(int argc, char** argv) {
93122
SepFwdBwd* pSep1;
94123
SepFwdBwd* pSep2;
95124
SepFwdBwd* pSep3;
96-
SepInter* pSep;
97-
98-
99-
125+
SepInter* pSep;
100126

101127
for ( int i = 0; i < obstacles.size(); i++){
102128
pf1 = new Function(vx, vy, (vx - obstacles[i][0]*cos(obstacles[i][3]))*T +boatInitPos[0] - obstacles[i][1]);
@@ -115,10 +141,17 @@ int main(int argc, char** argv) {
115141
double _speed[2][2] = {{-10, 10}, {-10, 10}};
116142
IntervalVector speed(2, _speed);
117143

144+
vector<IntervalVector> listBoxes;
145+
146+
pavingMov(speed, listSep, listBoxes);
147+
148+
delete pf1, pf2, pf3, pSep1, pSep2, pSep3, pSep, listSep;
118149

150+
vibes::drawBoxes({{boatSpeed[0].lb(), boatSpeed[0].ub(), boatSpeed[1].lb(), boatSpeed[1].ub()}}, "[red]");
119151

120-
pavingMov(speed, listSep);
152+
IntervalVector newSpeed = findClosest(listBoxes, boatSpeed);
121153

154+
vibes::drawBoxes({{newSpeed[0].lb(), newSpeed[0].ub(), newSpeed[1].lb(), newSpeed[1].ub()}}, "[green]");
122155

123156
return 0;
124157

Diff for: path-planning-mov.o

19.5 KB
Binary file not shown.

Diff for: tools.o

3.71 KB
Binary file not shown.

Diff for: vibes.o

5.69 KB
Binary file not shown.

0 commit comments

Comments
 (0)