Skip to content

Commit

Permalink
fixed to get real-bots working
Browse files Browse the repository at this point in the history
  • Loading branch information
apoorvumang committed Sep 8, 2014
1 parent abbf9da commit 1d432d0
Show file tree
Hide file tree
Showing 15 changed files with 374 additions and 344 deletions.
3 changes: 2 additions & 1 deletion epuck/algoworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,7 @@ double AlgoWorker::pointToAngle(int n)
void AlgoWorker::onTimeout()
{
bool isBSAvailable = false;
return;
bsMutex->lock();
if(bs)
{
Expand Down Expand Up @@ -867,7 +868,7 @@ void AlgoWorker::onTimeout()
}
// qDebug() << "Y222OOOOOOOOOOO";
// qDebug() << avail3;
if(allBotVisible == NUMBOTS && isBSAvailable && isRunning)
if(allBotVisible == NUMBOTS && isBSAvailable && isRunning && 0)
{
// qDebug() << "YOOOOOOOOOOO\n";

Expand Down
1 change: 1 addition & 0 deletions epuck/camcapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ CamError CamCapture::init(int nCamera)

#ifdef CAMCAPTURE_DEBUG
showSeg = cvCreateImage(cvSize(width_var, height_var), 8, 3);

#endif

// width_var = rgbimg->width;
Expand Down
2 changes: 1 addition & 1 deletion epuck/camcapture.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <opencv2/opencv.hpp>
#include "imgproc.h"

// #define CAMCAPTURE_DEBUG
//#define CAMCAPTURE_DEBUG
/*
HOW TO USE THIS CLASS
1. Make object of class.
Expand Down
5 changes: 5 additions & 0 deletions epuck/cameraworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ void CameraWorker::onTimeout()
cvCircle(cc->rgbimg, cvPoint(circle.centre.x, circle.centre.y), circle.radius, cvScalar(0,0,255), 3);
}
// qDebug() << "Bot state:" << fd->bot.x<< fd->bot.y<< fd->bot.angle;
#ifdef CAMCAPTURE_DEBUG
frame = cc->showSeg;
#endif
#ifndef CAMCAPTURE_DEBUG
frame = cc->rgbimg;
#endif
cvCvtColor(frame, frame,CV_BGR2RGB);
QImage qimg((uchar*)frame->imageData, frame->width, frame->height, frame->widthStep, QImage::Format_RGB888);
myMutex->lock();
Expand Down
2 changes: 1 addition & 1 deletion epuck/commondefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

//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 SIMULATION 1
//#define SIMULATION 1
//plz to store angle in radians
struct Bot
{
Expand Down
Binary file modified epuck/epuck
Binary file not shown.
2 changes: 1 addition & 1 deletion epuck/epuck.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.0.1, 2014-09-01T23:35:22. -->
<!-- Written by QtCreator 3.0.1, 2014-09-08T06:15:21. -->
<qtcreator>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
Expand Down
6 changes: 5 additions & 1 deletion epuck/featuredetection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ int FeatureDetection::getRobotIDByColour(BlobColour largeColour, BlobColour smal
void FeatureDetection::updateBeliefState(CamCapture &cam)
{
getBlobs(cam);

//need to see configuration. right now assuming
//5 bots with colors red, orange, purple, green and pink
// qDebug() << blobs_cyan.size();
Expand Down Expand Up @@ -280,7 +281,7 @@ void FeatureDetection::updateBeliefState(CamCapture &cam)
blob.colour = bc;
blob.x = it->second->centroid.x;
blob.y = it->second->centroid.y;
if(it->second->area > 350) //if more than 350, it is a large blob, otherwise small blob
if(it->second->area > 250) //if more than 350, it is a large blob, otherwise small blob
{
largeBlobs.push_back(blob);
}
Expand All @@ -292,6 +293,7 @@ void FeatureDetection::updateBeliefState(CamCapture &cam)

}


for(int i = 0; i < NUMBOTS; ++i)
{
bs.bot[i].isVisible = false;
Expand All @@ -303,6 +305,8 @@ void FeatureDetection::updateBeliefState(CamCapture &cam)
customBlob s = getClosest(it->second->centroid, smallBlobs);

int id = getRobotIDByColour(l.colour, s.colour);
if(id >= NUMBOTS)
continue;
bs.bot[id].isVisible = true;
bs.bot[id].x = it->second->centroid.x;
bs.bot[id].y = it->second->centroid.y;
Expand Down
2 changes: 1 addition & 1 deletion epuck/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ MainWindow::MainWindow(QWidget *parent) :

connect(this, SIGNAL(stopAlgo()), aw, SLOT(onStopAlgo()));

algoThread->start(QThread::TimeCriticalPriority);
// algoThread->start(QThread::TimeCriticalPriority);


connect(aw, SIGNAL(gotLine(int, int, int, int)), cw, SLOT(onGotLine(int, int, int, int)));
Expand Down
Binary file modified trial1/1
Binary file not shown.
2 changes: 1 addition & 1 deletion trial1/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void MainWindow::IplImage2QImage(IplImage *iplImg, QImage *image)
void MainWindow::asd()
{
cam = new CamCapture(false);//, "../pic-2.jpg");
cam->init(0);
cam->init(1);

isCameraOn = 1;

Expand Down
Loading

0 comments on commit 1d432d0

Please sign in to comment.