12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- #ifndef RSDRIVER_H
- #define RSDRIVER_H
- #include <thread>
- #include <iostream>
- #include <QUdpSocket>
- #include <QNetworkDatagram>
- #include <iostream>
- #include <QMutex>
- #include <QDateTime>
- #include "rawdata.h"
- #include <pcl/point_cloud.h>
- #include <pcl/point_types.h>
- #include "modulecomm.h"
- namespace lidar{
- extern char gstr_hostip[256];
- extern char gstr_port[256];
- struct {
- std::string frame_id; ///< tf frame ID
- std::string model; ///< device model name
- int npackets; ///< number of packets to collect
- double rpm; ///< device rotation rate (RPMs)
- double time_offset; ///< time in seconds added to each time stamp
- bool start_from_edge;
- } config_;
- void getPacket(int n);
- int StartLidar_rs_m1();
- void StopLidar_rs_m1();
- class rsM1_Buf
- {
- private:
- char * mstrdata;
- int mnSize; //Data SizeUse
- QMutex mMutex;
- int mIndex;
- public:
- rsM1_Buf()
- {
- mstrdata = new char[BK32_DATA_BUFSIZE];
- mIndex = 0;
- mnSize = 0;
- }
- ~rsM1_Buf()
- {
- delete mstrdata;
- }
- void WriteData(const char * strdata,const int nSize)
- {
- mMutex.lock();
- memcpy(mstrdata,strdata,nSize);
- mnSize = nSize;
- mIndex++;
- mMutex.unlock();
- }
- int ReadData(char * strdata,const int nRead,int * pnIndex)
- {
- int nRtn = 0;
- if(mnSize <= 0)return 0;
- mMutex.lock();
- nRtn = mnSize;
- if(nRtn >nRead)
- {
- nRtn = nRead;
- std::cout<<"lidar_rsM1 rsM1_Buf ReadData data nRead = "<<nRead<<" is small"<<std::endl;
- }
- memcpy(strdata,mstrdata,nRtn);
- mnSize = 0;
- if(pnIndex != 0)*pnIndex = mIndex;
- mMutex.unlock();
- return nRtn;
- }
- };
- }
- #endif // RSDRIVER_H
|