YARP
Yet Another Robot Platform
ControlBoardWrapperAxisInfo.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 
10 
12 
13 
14 bool ControlBoardWrapperAxisInfo::getAxisName(int j, std::string& name)
15 {
16  size_t off;
17  try {
18  off = device.lut.at(j).offset;
19  } catch (...) {
20  yCError(CONTROLBOARDWRAPPER, "Joint number %d out of bound [0-%zu] for part %s", j, controlledJoints, partName.c_str());
21  return false;
22  }
23  size_t subIndex = device.lut[j].deviceEntry;
24 
25  SubDevice* p = device.getSubdevice(subIndex);
26  if (!p) {
27  return false;
28  }
29 
30  if (p->info) {
31  return p->info->getAxisName(static_cast<int>(off + p->base), name);
32  }
33  return false;
34 }
35 
37 {
38  int off = device.lut[j].offset;
39  size_t subIndex = device.lut[j].deviceEntry;
40 
41  SubDevice* p = device.getSubdevice(subIndex);
42  if (!p) {
43  return false;
44  }
45 
46  if (p->info) {
47  return p->info->getJointType(static_cast<int>(off + p->base), type);
48  }
49  return false;
50 }
ControlBoardWrapperAxisInfo::getAxisName
bool getAxisName(int j, std::string &name) override
Definition: ControlBoardWrapperAxisInfo.cpp:14
ControlBoardWrapperLogComponent.h
SubDevice::info
yarp::dev::IAxisInfo * info
Definition: SubDevice.h:82
ControlBoardWrapperAxisInfo::getJointType
bool getJointType(int j, yarp::dev::JointTypeEnum &type) override
Definition: ControlBoardWrapperAxisInfo.cpp:36
CONTROLBOARDWRAPPER
const yarp::os::LogComponent & CONTROLBOARDWRAPPER()
Definition: ControlBoardWrapperLogComponent.cpp:11
ControlBoardWrapperCommon::partName
std::string partName
Definition: ControlBoardWrapperCommon.h:24
ControlBoardWrapperAxisInfo.h
ControlBoardWrapperCommon::controlledJoints
size_t controlledJoints
Definition: ControlBoardWrapperCommon.h:23
WrappedDevice::getSubdevice
SubDevice * getSubdevice(size_t i)
Definition: SubDevice.h:129
ControlBoardWrapperCommon::device
WrappedDevice device
Definition: ControlBoardWrapperCommon.h:22
yarp::dev::IAxisInfo::getJointType
virtual bool getJointType(int axis, yarp::dev::JointTypeEnum &type)
Definition: IAxisInfo.h:62
yCError
#define yCError(component,...)
Definition: LogComponent.h:157
SubDevice::base
size_t base
Definition: SubDevice.h:58
WrappedDevice::lut
std::vector< DevicesLutEntry > lut
Definition: SubDevice.h:126
yarp::dev::IAxisInfo::getAxisName
virtual bool getAxisName(int axis, std::string &name)=0
SubDevice
Definition: SubDevice.h:55
yarp::dev::JointTypeEnum
JointTypeEnum
Definition: IAxisInfo.h:29