113 thr()->push_back(thread);
128 auto tit =
thr()->begin();
129 while (tit !=
thr()->end()) {
143 for (
auto* thread : *
thr()) {
156 for (yarp::robotinterface::ParamList::const_iterator it = p.begin(); it != p.end(); ++it) {
160 std::string stringFormatValue = param.
value();
162 for (
size_t i = 0; i < stringFormatValue.size() && counter >= 0; i++) {
163 if (stringFormatValue[i] ==
'(') {
165 }
else if (stringFormatValue[i] ==
')') {
170 yWarning() <<
"Parentheses not balanced for param " << param.
name();
173 std::string s =
"(" + param.
name() +
" " + param.
value() +
")";
189 dbg <<
"(name = \"" <<
t.name() <<
"\", type = \"" <<
t.type() <<
"\"";
190 if (!
t.params().empty()) {
191 dbg <<
", params = [";
195 if (!
t.actions().empty()) {
196 dbg <<
", actions = [";
211 const std::string& type,
223 mPriv(new
Private(*other.mPriv))
234 if (&other !=
this) {
236 mPriv->type = other.mPriv->
type;
238 mPriv->params.clear();
239 mPriv->params = other.mPriv->
params;
241 mPriv->actions.clear();
242 mPriv->actions = other.mPriv->
actions;
244 *mPriv->driver = *other.mPriv->
driver;
266 return mPriv->params;
271 return mPriv->actions;
286 return mPriv->params;
291 return mPriv->actions;
296 if (mPriv->isValid()) {
297 yError() <<
"Trying to open an already opened device.";
301 if (!mPriv->open()) {
302 yWarning() <<
"Cannot open device" << mPriv->name;
311 if (!mPriv->isValid()) {
317 if (!mPriv->close()) {
318 yWarning() <<
"Cannot close device" << mPriv->name;
342 mPriv->registerThread(thread);
347 mPriv->joinThreads();
352 mPriv->stopThreads();
363 if (!driver()->view(calibrator)) {
369 if (!target.
poly->
view(controlCalibrator)) {
380 bool rem_calibrator_available =
true;
382 if (!target.
poly->
view(rem_calibrator_wrap)) {
383 yWarning() <<
"Device " << target.
key <<
"is not implementing a yarp::dev::IRemoteCalibrator, therefore it cannot attach to a Calibrator device. \n \
384 Please verify that the target of calibrate action is a controlboardwrapper2 device. \
385 This doesn't prevent the yarprobotinterface to correctly operate, but no remote calibration and homing will be available";
386 rem_calibrator_available =
false;
389 if ((rem_calibrator_available) && (!driver()->view(rem_calibrator_calib))) {
390 yWarning() <<
"Device " << name() <<
"is not implementing a yarp::dev::IRemoteCalibrator, therefore it cannot be used as a remote calibration device. \n \
391 This doesn't prevent the yarprobotinterface to correctly operate, but no remote calibration and homing will be available";
392 rem_calibrator_available =
false;
395 if (rem_calibrator_available) {
405 registerThread(calibratorThread);
407 if (!calibratorThread->
start()) {
423 driver()->view(multiplewrapper);
425 if (drivers.
size() == 1) {
427 if (!driver()->view(wrapper)) {
428 yInfo() << name() <<
"is not an IWrapper. Trying IMultipleWrapper";
429 }
else if (wrapper->
attach(drivers[0]->poly)) {
431 }
else if (!multiplewrapper) {
435 yInfo() << name() <<
"IWrapper::attach() failed. Trying IMultipleWrapper::attach().";
439 if (!multiplewrapper) {
444 if (!multiplewrapper->
attachAll(drivers)) {
461 driver()->view(wrapper);
462 driver()->view(multiplewrapper);
464 if (!wrapper && !multiplewrapper) {
469 if (multiplewrapper) {
477 yInfo() << name() <<
"IMultipleWrapper::detachAll() failed. Trying IWrapper::detach().";
480 if (wrapper && !wrapper->
detach()) {
497 yError() <<
"park device do not exists";
501 if (!driver()->view(calibrator)) {
507 if (!target.
poly->
view(controlCalibrator)) {
519 registerThread(parkerThread);
521 if (!parkerThread->
start()) {
define control board standard interfaces
yarp::os::LogStream operator<<(yarp::os::LogStream dbg, const yarp::robotinterface::Device &t)
#define YARP_FIXME_NOTIMPLEMENTED(what)
bool view(T *&x)
Get an interface to the device driver.
Interface for control devices, calibration commands.
virtual bool setCalibrator(ICalibrator *c)
Set the calibrator object to be used to calibrate the robot.
Interface for an object that can wrap/attach to to another.
virtual bool detachAll()=0
Detach the object (you must have first called attach).
virtual bool attachAll(const PolyDriverList &drivers)=0
Attach to a list of objects.
IRemoteCalibrator interface is meant to remotize the access of the calibration device in order to all...
virtual bool setCalibratorDevice(yarp::dev::IRemoteCalibrator *dev)
setCalibratorDevice: store the pointer to the calibrator device.
Interface for an object that can wrap/or "attach" to another.
virtual bool detach()=0
Detach the object (you must have first called attach).
virtual bool attach(PolyDriver *driver)=0
Attach to another object.
A container for a device driver.
bool close() override
Close the DeviceDriver.
bool isValid() const
Check if device is valid.
bool open(const std::string &txt)
Construct and configure a device by its common name.
A class for storing options and configuration information.
void fromString(const std::string &txt, bool wipe=true)
Interprets a string as a list of properties.
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
A class for thread synchronization and mutual exclusion.
void wait()
Decrement the counter, even if we must wait to do that.
void post()
Increment the counter.
An abstraction for a thread of execution.
bool join(double seconds=-1)
The function returns when the thread execution has completed.
bool start()
Start the new thread running.
Private(const Private &other)
yarp::os::Semaphore * reg_sem() const
yarp::dev::PolyDriver * drv() const
yarp::os::Property paramsAsProperty() const
yarp::os::Semaphore * lst_sem() const
void registerThread(yarp::os::Thread *thread) const
yarp::robotinterface::ThreadList * thr() const
Private & operator=(const Private &other)
bool attach(const yarp::dev::PolyDriverList &drivers) const
bool park(const yarp::dev::PolyDriverDescriptor &target) const
yarp::dev::PolyDriver * driver() const
bool hasParam(const std::string &name) const
bool calibrate(const yarp::dev::PolyDriverDescriptor &target) const
Device & operator=(const Device &other)
std::string findParam(const std::string &name) const
void registerThread(yarp::os::Thread *thread) const
bool isValid()
Check if time is valid (non-zero).
robotinterface::ParamList mergeDuplicateGroups(const robotinterface::ParamList &list)
std::vector< robotinterface::Action > ActionList
std::string ActionTypeToString(robotinterface::ActionType actiontype)
bool hasParam(const robotinterface::ParamList &list, const std::string &name)
std::vector< robotinterface::Param > ParamList
std::string findParam(const robotinterface::ParamList &list, const std::string &name)
std::list< yarp::os::Thread * > ThreadList
The main, catch-all namespace for YARP.
ThreadList runningThreads
Driver(yarp::dev::PolyDriver *d)
yarp::dev::PolyDriver * driver
yarp::os::Semaphore registerThreadSemaphore
yarp::os::Semaphore threadListSemaphore