YARP
Yet Another Robot Platform
CalibratorThread.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 #include <yarp/os/Log.h>
10 #include <yarp/os/LogStream.h>
11 
14 
16 
18 {
19 public:
21  parent(parent),
22  calibrator(nullptr),
23  target(nullptr),
24  action(yarp::robotinterface::impl::CalibratorThread::Action::ActionCalibrate)
25  {
26  }
27 
28  void run()
29  {
30  switch (action) {
31  case ActionCalibrate:
32  yDebug() << calibratorName << "starting calibration of device" << targetName;
34  yDebug() << calibratorName << "finished calibration of device" << targetName;
35  break;
36  case ActionPark:
37  yDebug() << calibratorName << "starting park device" << targetName;
39  yDebug() << calibratorName << "finished park device" << targetName;
40  break;
41  }
42  }
43 
44  void stop()
45  {
46  switch (action) {
47  case ActionCalibrate:
48  yDebug() << calibratorName << "killing calibration of device" << targetName;
50  break;
51  case ActionPark:
52  yDebug() << calibratorName << "killing park of device" << targetName;
54  break;
55  }
56  }
57 
59 
61  std::string calibratorName;
63  std::string targetName;
65 }; // class yarp::robotinterface::impl::CalibratorThread::Private
66 
67 
69  const std::string& calibratorName,
71  const std::string& targetName,
73  mPriv(new Private(this))
74 {
75  yAssert(calibrator);
76  yAssert(target);
77  yAssert(action == ActionCalibrate || action == ActionPark);
78 
79  mPriv->calibrator = calibrator;
80  mPriv->calibratorName = calibratorName;
81  mPriv->target = target;
82  mPriv->targetName = targetName;
83  mPriv->action = action;
84 }
85 
87 {
88  delete mPriv;
89 }
90 
92 {
93  mPriv->run();
94 }
95 
97 {
98  mPriv->stop();
99 }
define control board standard interfaces
#define yDebug(...)
Definition: Log.h:237
#define yAssert(x)
Definition: Log.h:297
Interface implemented by all device drivers.
Definition: DeviceDriver.h:38
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: environment.h:18