diff --git a/Lidar/rplidarthread.cpp b/Lidar/rplidarthread.cpp index abd60fb..4952438 100644 --- a/Lidar/rplidarthread.cpp +++ b/Lidar/rplidarthread.cpp @@ -22,11 +22,12 @@ #include "rplidarthread.h" -RPLidarThread::RPLidarThread(const QString& serialPortFileName, const unsigned int serialPortBPS, const unsigned short motorPWM) +RPLidarThread::RPLidarThread(const QString& serialPortFileName, const unsigned int serialPortBPS, const unsigned short motorPWM, const short scanMode) { this->serialPortFileName = serialPortFileName; this->serialPortBPS = serialPortBPS; this->motorPWM = motorPWM; + this->scanMode = scanMode; terminateRequest = false; suspended = false; @@ -177,9 +178,17 @@ void RPLidarThread::run() { suspendIfNeeded(); - emit infoMessage("Starting scan..."); - - rpResult = lidarDriver->startScan(false, true); + if (scanMode == -1) + { + // Use startScan-call when scanmode is "standard" + emit infoMessage("Starting scan using startScan-call..."); + rpResult = lidarDriver->startScan(false, true); + } + else + { + emit infoMessage("Starting scan using startScanExpress-call, mode: " + QString::number(scanMode) + "..."); + rpResult = lidarDriver->startScanExpress(false, scanMode); + } if (IS_FAIL(rpResult)) { diff --git a/Lidar/rplidarthread.h b/Lidar/rplidarthread.h index dcedd6b..7d8e004 100644 --- a/Lidar/rplidarthread.h +++ b/Lidar/rplidarthread.h @@ -35,8 +35,9 @@ class RPLidarThread : public QThread * @brief Constructor * @param serialPortFileName File name of com port to open * @param serialPortBPS Speed (Bits Per Second) of the serial port + * @param scanMode Value used in startScanExpress-call's scanMode-parameter or -1 (use startScan-call instead) */ - RPLidarThread(const QString& serialPortFileName, const unsigned int serialPortBPS, const unsigned short motorPWM = 660); + RPLidarThread(const QString& serialPortFileName, const unsigned int serialPortBPS, const unsigned short motorPWM = 660, const short scanMode = -1); ~RPLidarThread() override; void run() override; //!< Thread code @@ -56,6 +57,7 @@ class RPLidarThread : public QThread QString serialPortFileName; unsigned int serialPortBPS; unsigned short motorPWM = 0; + short scanMode = -1; bool terminateRequest = false; bool suspended = false; diff --git a/mainwindow.cpp b/mainwindow.cpp index 54e0ada..7246561 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -172,6 +172,7 @@ MainWindow::MainWindow(QWidget *parent) : ui->lineEdit_SerialPort_RPLidar->setText(settings.value("SerialPort_RPLidar", "\\\\.\\COM").toString()); ui->spinBox_SerialSpeed_RPLidar->setValue(settings.value("SerialSpeed_RPLidar", "256000").toInt()); ui->spinBox_MotorPWM_RPLidar->setValue(settings.value("MotorPWM_RPLidar", "660").toInt()); + ui->comboBox_ExpressScanMode->setCurrentIndex(settings.value("ExpressScanMode_RPLidar", "0").toInt()); // Why is this needed? Q_ENUM should do the job? Different threads causing the need for this? qRegisterMetaType(); @@ -188,6 +189,7 @@ MainWindow::~MainWindow() settings.setValue("SerialPort_RPLidar", ui->lineEdit_SerialPort_RPLidar->text()); settings.setValue("SerialSpeed_RPLidar", ui->spinBox_SerialSpeed_RPLidar->value()); settings.setValue("MotorPWM_RPLidar", ui->spinBox_MotorPWM_RPLidar->value()); + settings.setValue("ExpressScanMode_RPLidar", ui->comboBox_ExpressScanMode->currentIndex()); delete messageMonitorForm_Base_Serial; delete messageMonitorForm_Base_NTRIP; @@ -1086,7 +1088,7 @@ void MainWindow::on_pushButton_StartThread_RPLidar_clicked() { if (!thread_RPLidar) { - thread_RPLidar = new RPLidarThread(ui->lineEdit_SerialPort_RPLidar->text(), ui->spinBox_SerialSpeed_RPLidar->value(), ui->spinBox_MotorPWM_RPLidar->value()); + thread_RPLidar = new RPLidarThread(ui->lineEdit_SerialPort_RPLidar->text(), ui->spinBox_SerialSpeed_RPLidar->value(), ui->spinBox_MotorPWM_RPLidar->value(), ui->comboBox_ExpressScanMode->currentIndex() - 1); if (ui->checkBox_SuspendThread_RPLidar->isChecked()) { thread_RPLidar->suspend(); @@ -1113,6 +1115,7 @@ void MainWindow::on_pushButton_StartThread_RPLidar_clicked() ui->lineEdit_SerialPort_RPLidar->setEnabled(false); ui->spinBox_SerialSpeed_RPLidar->setEnabled(false); ui->spinBox_MotorPWM_RPLidar->setEnabled(false); + ui->comboBox_ExpressScanMode->setEnabled(false); ui->pushButton_StartThread_RPLidar->setEnabled(false); ui->pushButton_TerminateThread_RPLidar->setEnabled(true); } @@ -1150,6 +1153,7 @@ void MainWindow::on_pushButton_TerminateThread_RPLidar_clicked() ui->lineEdit_SerialPort_RPLidar->setEnabled(true); ui->spinBox_SerialSpeed_RPLidar->setEnabled(true); ui->spinBox_MotorPWM_RPLidar->setEnabled(true); + ui->comboBox_ExpressScanMode->setEnabled(true); ui->pushButton_StartThread_RPLidar->setEnabled(true); ui->pushButton_TerminateThread_RPLidar->setEnabled(false); } diff --git a/mainwindow.ui b/mainwindow.ui index 3d77e33..938f0d5 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -7,7 +7,7 @@ 0 0 626 - 696 + 734 @@ -24,9 +24,9 @@ 0 - 0 + -438 589 - 1121 + 1131 @@ -994,6 +994,73 @@ 4 + + + + 8 + + + 8 + + + + + Serial port: + + + + + + + \\.\COM + + + 256 + + + + + + + Bps: + + + + + + + + 80 + 0 + + + + 300 + + + 10000000 + + + 115200 + + + + + + + Start thread + + + + + + + Terminate thread + + + + + @@ -1149,73 +1216,6 @@ - - - - 8 - - - 8 - - - - - Serial port: - - - - - - - \\.\COM - - - 256 - - - - - - - Bps: - - - - - - - - 80 - 0 - - - - 300 - - - 10000000 - - - 115200 - - - - - - - Start thread - - - - - - - Terminate thread - - - - - @@ -1525,74 +1525,129 @@ RPLidar - + - - - 8 - - - 8 - - - - - Serial port: - - - - - - - \\.\COM - - - 256 - - - - - - - Bps: - - - - - - - - 80 - 0 - - - - 300 - - - 10000000 - - - 256000 - - - - - - - Motor PWM: - - - + - - - 1023 - - - 660 - - + + + + + + + Serial port: + + + + + + + \\.\COM + + + 256 + + + + + + + Bps: + + + + + + + + 80 + 0 + + + + 300 + + + 10000000 + + + 256000 + + + + + + + Motor PWM: + + + + + + + 1023 + + + 660 + + + + + + + + + + + Express scan mode: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + None (use startScan-call instead of Express) + + + + + Standard (0) + + + + + Express (1) + + + + + HQ (2) + + + + + Boost (3) + + + + + Stability (4) + + + + + Sensitivity (5) + + + + + + + @@ -1636,7 +1691,7 @@ - + 8