#include <iostream>
#include <visp3/ustk_core/usConfig.h>
#if defined(VISP_HAVE_MODULE_USTK_GUI) && defined(VISP_HAVE_MODULE_USTK_GRABBER) && defined(VISP_HAVE_VIPER850)
#include <visp3/ustk_grabber/usNetworkGrabberPreScan2D.h>
#include <visp3/ustk_gui/usConfidenceMapController.h>
#include <visp3/ustk_gui/usImageDisplayWidgetRobotControl.h>
#include <visp3/ustk_gui/usRobotManualControlWidget.h>
#include <visp3/ustk_gui/usUltrasonixClientWidget.h>
#include <visp3/ustk_gui/usViper850WrapperVelocityControl.h>
#include <QApplication>
#include <QHBoxLayout>
#include <QMainWindow>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
app.setApplicationName(QString("USTK display widget"));
usUltrasonixClientWidget *ultrasonixControlWidet = new usUltrasonixClientWidget();
QWidget *centralWidget = new QWidget();
QHBoxLayout *mainLayout = new QHBoxLayout();
mainLayout->addWidget(ultrasonixControlWidet);
mainLayout->addWidget(widget, 2);
mainLayout->addWidget(robotControlPanel);
centralWidget->setLayout(mainLayout);
QThread *threadRobotControl = new QThread();
viperControl.moveToThread(threadRobotControl);
threadRobotControl->start();
usConfidenceMapController *confidenceController = new usConfidenceMapController();
QThread *confidenceThread = new QThread();
confidenceController->moveToThread(confidenceThread);
confidenceThread->start();
QThread *grabbingThread = new QThread();
qtGrabber->moveToThread(grabbingThread);
grabbingThread->start();
QMainWindow window;
window.setCentralWidget(centralWidget);
window.resize(1280, 480);
window.show();
QObject::connect(robotControlPanel, SIGNAL(changeVX(int)), &viperControl, SLOT(setXVelocity(int)));
QObject::connect(robotControlPanel, SIGNAL(changeVY(int)), &viperControl, SLOT(setYVelocity(int)));
QObject::connect(robotControlPanel, SIGNAL(changeVZ(int)), &viperControl, SLOT(setZVelocity(int)));
QObject::connect(robotControlPanel, SIGNAL(changeWX(int)), &viperControl, SLOT(setXAngularVelocity(int)));
QObject::connect(robotControlPanel, SIGNAL(changeWY(int)), &viperControl, SLOT(setYAngularVelocity(int)));
QObject::connect(robotControlPanel, SIGNAL(changeWZ(int)), &viperControl, SLOT(setZAngularVelocity(int)));
QObject::connect(widget, SIGNAL(moveLeft()), &viperControl, SLOT(moveLeft()));
QObject::connect(widget, SIGNAL(moveRight()), &viperControl, SLOT(moveRight()));
QObject::connect(widget, SIGNAL(stopMove()), &viperControl, SLOT(stopMoveLateral()));
QObject::connect(robotControlPanel, SIGNAL(initRobot()), &viperControl, SLOT(init()));
QObject::connect(robotControlPanel, SIGNAL(startRobot()), &viperControl, SLOT(run()));
QObject::connect(robotControlPanel, SIGNAL(stopRobot()), &viperControl, SLOT(stop()));
QObject::connect(robotControlPanel, SIGNAL(activateAutomaticForceControl()), &viperControl,
SLOT(startAutomaticForceControl()));
QObject::connect(robotControlPanel, SIGNAL(disableAutomaticForceControl()), &viperControl,
SLOT(stopAutomaticForceControl()));
QObject::connect(&viperControl, SIGNAL(robotError()), robotControlPanel, SLOT(robotErrorSlot()));
qRegisterMetaType<QHostAddress>("QHostAddress");
qRegisterMetaType<usNetworkGrabber::usInitHeaderSent>("usNetworkGrabber::usInitHeaderSent");
QObject::connect(ultrasonixControlWidet, SIGNAL(connectToServer(QHostAddress)), qtGrabber,
SLOT(connectToServer(QHostAddress)));
QObject::connect(ultrasonixControlWidet, SIGNAL(center3DProbeMotor()), qtGrabber, SLOT(center3DProbeMotor()));
QObject::connect(ultrasonixControlWidet, SIGNAL(runAcquisition()), qtGrabber, SLOT(runAcquisition()));
QObject::connect(ultrasonixControlWidet, SIGNAL(stopAcquisition()), qtGrabber, SLOT(stopAcquisition()));
qRegisterMetaType<usImagePreScan2D<unsigned char> >("usImagePreScan2D<unsigned char>");
QObject::connect(widget, SIGNAL(confidenceServoing(bool)), confidenceController, SLOT(activateController(bool)));
QObject::connect(confidenceController, SIGNAL(updateProbeOrientation(int)), &viperControl,
SLOT(setZAngularVelocity(int)));
QObject::connect(confidenceController, SIGNAL(confidenceBarycenterAngle(double)), widget,
SLOT(updateConfidenceAngle(double)));
app.exec();
grabbingThread->exit();
delete widget;
delete robotControlPanel;
delete centralWidget;
delete mainLayout;
delete grabbingThread;
delete qtGrabber;
return 0;
}
#else
int main()
{
std::cout << "You should build ustk_gui and ustk_grabber, and have a viper850 robot to run this tutorial"
<< std::endl;
return 0;
}
#endif
Specific class to grab pre-scan frames from the ultrasound station on the network.