#define HOKUYO_INITIAL_MEASUREMENT 44
#define HOKUYO_FINAL_MEASUREMENT 725
-#define HOKUYO_INDEX_TO_RAD(x) (-113.0+(x)*360.0/HOKUYO_SPLIT_DIVISION)
-#define HOKUYO_CLUSTER_TO_RAD(x) (HOKUYO_CLUSTER_TO_DEG(x)/180.0*M_PI)
+#define HOKUYO_INDEX_TO_DEG(x) (-113.0+(x)*360.0/HOKUYO_SPLIT_DIVISION)
+#define HOKUYO_INDEX_TO_RAD(x) (HOKUYO_INDEX_TO_DEG(x)/180.0*M_PI)
#endif //HOKUYO_H
playgroundScene->addItem(trailRefPos);
playgroundScene->addItem(trailPosIndepOdo);
playgroundScene->addItem(trailOdoPos);
+
+ hokuyoScan = new HokuyoScan();
+ hokuyoScan->setZValue(10);
+ playgroundScene->addItem(hokuyoScan);
+
}
/**********************************************************************
case QEVENT(QEV_MOTION_STATUS):
emit motionStatusReceivedSignal();
break;
+ case QEVENT(QEV_HOKUYO_SCAN):
+ hokuyoScan->newScan(&orte.hokuyo_scan);
+ break;
case QEVENT(QEV_REFERENCE_POSITION):
emit actualPositionReceivedSignal();
break;
orte.est_pos_indep_odo.y, orte.est_pos_indep_odo.phi);
trailPosIndepOdo->addPoint(QPointF(orte.est_pos_indep_odo.x,
orte.est_pos_indep_odo.y));
+
+// hokuyoScan->setPosition(orte.est_pos_indep_odo.x,
+// orte.est_pos_indep_odo.y,
+// orte.est_pos_indep_odo.phi);
break;
case QEVENT(QEV_ESTIMATED_POSITION_ODO):
robotEstPosOdo->moveRobot(orte.est_pos_odo.x,
generic_rcv_cb, new OrteCallbackInfo(this, QEV_ESTIMATED_POSITION_ODO));
robottype_subscriber_est_pos_indep_odo_create(&orte,
generic_rcv_cb, new OrteCallbackInfo(this, QEV_ESTIMATED_POSITION_INDEP_ODO));
+ robottype_subscriber_hokuyo_scan_create(&orte,
+ generic_rcv_cb, new OrteCallbackInfo(this, QEV_HOKUYO_SCAN));
robottype_subscriber_fsm_main_create(&orte,
rcv_fsm_main_cb, this);
robottype_subscriber_fsm_motion_create(&orte,
#include "Robot.h"
#include <roboorte_robottype.h>
#include "trail.h"
+#include "hokuyoscan.h"
class QHBoxLayout;
class QVBoxLayout;
Trail *trailPosIndepOdo;
Trail *trailOdoPos;
+ HokuyoScan *hokuyoScan;
+
/* keypad */
double leftMotorValue;
double rightMotorValue;
--- /dev/null
+#include "hokuyoscan.h"
+#include <QPointF>
+#include <hokuyo.h>
+#include "PlaygroundScene.h"
+#include <robodim.h>
+#include <iostream>
+
+HokuyoScan::HokuyoScan() : QGraphicsItem()
+{
+ memset(&data, 0, sizeof(data));
+}
+
+HokuyoScan::~HokuyoScan()
+{
+}
+
+QRectF HokuyoScan::boundingRect() const
+{
+ QPointF tl, br;
+ tl = PlaygroundScene::world2scene(QPointF(-3, -3));
+ br = PlaygroundScene::world2scene(QPointF(+3, +3));
+ return QRectF(tl, br);
+}
+
+void HokuyoScan::paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget)
+{
+ int d;
+ QPointF points[HOKUYO_ARRAY_SIZE + 1];
+ unsigned point_num = 0;
+ QColor color;
+
+ painter->setPen(QPen(Qt::blue));
+ color = QColor(Qt::red);
+ color.setAlpha(50);
+ painter->setBrush(QBrush(color));
+
+ for (unsigned i=0; i < HOKUYO_ARRAY_SIZE; i++) {
+ d = data.data[i];
+ if (d > 5600)
+ d = 5600;
+ if (d > 19) {
+ float x, y;
+
+ if (point_num == 0) {
+ points[0] = QPointF(0, 0);
+ point_num++;
+ }
+
+ x = d * cos(HOKUYO_INDEX_TO_RAD(i));
+ y = d * sin(HOKUYO_INDEX_TO_RAD(i));
+
+ points[point_num] = QPointF(x, y);
+ point_num++;
+ } else {
+ painter->drawPolygon(points, point_num);
+ point_num = 0;
+ }
+ }
+ painter->drawPolygon(points, point_num);
+}
+
+void HokuyoScan::setPosition(double x, double y, double phi)
+{
+ QPointF pos(x, y);
+
+ pos = PlaygroundScene::world2scene(pos);
+
+ setPos(pos);
+ setTransform(QTransform().rotateRadians(phi).translate(HOKUYO_CENTER_OFFSET_MM, 0));
+}
+
+void HokuyoScan::newScan(struct hokuyo_scan_type *scan)
+{
+ data = *scan;
+ update(boundingRect());
+}
--- /dev/null
+#ifndef HOKUYOSCAN_H
+#define HOKUYOSCAN_H
+
+#include <robottype.h>
+#include <QRectF>
+#include <QPainter>
+#include <QStyleOptionGraphicsItem>
+#include <QWidget>
+#include <QGraphicsItem>
+
+class HokuyoScan : public QGraphicsItem
+{
+public:
+ struct hokuyo_scan_type data;
+ HokuyoScan();
+ QRectF boundingRect() const;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+ void setPosition(double x, double y, double phi);
+ void newScan(struct hokuyo_scan_type *scan);
+
+ ~HokuyoScan();
+};
+
+#endif // HOKUYOSCAN_H
MiscGui.cpp \
robomon_orte.cpp \
playgroundview.cpp \
- trail.cpp
+ trail.cpp \
+ hokuyoscan.cpp
TEMPLATE = app
CONFIG += warn_on \
MiscGui.h \
robomon_orte.h \
playgroundview.h \
- trail.h
+ trail.h \
+ hokuyoscan.h
LIBS += -lm -lpthread -lmcl -llaser-nav -lrobodim -lrobomath -lroboorte \
-lrobottype -lorte -lsharp -lmap -lactlib
QEV_FSM_MAIN,
QEV_FSM_ACT,
QEV_FSM_MOTION,
+ QEV_HOKUYO_SCAN,
};
class OrteCallbackInfo {