|
@@ -42,11 +42,13 @@ lidar_bkdriver::lidar_bkdriver() {
|
|
configDeviceParams();
|
|
configDeviceParams();
|
|
|
|
|
|
mpThreadRaw = new std::thread(&lidar_bkdriver::RecvRawThread,this);
|
|
mpThreadRaw = new std::thread(&lidar_bkdriver::RecvRawThread,this);
|
|
|
|
+ mpThreadHeartbeat = new std::thread(&lidar_bkdriver::HeartBeatThread,this);
|
|
}
|
|
}
|
|
|
|
|
|
lidar_bkdriver::~lidar_bkdriver()
|
|
lidar_bkdriver::~lidar_bkdriver()
|
|
{
|
|
{
|
|
mbRun = false;
|
|
mbRun = false;
|
|
|
|
+ mpThreadHeartbeat->join();
|
|
mpThreadRaw->join();
|
|
mpThreadRaw->join();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -169,6 +171,7 @@ int lidar_bkdriver::progSet(lidarAPi::DEB_PROGRM_S &program)
|
|
case ANGLE_SPEED_0HZ:
|
|
case ANGLE_SPEED_0HZ:
|
|
tmpData |= CMD_SCAN_DISABLE;
|
|
tmpData |= CMD_SCAN_DISABLE;
|
|
tmpData |= CMD_SCAN_SPEED_10HZ;
|
|
tmpData |= CMD_SCAN_SPEED_10HZ;
|
|
|
|
+ break;
|
|
case ANGLE_SPEED_10HZ:
|
|
case ANGLE_SPEED_10HZ:
|
|
tmpData |= CMD_SCAN_ENABLE;
|
|
tmpData |= CMD_SCAN_ENABLE;
|
|
tmpData |= CMD_SCAN_SPEED_10HZ;
|
|
tmpData |= CMD_SCAN_SPEED_10HZ;
|
|
@@ -278,7 +281,7 @@ uint32_t isCrc32(uint8_t const *pIn, uint16_t len)
|
|
int lidar_bkdriver::lidar_run(SCDEV_CMD_E me_cmd, float mt_scnspd, int mt_lsrfreq, int mt_lsrpwr)
|
|
int lidar_bkdriver::lidar_run(SCDEV_CMD_E me_cmd, float mt_scnspd, int mt_lsrfreq, int mt_lsrpwr)
|
|
{
|
|
{
|
|
LIDAR_COMMAND_S cmd;
|
|
LIDAR_COMMAND_S cmd;
|
|
- memset(&cmd.commander, 0, sizeof(LIDAR_CMDRPT_U));
|
|
|
|
|
|
+ memset((void *)&cmd.commander, 0, sizeof(LIDAR_CMDRPT_U));
|
|
cmd.commander.cmdId = eMsgProgam;
|
|
cmd.commander.cmdId = eMsgProgam;
|
|
cmd.commander.isAsk = 0;
|
|
cmd.commander.isAsk = 0;
|
|
cmd.commander.prgCtrl.cmdID = me_cmd;
|
|
cmd.commander.prgCtrl.cmdID = me_cmd;
|
|
@@ -325,9 +328,92 @@ int lidar_bkdriver::RecvRawThread()
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ mmutexrawdata.lock();
|
|
|
|
+ if(mvecterraw.size()>100)
|
|
|
|
+ {
|
|
|
|
+ std::cout<<std::chrono::system_clock::now().time_since_epoch().count()<<" raw vector full. skip one."<<std::endl;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ iv::lidarraw xraw;
|
|
|
|
+ xraw.mnrecvtime = std::chrono::system_clock::now().time_since_epoch().count();
|
|
|
|
+ xraw.mpraw_ptr = pread;
|
|
|
|
+ xraw.ndatasize = ret;
|
|
|
|
+ mvecterraw.push_back(xraw);
|
|
|
|
+ }
|
|
|
|
+ mmutexrawdata.unlock();
|
|
|
|
+ mcv.notify_all();
|
|
|
|
+
|
|
std::cout<<std::chrono::system_clock::now().time_since_epoch().count()<<" recv "<<ret<<std::endl;
|
|
std::cout<<std::chrono::system_clock::now().time_since_epoch().count()<<" recv "<<ret<<std::endl;
|
|
std::cout<<" mod: "<<ret%1248<<std::endl;
|
|
std::cout<<" mod: "<<ret%1248<<std::endl;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ return 1;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int lidar_bkdriver::HeartBeatThread()
|
|
|
|
+{
|
|
|
|
+ float temper;
|
|
|
|
+ while(mbRun)
|
|
|
|
+ {
|
|
|
|
+ if (m_heart_socket->read((unsigned char *)&m_heart, sizeof(m_heart)) == 256)
|
|
|
|
+ {
|
|
|
|
+ temper = m_heart.temperature / 100.0;
|
|
|
|
+ (void)temper;
|
|
|
|
+ // if (m_input_para.save_isf && !m_input_para.isf_path.empty())
|
|
|
|
+ // {
|
|
|
|
+ // m_heartbeat_vec.push_back(m_heart);
|
|
|
|
+ // }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ static int num = 0;
|
|
|
|
+ if (0 == num++)
|
|
|
|
+ {
|
|
|
|
+ std::cout<<"temperature = "<<temper<<"motoer speed: "<<m_heart.motorspd<<std::endl;
|
|
|
|
+ std::cout<<"DEVICE_id = "<<m_heart.device_id<<std::endl;
|
|
|
|
+ // ROS_WARN("temperature=%f", temper);
|
|
|
|
+ // ROS_INFO("DEVICE_id=%d", m_heart.device_id);
|
|
|
|
+ }
|
|
|
|
+ num %= 10;
|
|
|
|
+
|
|
|
|
+ std::this_thread::sleep_for(chrono::seconds(1));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return 1;
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int lidar_bkdriver::GetRecvData(std::shared_ptr<unsigned char> &pdata_ptr, int64_t &nRecvTime, int & ndatasize)
|
|
|
|
+{
|
|
|
|
+ int nread = 0;
|
|
|
|
+ nread = ExecGetRecvData(pdata_ptr,nRecvTime,ndatasize);
|
|
|
|
+ if(nread > 0)return nread;
|
|
|
|
+
|
|
|
|
+ std::unique_lock<std::mutex> lk(mmutexcv);
|
|
|
|
+ if(mcv.wait_for(lk,std::chrono::milliseconds(100)) == std::cv_status::timeout){
|
|
|
|
+ lk.unlock();
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ lk.unlock();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return ExecGetRecvData(pdata_ptr,nRecvTime,ndatasize);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int lidar_bkdriver::ExecGetRecvData(std::shared_ptr<unsigned char> & pdata_ptr, int64_t & nRecvTime, int & ndatasize)
|
|
|
|
+{
|
|
|
|
+ int nread = 0;
|
|
|
|
+ mmutexrawdata.lock();
|
|
|
|
+ if(mvecterraw.size() > 0)
|
|
|
|
+ {
|
|
|
|
+ pdata_ptr = mvecterraw[0].mpraw_ptr;
|
|
|
|
+ nRecvTime = mvecterraw[0].mnrecvtime;
|
|
|
|
+ ndatasize = mvecterraw[0].ndatasize;
|
|
|
|
+ mvecterraw.erase(mvecterraw.begin());
|
|
|
|
+ nread = 1;
|
|
|
|
+ }
|
|
|
|
+ mmutexrawdata.unlock();
|
|
|
|
+ return nread;
|
|
}
|
|
}
|
|
|
|
|