23 bool SubDevice::configure(
size_t wb,
size_t wt,
size_t b,
size_t t,
size_t n,
const std::string& key,
const std::string& _parentName)
25 parentName = _parentName;
41 if ((top - base + 1) != axes) {
42 yCError(
CONTROLBOARD) <<
"Check configuration file, number of axes and top/base parameters do not match";
51 subDev_joint_encoders.resize(axes);
52 jointEncodersTimes.resize(axes);
53 subDev_motor_encoders.resize(axes);
54 motorEncodersTimes.resize(axes);
87 yCError(
CONTROLBOARD,
"Part <%s>: Wrong or unknown device %s. Cannot attach to it.", parentName.c_str(), k.c_str());
93 yCError(
CONTROLBOARD,
"Part <%s>: You need to call configure before you can attach any device", parentName.c_str());
104 if (subdevice->isValid()) {
105 subdevice->
view(pid);
106 subdevice->view(pos);
107 subdevice->view(posDir);
108 subdevice->view(vel);
109 subdevice->view(amp);
110 subdevice->view(lim);
111 subdevice->view(calib);
112 subdevice->view(info);
113 subdevice->view(iTimed);
114 subdevice->view(iTorque);
115 subdevice->view(iImpedance);
116 subdevice->view(iMode);
117 subdevice->view(iJntEnc);
118 subdevice->view(iMotEnc);
119 subdevice->view(iInteract);
120 subdevice->view(imotor);
121 subdevice->view(iVar);
122 subdevice->view(iCurr);
123 subdevice->view(iPWM);
125 yCError(
CONTROLBOARD,
"Part <%s>: Invalid device %s (isValid() returned false).", parentName.c_str(), k.c_str());
150 yCDebug(
CONTROLBOARD,
"Part <%s>: iInteractionMode not valid interface.", parentName.c_str());
154 yCDebug(
CONTROLBOARD,
"Part <%s>: iMotorEncoder not valid interface.", parentName.c_str());
162 yCDebug(
CONTROLBOARD,
"Part <%s>: iRemoteVariable not valid interface.", parentName.c_str());
169 size_t deviceJoints = 0;
173 yCError(
CONTROLBOARD,
"Part <%s>: IPositionControl interface was not found in subdevice. Quitting", parentName.c_str());
178 yCError(
CONTROLBOARD,
"Part <%s>: IVelocityControl interface was not found in subdevice. Quitting", parentName.c_str());
183 yCError(
CONTROLBOARD,
"Part <%s>: IEncoderTimed interface was not found in subdevice.", parentName.c_str());
187 if (pos !=
nullptr) {
189 if (!pos->getAxes(&tmp_axes)) {
194 yCError(
CONTROLBOARD,
"Part <%s>: attached device has an invalid number of joints (%d)", parentName.c_str(), tmp_axes);
197 deviceJoints =
static_cast<size_t>(tmp_axes);
200 if (!pos->getAxes(&tmp_axes)) {
201 yCError(
CONTROLBOARD,
"Part <%s>: failed to get axes number for subdevice %s.", parentName.c_str(), k.c_str());
205 yCError(
CONTROLBOARD,
"Part <%s>: attached device has an invalid number of joints (%d)", parentName.c_str(), tmp_axes);
208 deviceJoints =
static_cast<size_t>(tmp_axes);
211 if (deviceJoints < axes) {
212 yCError(
CONTROLBOARD,
"Part <%s>: check device configuration, number of joints of attached device '%zu' less \
213 than the one specified during configuration '%zu' for %s.",
222 if (!pos || !pos->getAxes(&subdevAxes)) {
223 yCError(
CONTROLBOARD) <<
"Device <" << parentName <<
"> attached to subdevice " << k.c_str() <<
" but it was not ready yet. \n"
224 <<
"Please check the device has been correctly created and all required initialization actions has been performed.";
228 totalAxis = deviceJoints;
const yarp::os::LogComponent & CONTROLBOARD()
bool configure(size_t wbase, size_t wtop, size_t base, size_t top, size_t axes, const std::string &id, const std::string &_parentName)
bool attach(yarp::dev::PolyDriver *d, const std::string &id)
bool view(T *&x)
Get an interface to the device driver.
A container for a device driver.
#define yCError(component,...)
#define yCDebug(component,...)
An interface for the device drivers.
An interface to the operating system, including Port based communication.