由于马达移动准确性较低,自动调焦完成后,直接移动到m_goodPos效果不好,所以先移动到tmpPos,然后移动到m_goodPos
This commit is contained in:
@ -32,7 +32,7 @@ void OneMotorControl::onConnectMotor()
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_multiAxisController->moveToThread(&m_motorThread);
|
m_multiAxisController->moveToThread(&m_motorThread);
|
||||||
m_motorThread.start();
|
connect(&m_motorThread, SIGNAL(finished()), m_multiAxisController, SLOT(deleteLater()));
|
||||||
|
|
||||||
connect(this->ui.right_btn, SIGNAL(pressed()), this, SLOT(onxMotorRight()));
|
connect(this->ui.right_btn, SIGNAL(pressed()), this, SLOT(onxMotorRight()));
|
||||||
connect(this->ui.right_btn, SIGNAL(released()), this, SLOT(onxMotorStop()));
|
connect(this->ui.right_btn, SIGNAL(released()), this, SLOT(onxMotorStop()));
|
||||||
@ -59,6 +59,8 @@ void OneMotorControl::onConnectMotor()
|
|||||||
|
|
||||||
connect(this, SIGNAL(testConnectivitySignal(int, int)), m_multiAxisController, SLOT(testConnectivity(int, int)));
|
connect(this, SIGNAL(testConnectivitySignal(int, int)), m_multiAxisController, SLOT(testConnectivity(int, int)));
|
||||||
connect(m_multiAxisController, SIGNAL(broadcastConnectivity(std::vector<int>)), this, SLOT(display_motors_connectivity(std::vector<int>)));
|
connect(m_multiAxisController, SIGNAL(broadcastConnectivity(std::vector<int>)), this, SLOT(display_motors_connectivity(std::vector<int>)));
|
||||||
|
|
||||||
|
m_motorThread.start();
|
||||||
emit testConnectivitySignal(0, 1000);
|
emit testConnectivitySignal(0, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,6 +118,7 @@ void focusWindow::onConnectMotor()
|
|||||||
connect(this, SIGNAL(zeroStartSignal(int)), m_multiAxisController, SLOT(zeroStart(int)));
|
connect(this, SIGNAL(zeroStartSignal(int)), m_multiAxisController, SLOT(zeroStart(int)));
|
||||||
connect(this, SIGNAL(move2MaxLocSignal(int, double, int)), m_multiAxisController, SLOT(moveToMax(int, double, int)));
|
connect(this, SIGNAL(move2MaxLocSignal(int, double, int)), m_multiAxisController, SLOT(moveToMax(int, double, int)));
|
||||||
connect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(display_x_loc(std::vector<double>)));
|
connect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(display_x_loc(std::vector<double>)));
|
||||||
|
connect(m_multiAxisController, SIGNAL(motorStopSignal(int, double)), this, SLOT(moveAfterAutoFocus(int, double)));
|
||||||
m_motorThread.start();
|
m_motorThread.start();
|
||||||
|
|
||||||
//归零
|
//归零
|
||||||
@ -408,10 +409,14 @@ void focusWindow::onAutoFocusFinished()
|
|||||||
if (mu < 0 || mu > maxPos)
|
if (mu < 0 || mu > maxPos)
|
||||||
{
|
{
|
||||||
std::cout << "拟合失败!!!!!" << std::endl;
|
std::cout << "拟合失败!!!!!" << std::endl;
|
||||||
QMessageBox msgBox;
|
m_goodPos = mu_init;
|
||||||
msgBox.setText(QString::fromLocal8Bit("纹理较弱,自动调焦效果不佳!请使用调焦纸进行自动调焦!"));
|
m_isAutoFocusSuccess = false;
|
||||||
msgBox.exec();
|
}
|
||||||
mu = mu_init;
|
else
|
||||||
|
{
|
||||||
|
std::cout << "拟合成功!!!!!" << std::endl;
|
||||||
|
m_goodPos = mu;
|
||||||
|
m_isAutoFocusSuccess = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileOperation* fileOperation = new FileOperation();
|
FileOperation* fileOperation = new FileOperation();
|
||||||
@ -420,13 +425,13 @@ void focusWindow::onAutoFocusFinished()
|
|||||||
QString format1 = "yyyyMMdd_HHmmss";
|
QString format1 = "yyyyMMdd_HHmmss";
|
||||||
QString fileName = now.toString("yyyyMMdd_HHmmss");
|
QString fileName = now.toString("yyyyMMdd_HHmmss");
|
||||||
|
|
||||||
QString tmp = QDir::cleanPath(QString::fromStdString(directory) + QDir::separator() + fileName + "_" + QString::number(m_iStepSize) + "interval_" + QString::number(mu) + ".csv");
|
QString fitDataFile = QDir::cleanPath(QString::fromStdString(directory) + QDir::separator() + fileName + "_" + QString::number(m_iStepSize) + "interval_" + QString::number(mu) + ".csv");
|
||||||
|
m_coordinator->saveToCsv(fitDataFile);
|
||||||
|
|
||||||
QString focusFilePath = QString::fromStdString(directory) + "\\focus.csv";
|
//由于马达移动准确性较低,自动调焦完成后,直接移动到m_goodPos效果不好,所以先移动到tmpPos,然后移动到m_goodPos
|
||||||
m_coordinator->saveToCsv(tmp);
|
double tmpPos = m_goodPos - positionData[positionData.size() - 1].actualPosition / 10;
|
||||||
|
m_isMoveAfterAutoFocus = true;
|
||||||
//移动马达到最佳位置
|
emit move2LocSignal(0, (double)tmpPos, m_dSpeed, 1000);
|
||||||
emit move2LocSignal(0, (double)mu, m_dSpeed, 1000);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -436,6 +441,37 @@ void focusWindow::onAutoFocusFinished()
|
|||||||
this->setDisabled(false);
|
this->setDisabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void focusWindow::moveAfterAutoFocus(int motorID, double location)
|
||||||
|
{
|
||||||
|
if (!m_isMoveAfterAutoFocus)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "\n已经到达位置:" << location << std::endl;
|
||||||
|
|
||||||
|
//移动马达到最佳位置
|
||||||
|
emit move2LocSignal(0, (double)m_goodPos, m_dSpeed, 1000);
|
||||||
|
|
||||||
|
double tmp = abs(location - m_goodPos) / m_goodPos * 100;
|
||||||
|
if (tmp<5)
|
||||||
|
{
|
||||||
|
if (!m_isAutoFocusSuccess)
|
||||||
|
{
|
||||||
|
QMessageBox msgBox;
|
||||||
|
msgBox.setText(QString::fromLocal8Bit("纹理较弱,自动调焦效果不佳!请使用调焦纸进行自动调焦!"));
|
||||||
|
msgBox.exec();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMessageBox msgBox;
|
||||||
|
msgBox.setText(QString::fromLocal8Bit("自动调焦成功!"));
|
||||||
|
msgBox.exec();
|
||||||
|
}
|
||||||
|
m_isMoveAfterAutoFocus = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void focusWindow::getGaussianInitParam(const std::vector<double>& pos, const std::vector<double>& index, double& a_init, double& mu_init, double& sigma_init, double& c_init)
|
void focusWindow::getGaussianInitParam(const std::vector<double>& pos, const std::vector<double>& index, double& a_init, double& mu_init, double& sigma_init, double& c_init)
|
||||||
{
|
{
|
||||||
auto minmax_element = std::minmax_element(index.begin(), index.end());
|
auto minmax_element = std::minmax_element(index.begin(), index.end());
|
||||||
|
@ -125,6 +125,9 @@ private:
|
|||||||
MotionCaptureCoordinator* m_coordinator;
|
MotionCaptureCoordinator* m_coordinator;
|
||||||
|
|
||||||
int m_iStepSize;
|
int m_iStepSize;
|
||||||
|
double m_goodPos;
|
||||||
|
bool m_isAutoFocusSuccess;
|
||||||
|
bool m_isMoveAfterAutoFocus = false;
|
||||||
void getGaussianInitParam(const std::vector<double>& pos, const std::vector<double>& index, double& a_init, double& mu_init, double& sigma_init, double& c_init);
|
void getGaussianInitParam(const std::vector<double>& pos, const std::vector<double>& index, double& a_init, double& mu_init, double& sigma_init, double& c_init);
|
||||||
void gaussian_fit(const std::vector<double>& x_data, const std::vector<double>& y_data, double& a, double& mu, double& sigma, double& c);
|
void gaussian_fit(const std::vector<double>& x_data, const std::vector<double>& y_data, double& a, double& mu, double& sigma, double& c);
|
||||||
|
|
||||||
@ -146,6 +149,8 @@ public Q_SLOTS:
|
|||||||
void display_x_loc(std::vector<double> loc);
|
void display_x_loc(std::vector<double> loc);
|
||||||
void onx_rangeMeasurement();
|
void onx_rangeMeasurement();
|
||||||
|
|
||||||
|
void moveAfterAutoFocus(int motorID, double location);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void StartManualFocusSignal(int);//1<><31><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><30>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
void StartManualFocusSignal(int);//1<><31><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><30>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user