From 41a05c0e805fde5f8b607a89a51dd506ebf7f0cf Mon Sep 17 00:00:00 2001 From: Martin Synek Date: Tue, 18 Jan 2011 08:33:31 +0100 Subject: [PATCH] MainWindow: add menu item (robomon): View -> Show shape detect hokuyoscan: add method drawShapeDetect robomon.pro: add library lshape_detect --- src/hokuyo/shape-detect/shape_detect.h | 2 +- src/robomon/MainWindow.cpp | 4 ++++ src/robomon/MainWindow.h | 1 + src/robomon/RobomonAtlantis.cpp | 10 ++++++++++ src/robomon/RobomonAtlantis.h | 1 + src/robomon/hokuyoscan.cpp | 21 +++++++++++++++++++++ src/robomon/hokuyoscan.h | 3 +++ src/robomon/robomon.pro | 2 +- 8 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/hokuyo/shape-detect/shape_detect.h b/src/hokuyo/shape-detect/shape_detect.h index 16a47243..70f73b4f 100644 --- a/src/hokuyo/shape-detect/shape_detect.h +++ b/src/hokuyo/shape-detect/shape_detect.h @@ -16,7 +16,7 @@ #include // gnuplot graph -#define GNUPLOT 1 +//#define GNUPLOT 0 // debug mode with connect Hokuyo #define OFFLINE 1 diff --git a/src/robomon/MainWindow.cpp b/src/robomon/MainWindow.cpp index ed0ba94f..ced8ba2f 100644 --- a/src/robomon/MainWindow.cpp +++ b/src/robomon/MainWindow.cpp @@ -52,6 +52,7 @@ void MainWindow::addRobomonAtlantisTab() connect(showMap, SIGNAL(toggled( bool )), robomonAtlantis, SLOT(showMap(bool))); connect(showTrails, SIGNAL(toggled( bool )), robomonAtlantis, SLOT(showTrails(bool))); connect(resetTrails, SIGNAL(triggered()), robomonAtlantis, SLOT(resetTrails())); + connect(showShapeDetect, SIGNAL(toggled( bool )), robomonAtlantis, SLOT(showShapeDetect(bool))); connect(useOpenGL, SIGNAL(toggled( bool )), robomonAtlantis, SLOT(useOpenGL(bool))); connect(showRobotRef, SIGNAL(toggled(bool)), robomonAtlantis->robotRefPos, SLOT(mySetVisible(bool))); @@ -134,6 +135,8 @@ void MainWindow::createActions() showTrails->setCheckable(true); showMap = new QAction("Show &map", this); showMap->setCheckable(true); + showShapeDetect = new QAction("Show s&hape detect", this); + showShapeDetect->setCheckable(true); resetTrails = new QAction("Re&set trails", this); useOpenGL = new QAction("Use &OpenGL", this); @@ -161,6 +164,7 @@ void MainWindow::createMenus() m->addAction(showMap); m->addAction(showTrails); m->addAction(resetTrails); + m->addAction(showShapeDetect); QMenu *robot = m->addMenu(tr("&Robot")); m->addAction(useOpenGL); diff --git a/src/robomon/MainWindow.h b/src/robomon/MainWindow.h index 50650669..e5260b7b 100644 --- a/src/robomon/MainWindow.h +++ b/src/robomon/MainWindow.h @@ -65,6 +65,7 @@ private: QAction *resetTrails; QAction *showTrails; QAction *showMap; + QAction *showShapeDetect; QAction *showRobotRef; QAction *showRobotEst; QAction *showRobotEstOdo; diff --git a/src/robomon/RobomonAtlantis.cpp b/src/robomon/RobomonAtlantis.cpp index b63994c5..49ddb685 100644 --- a/src/robomon/RobomonAtlantis.cpp +++ b/src/robomon/RobomonAtlantis.cpp @@ -1005,3 +1005,13 @@ void RobomonAtlantis::showTrails(bool show) trailPosIndepOdo->setVisible(show && robotEstPosIndepOdo->isVisible()); trailOdoPos->setVisible(show && robotEstPosOdo->isVisible()); } + +void RobomonAtlantis::showShapeDetect(bool show) +{ + if (show) + { + + } else { + + } +} diff --git a/src/robomon/RobomonAtlantis.h b/src/robomon/RobomonAtlantis.h index d3ac3e8b..8dc2473a 100644 --- a/src/robomon/RobomonAtlantis.h +++ b/src/robomon/RobomonAtlantis.h @@ -60,6 +60,7 @@ public slots: void showMap(bool show); void useOpenGL(bool use); void showTrails(bool show); + void showShapeDetect(bool show); void resetTrails(); private slots: /************************************************************ diff --git a/src/robomon/hokuyoscan.cpp b/src/robomon/hokuyoscan.cpp index f806cf5a..bdf5a91b 100644 --- a/src/robomon/hokuyoscan.cpp +++ b/src/robomon/hokuyoscan.cpp @@ -22,6 +22,24 @@ QRectF HokuyoScan::boundingRect() const return QRectF(tl, br); } +void HokuyoScan::drawShapeDetect(QPainter * painter) +{ + Shape_detect sd; + + std::vector input(HOKUYO_ARRAY_SIZE); + + for (unsigned i = 0; i < HOKUYO_ARRAY_SIZE; i++) + input[i] = (int) data.data[i]; + + std::vector output; + sd.shape_detect(input, output); + + painter->setPen(QPen(Qt::green)); + + for (unsigned i = 0; i < output.size(); i++) + painter->drawLine(output[i].a.x, output[i].a.y, output[i].b.x, output[i].b.y); +} + void HokuyoScan::paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) { int d; @@ -56,6 +74,9 @@ void HokuyoScan::paint(QPainter * painter, const QStyleOptionGraphicsItem * opti point_num = 0; } } + + drawShapeDetect(painter); + painter->drawPolygon(points, point_num); } diff --git a/src/robomon/hokuyoscan.h b/src/robomon/hokuyoscan.h index 49128392..372e0fc5 100644 --- a/src/robomon/hokuyoscan.h +++ b/src/robomon/hokuyoscan.h @@ -2,6 +2,7 @@ #define HOKUYOSCAN_H #include +#include #include #include #include @@ -19,6 +20,8 @@ public: void setPosition(double x, double y, double phi); void newScan(struct hokuyo_scan_type *scan); + void drawShapeDetect(QPainter * painter); + ~HokuyoScan(); }; diff --git a/src/robomon/robomon.pro b/src/robomon/robomon.pro index e43f4967..17c9b76f 100644 --- a/src/robomon/robomon.pro +++ b/src/robomon/robomon.pro @@ -36,4 +36,4 @@ HEADERS += MainWindow.h \ hokuyoscan.h LIBS += -lm -lpthread -lmcl -llaser-nav -lrobodim -lrobomath -lroboorte \ - -lrobottype -lorte -lsharp -lmap -lactlib -lcornslib + -lrobottype -lorte -lsharp -lmap -lactlib -lcornslib -lshape_detect -- 2.39.2