YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
CalibratorThread.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#include <yarp/os/Log.h>
7#include <yarp/os/LogStream.h>
8
11
13
14namespace {
15YARP_LOG_COMPONENT(YRI_CALIBRATOR, "yarp.yri.Calibrator")
16}
17
19{
20public:
23 calibrator(nullptr),
24 target(nullptr),
25 action(yarp::robotinterface::impl::CalibratorThread::Action::ActionCalibrate)
26 {
27 }
28
29 void run()
30 {
31 switch (action) {
32 case ActionCalibrate:
33 yCDebug(YRI_CALIBRATOR) << calibratorName << "starting calibration of device" << targetName;
35 yCDebug(YRI_CALIBRATOR) << calibratorName << "finished calibration of device" << targetName;
36 break;
37 case ActionPark:
38 yCDebug(YRI_CALIBRATOR) << calibratorName << "starting park device" << targetName;
40 yCDebug(YRI_CALIBRATOR) << calibratorName << "finished park device" << targetName;
41 break;
42 }
43 }
44
45 void stop()
46 {
47 switch (action) {
48 case ActionCalibrate:
49 yCDebug(YRI_CALIBRATOR) << calibratorName << "killing calibration of device" << targetName;
51 break;
52 case ActionPark:
53 yCDebug(YRI_CALIBRATOR) << calibratorName << "killing park of device" << targetName;
55 break;
56 }
57 }
58
60
62 std::string calibratorName;
64 std::string targetName;
66}; // class yarp::robotinterface::impl::CalibratorThread::Private
67
68
70 const std::string& calibratorName,
72 const std::string& targetName,
74 mPriv(new Private(this))
75{
76 yAssert(calibrator);
77 yAssert(target);
78 yAssert(action == ActionCalibrate || action == ActionPark);
79
80 mPriv->calibrator = calibrator;
81 mPriv->calibratorName = calibratorName;
82 mPriv->target = target;
83 mPriv->targetName = targetName;
84 mPriv->action = action;
85}
86
91
96
define control board standard interfaces
#define yAssert(x)
Definition Log.h:388
Interface implemented by all device drivers.
Interface for a calibrator device.
Definition ICalibrator.h:21
virtual bool park(DeviceDriver *dd, bool wait=true)=0
virtual bool calibrate(DeviceDriver *dd)=0
virtual bool quitPark()=0
virtual bool quitCalibrate()=0
yarp::robotinterface::impl::CalibratorThread::Action action
yarp::robotinterface::impl::CalibratorThread *const parent
void run() override
Main body of the new thread.
void onStop() override
Call-back, called while halting the thread (before join).
CalibratorThread(yarp::dev::ICalibrator *calibrator, const std::string &calibratorName, yarp::dev::DeviceDriver *target, const std::string &targetName, yarp::robotinterface::impl::CalibratorThread::Action action)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
The main, catch-all namespace for YARP.
Definition dirs.h:16