Skip to content

Commit

Permalink
Major commit - new algo working, ui working
Browse files Browse the repository at this point in the history
  • Loading branch information
apoorvumang committed Sep 10, 2014
1 parent ec017d4 commit 335323c
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 20 deletions.
11 changes: 8 additions & 3 deletions epuck/algoworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,8 @@ void AlgoWorker::onTimeout()

case SAVE_CURRENT_POSITION:
totDistance = 0.0;
numRounds = 0;
numActivations = 0;
for(int i = 0; i < NUMBOTS; ++i)
{
savedPosition[i] = cvPoint(localBS.bot[i].x, localBS.bot[i].y);
Expand All @@ -1098,6 +1100,8 @@ void AlgoWorker::onTimeout()
{
int numCompleted = 0;
totDistance = 0.0;
numRounds = 0;
numActivations = 0;
for(int i = 0; i < NUMBOTS; ++i)
{
if(moveToPoint(savedPosition[i], localBS.bot[i], i))
Expand Down Expand Up @@ -1143,7 +1147,7 @@ void AlgoWorker::onTimeout()
{
ls.push_back(LineSegment(x1, y1, x2, y2));
}

output.close();
for(int i = 0; i < NUMBOTS; ++i)
{
destinationPoint[i] = getDestinationVoronoi(i);
Expand Down Expand Up @@ -1196,14 +1200,15 @@ void AlgoWorker::onTimeout()
bool allOnCircle = true;
for(int i = 0; i < NUMBOTS; ++i)
{
if(fabs(getDistance(destinationPoint[i], destinationCircle.centre) - destinationCircle.radius) > 5)
if(fabs(getDistance(destinationPoint[i], destinationCircle.centre) - destinationCircle.radius) > FINAL_REACHED_THRESHOLD)
{
allOnCircle = false;
break;
}
}
if(allOnCircle == false)
{
qDebug() << "All not on circle";
currentState = MAKE_CIRCLE;
}
else
Expand Down Expand Up @@ -1386,7 +1391,7 @@ void AlgoWorker::onTimeout()
//calculate the destination points
//assume leader is destinationPoint[0]
const double stableAngle = 2.0*CV_PI/((double)NUMBOTS);
CvPoint myPoint[5];
CvPoint myPoint[NUMBOTS];
for(int i = 0; i < NUMBOTS; ++i)
{
myPoint[i] = angleToPoint(pointToAngle(destinationPoint[0]) + stableAngle*i);
Expand Down
2 changes: 1 addition & 1 deletion epuck/commondefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <opencv2/opencv.hpp>

//enum Command {FORWARD, BACKWARD, LEFT, RIGHT, UP, DOWN, STOP, SPEED1, SPEED2, SPEED3, SPEED4, F_PULSE, B_PULSE, L_PULSE, R_PULSE};
#define NUMBOTS 5
#define NUMBOTS 10
#define SIMULATION 1
//plz to store angle in radians
struct Bot
Expand Down
Binary file modified epuck/epuck
Binary file not shown.
15 changes: 10 additions & 5 deletions epuck/in.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
389 167
354 359
439 280
249 293
265 189
235 108
206 251
502 175
200 216
451 322
241 310
317 60
203 172
424 71
328 358
37 changes: 26 additions & 11 deletions epuck/out.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
-81 189 -257539 -39419.9
-81 189 340.455 253.839
280.757 359 342.265 261.146
280.757 359 -3097.68 5733.79
325.048 167 -300.055 -3356.31
325.048 167 340.455 253.839
359.788 280 342.265 261.146
359.788 280 1568.08 1580.06
340.455 253.839 341.873 255.415
342.265 261.146 341.873 255.415
341.873 255.415 1787.16 -384.091
-121.167 172 -1.46998e+06 -100046
-121.167 172 346.333 203.875
100.917 251 343.261 209.455
100.917 251 -233682 40328.1
155 108 -28550.5 -14244.8
155 108 345.931 203.466
173.771 310 343.261 209.455
173.771 310 -20618.1 12644.2
261.951 60 -3132.52 -5738.89
261.951 60 345.931 203.466
271.259 358 351.958 211.732
271.259 358 -2827.57 5974.63
369.935 71 671.451 -2861.93
369.935 71 356.367 202.975
384.232 322 351.958 211.732
384.232 322 1096.62 2756.01
343.261 209.455 349.908 206.556
345.931 203.466 346.333 203.875
346.333 203.875 349.908 206.556
349.908 206.556 352.214 207.257
351.958 211.732 352.214 207.257
393.667 175 1863.26 -927.198
393.667 175 356.367 202.975
352.214 207.257 354.4 206.139
356.367 202.975 354.4 206.139
354.4 206.139 2000.17 777.119

0 comments on commit 335323c

Please sign in to comment.