YARP
Yet Another Robot Platform
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 
15 {
16 public:
18  parent(parent),
19  calibrator(nullptr),
20  target(nullptr),
21  action(yarp::robotinterface::impl::CalibratorThread::Action::ActionCalibrate)
22  {
23  }
24 
25  void run()
26  {
27  switch (action) {
28  case ActionCalibrate:
29  yDebug() << calibratorName << "starting calibration of device" << targetName;
31  yDebug() << calibratorName << "finished calibration of device" << targetName;
32  break;
33  case ActionPark:
34  yDebug() << calibratorName << "starting park device" << targetName;
36  yDebug() << calibratorName << "finished park device" << targetName;
37  break;
38  }
39  }
40 
41  void stop()
42  {
43  switch (action) {
44  case ActionCalibrate:
45  yDebug() << calibratorName << "killing calibration of device" << targetName;
47  break;
48  case ActionPark:
49  yDebug() << calibratorName << "killing park of device" << targetName;
51  break;
52  }
53  }
54 
56 
58  std::string calibratorName;
60  std::string targetName;
62 }; // class yarp::robotinterface::impl::CalibratorThread::Private
63 
64 
66  const std::string& calibratorName,
68  const std::string& targetName,
70  mPriv(new Private(this))
71 {
72  yAssert(calibrator);
73  yAssert(target);
74  yAssert(action == ActionCalibrate || action == ActionPark);
75 
76  mPriv->calibrator = calibrator;
77  mPriv->calibratorName = calibratorName;
78  mPriv->target = target;
79  mPriv->targetName = targetName;
80  mPriv->action = action;
81 }
82 
84 {
85  delete mPriv;
86 }
87 
89 {
90  mPriv->run();
91 }
92 
94 {
95  mPriv->stop();
96 }
define control board standard interfaces
#define yDebug(...)
Definition: Log.h:234
#define yAssert(x)
Definition: Log.h:294
Interface implemented by all device drivers.
Definition: DeviceDriver.h:35
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)
The main, catch-all namespace for YARP.
Definition: dirs.h:16