4 #include <visp3/ustk_core/usConfig.h>
6 #if defined(VISP_HAVE_MODULE_USTK_GUI) && defined(VISP_HAVE_MODULE_USTK_TEMPLATE_TRACKING) && \
7 defined(VISP_HAVE_VIPER850) && (defined(USTK_HAVE_VTK_QT5) || defined(USTK_HAVE_QT5))
9 #include <visp3/ustk_core/usImageIo.h>
10 #include <visp3/ustk_grabber/usNetworkGrabberPreScan2D.h>
11 #include <visp3/ustk_gui/usImageDisplayWidgetQmlOverlayServoing.h>
12 #include <visp3/ustk_gui/usRectangleVisualServoingController.h>
13 #include <visp3/ustk_gui/usRobotManualControlWidget.h>
14 #include <visp3/ustk_gui/usUltrasonixClientWidget.h>
15 #include <visp3/ustk_gui/usViper850WrapperVelocityControl.h>
17 #include <QApplication>
18 #include <QMainWindow>
20 int main(
int argc,
char **argv)
22 QApplication app(argc, argv);
23 app.setApplicationName(QString(
"USTK tracking 2D demo"));
28 usUltrasonixClientWidget *ultrasonixControlWidet =
new usUltrasonixClientWidget();
31 QWidget *centralWidget =
new QWidget();
32 QHBoxLayout *mainLayout =
new QHBoxLayout();
33 mainLayout->addWidget(ultrasonixControlWidet);
34 mainLayout->addWidget(widget, 2);
35 mainLayout->addWidget(robotControlPanel);
36 centralWidget->setLayout(mainLayout);
39 QThread *threadRobotControl =
new QThread();
41 viperControl.moveToThread(threadRobotControl);
42 threadRobotControl->start();
46 usRectangleVisualServoingController *visualServoingController =
new usRectangleVisualServoingController();
47 QThread *servoingThread =
new QThread();
48 visualServoingController->moveToThread(servoingThread);
49 servoingThread->start();
52 QThread *grabbingThread =
new QThread();
55 qtGrabber->moveToThread(grabbingThread);
56 grabbingThread->start();
59 QObject::connect(robotControlPanel, SIGNAL(changeVX(
int)), &viperControl, SLOT(setXVelocity(
int)));
60 QObject::connect(robotControlPanel, SIGNAL(changeVY(
int)), &viperControl, SLOT(setYVelocity(
int)));
61 QObject::connect(robotControlPanel, SIGNAL(changeVZ(
int)), &viperControl, SLOT(setZVelocity(
int)));
62 QObject::connect(robotControlPanel, SIGNAL(changeWX(
int)), &viperControl, SLOT(setXAngularVelocity(
int)));
63 QObject::connect(robotControlPanel, SIGNAL(changeWY(
int)), &viperControl, SLOT(setYAngularVelocity(
int)));
64 QObject::connect(robotControlPanel, SIGNAL(changeWZ(
int)), &viperControl, SLOT(setZAngularVelocity(
int)));
66 QObject::connect(robotControlPanel, SIGNAL(initRobot()), &viperControl, SLOT(init()));
67 QObject::connect(robotControlPanel, SIGNAL(startRobot()), &viperControl, SLOT(run()));
68 QObject::connect(robotControlPanel, SIGNAL(stopRobot()), &viperControl, SLOT(stop()));
70 QObject::connect(robotControlPanel, SIGNAL(activateAutomaticForceControl()), &viperControl,
71 SLOT(startAutomaticForceControl()));
72 QObject::connect(robotControlPanel, SIGNAL(disableAutomaticForceControl()), &viperControl,
73 SLOT(stopAutomaticForceControl()));
76 QObject::connect(&viperControl, SIGNAL(robotError()), robotControlPanel, SLOT(robotErrorSlot()));
79 qRegisterMetaType<vpRectOriented>(
"vpRectOriented");
80 QObject::connect(widget, SIGNAL(startTrackingRect(vpRectOriented)), visualServoingController,
81 SLOT(initTracker(vpRectOriented)));
82 QObject::connect(widget, SIGNAL(stopTrackingRect()), visualServoingController, SLOT(stopTracking()));
83 QObject::connect(widget, SIGNAL(startServoingRect()), visualServoingController, SLOT(activateController()));
84 QObject::connect(widget, SIGNAL(stopServoingRect()), visualServoingController, SLOT(disactivateController()));
87 qRegisterMetaType<QHostAddress>(
"QHostAddress");
88 qRegisterMetaType<usNetworkGrabber::usInitHeaderSent>(
"usNetworkGrabber::usInitHeaderSent");
89 QObject::connect(ultrasonixControlWidet, SIGNAL(connectToServer(QHostAddress)), qtGrabber,
90 SLOT(connectToServer(QHostAddress)));
93 QObject::connect(ultrasonixControlWidet, SIGNAL(center3DProbeMotor()), qtGrabber, SLOT(center3DProbeMotor()));
94 QObject::connect(ultrasonixControlWidet, SIGNAL(runAcquisition()), qtGrabber, SLOT(runAcquisition()));
95 QObject::connect(ultrasonixControlWidet, SIGNAL(stopAcquisition()), qtGrabber, SLOT(stopAcquisition()));
98 qRegisterMetaType<usImagePreScan2D<unsigned char> >(
"usImagePreScan2D<unsigned char>");
99 qRegisterMetaType<usImagePostScan2D<unsigned char> >(
"usImagePostScan2D<unsigned char>");
106 QObject::connect(visualServoingController, SIGNAL(newRectTracked(vpRectOriented)), widget,
107 SLOT(updateRectPosition(vpRectOriented)));
110 QObject::connect(visualServoingController, SIGNAL(updatePobeXVelocity(
int)), &viperControl, SLOT(setXVelocity(
int)));
111 QObject::connect(visualServoingController, SIGNAL(updateProbeZOrientation(
int)), &viperControl,
112 SLOT(setZAngularVelocity(
int)));
115 QObject::connect(visualServoingController, SIGNAL(trackerXError(
double)), widget, SLOT(updateXError(
double)));
116 QObject::connect(visualServoingController, SIGNAL(confidenceBarycenterAngle(
double)), widget,
117 SLOT(updateConfidenceAngle(
double)));
122 window.setCentralWidget(centralWidget);
123 window.resize(1200, 650);
132 std::cout <<
"You should build ustk_gui and ustk_template_tracking to run this tutorial" << std::endl;
Specific class to grab pre-scan frames from the ultrasound station on the network.
void activateRecording(std::string path)