1 | /// @date created 2010/03/26 - 14:30
|
---|
2 | /// @author Gerald Dherbomez
|
---|
3 | /// @copyright Heudiasyc UMR UTC/CNRS 6599
|
---|
4 | /// @version $Id: $
|
---|
5 |
|
---|
6 | #ifndef VELODYNECOMPONENT_H
|
---|
7 | #define VELODYNECOMPONENT_H
|
---|
8 |
|
---|
9 | #include <qhostaddress.h>
|
---|
10 | #include <qthread.h>
|
---|
11 |
|
---|
12 | #include "Pacpus/kernel/ComponentBase.h"
|
---|
13 | #include "Pacpus/kernel/DbiteFile.h"
|
---|
14 | #include "Pacpus/kernel/road_time.h"
|
---|
15 | #include "Pacpus/PacpusTools/ShMem.h"
|
---|
16 | #include "structure_velodyne.h"
|
---|
17 |
|
---|
18 | // TODO !
|
---|
19 | // faire une classe VelodyneDecoding qui s'occupera de traiter les données en provenance du slot readPendingDatagrams
|
---|
20 | // en effet, la classe VelodyneComponent vit dans le thread GUI alors que le socket udp vit dans le thread de VelodyneComponent
|
---|
21 | // du coup la connexion signal/slot n'est pas directe et mise en file d'attente. Il semble qu'il y ait ensuite un accès concurrent
|
---|
22 | // quelque part qui fait planter le programme.
|
---|
23 | // pas de plantage en mode monothread !
|
---|
24 | // cf. discussion http://lists.trolltech.com/qt-interest/2007-01/msg00757.html qui donne des infos et détails du même type
|
---|
25 | // rem : la classe VelodyneDecoding devra être instancier dans le run() de VelodyneComponent pour que la connexion
|
---|
26 | // se fassent entre des objets ayant le même contexte de thread !
|
---|
27 |
|
---|
28 | // Export macro for AlascaXT DLL for Windows only
|
---|
29 | #ifdef WIN32
|
---|
30 | # ifdef VELODYNEHDL64S2_EXPORTS
|
---|
31 | // make DLL
|
---|
32 | # define VELODYNEHDL64S2_API __declspec(dllexport)
|
---|
33 | # else
|
---|
34 | // use DLL
|
---|
35 | # define VELODYNEHDL64S2_API __declspec(dllimport)
|
---|
36 | # endif
|
---|
37 | #else
|
---|
38 | // On other platforms, simply ignore this
|
---|
39 | # define VELODYNEHDL64S2_API
|
---|
40 | #endif
|
---|
41 |
|
---|
42 | class QUdpSocket;
|
---|
43 |
|
---|
44 | namespace pacpus {
|
---|
45 |
|
---|
46 | class VELODYNEHDL64S2_API VelodyneComponent
|
---|
47 | : public QThread
|
---|
48 | , public ComponentBase
|
---|
49 | {
|
---|
50 | Q_OBJECT
|
---|
51 |
|
---|
52 | public:
|
---|
53 | VelodyneComponent(QString name);
|
---|
54 | ~VelodyneComponent();
|
---|
55 |
|
---|
56 | /// to stop the processing thread
|
---|
57 | virtual void stopActivity();
|
---|
58 | /// to start the processing thread
|
---|
59 | virtual void startActivity();
|
---|
60 | virtual ComponentBase::COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config);
|
---|
61 |
|
---|
62 | public Q_SLOTS:
|
---|
63 | void readPendingDatagrams();
|
---|
64 |
|
---|
65 | protected:
|
---|
66 | void initialize();
|
---|
67 | void close();
|
---|
68 | void initSocket();
|
---|
69 | void closeSocket();
|
---|
70 | void run();
|
---|
71 | void processTheDatagram(road_time_t time, QByteArray data);
|
---|
72 | void record();
|
---|
73 | void exposeData();
|
---|
74 | void switchBuffer();
|
---|
75 |
|
---|
76 | private:
|
---|
77 | QUdpSocket * mSocket;
|
---|
78 |
|
---|
79 | bool mStartOfScan, mEndOfScan;
|
---|
80 | unsigned short mBlockIndex;
|
---|
81 |
|
---|
82 | /// The Velodyne IP or hostname
|
---|
83 | QHostAddress mHost;
|
---|
84 |
|
---|
85 | /// The Velodyne port
|
---|
86 | quint16 mPort;
|
---|
87 |
|
---|
88 | struct VelodynePolarData mVelodyneDataBuffer[2];
|
---|
89 | struct VelodynePolarData * mVelodyneData; // a pointer to the current velodyneDataBuffer_
|
---|
90 | struct VelodynePolarData * mFullBuffer; // a pointer to the velodyne data which is completly filled
|
---|
91 |
|
---|
92 | int mCurrentVelodyneData;
|
---|
93 | int mPreviousAngle;
|
---|
94 | bool mRunning;
|
---|
95 |
|
---|
96 | DbiteFile mVelodyneSphericDataFile;
|
---|
97 |
|
---|
98 | ShMem * mShMem;
|
---|
99 | };
|
---|
100 |
|
---|
101 | } // namespace pacpus
|
---|
102 |
|
---|
103 | #endif // VELODYNECOMPONENT_H
|
---|