YARP
Yet Another Robot Platform
ControlBoardWrapperControlLimits.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 
7 
9 
10 
11 bool ControlBoardWrapperControlLimits::setLimits(int j, double min, double max)
12 {
13  size_t off;
14  try {
15  off = device.lut.at(j).offset;
16  } catch (...) {
17  yCError(CONTROLBOARD, "Joint number %d out of bound [0-%zu] for part %s", j, controlledJoints, partName.c_str());
18  return false;
19  }
20  size_t subIndex = device.lut[j].deviceEntry;
21 
22  SubDevice* p = device.getSubdevice(subIndex);
23  if (!p) {
24  return false;
25  }
26 
27  if (p->lim) {
28  return p->lim->setLimits(static_cast<int>(off + p->base), min, max);
29  }
30  return false;
31 }
32 
33 bool ControlBoardWrapperControlLimits::getLimits(int j, double* min, double* max)
34 {
35  size_t off;
36  try {
37  off = device.lut.at(j).offset;
38  } catch (...) {
39  yCError(CONTROLBOARD, "Joint number %d out of bound [0-%zu] for part %s", j, controlledJoints, partName.c_str());
40  return false;
41  }
42  size_t subIndex = device.lut[j].deviceEntry;
43 
44  SubDevice* p = device.getSubdevice(subIndex);
45  if (!p) {
46  *min = 0.0;
47  *max = 0.0;
48  return false;
49  }
50 
51  if (p->lim) {
52  return p->lim->getLimits(static_cast<int>(off + p->base), min, max);
53  }
54  *min = 0.0;
55  *max = 0.0;
56  return false;
57 }
58 
59 bool ControlBoardWrapperControlLimits::setVelLimits(int j, double min, double max)
60 {
61  size_t off;
62  try {
63  off = device.lut.at(j).offset;
64  } catch (...) {
65  yCError(CONTROLBOARD, "Joint number %d out of bound [0-%zu] for part %s", j, controlledJoints, partName.c_str());
66  return false;
67  }
68  size_t subIndex = device.lut[j].deviceEntry;
69 
70  SubDevice* p = device.getSubdevice(subIndex);
71  if (!p) {
72  return false;
73  }
74 
75  if (!p->lim) {
76  return false;
77  }
78  return p->lim->setVelLimits(static_cast<int>(off + p->base), min, max);
79 }
80 
81 bool ControlBoardWrapperControlLimits::getVelLimits(int j, double* min, double* max)
82 {
83  size_t off;
84  try {
85  off = device.lut.at(j).offset;
86  } catch (...) {
87  yCError(CONTROLBOARD, "Joint number %d out of bound [0-%zu] for part %s", j, controlledJoints, partName.c_str());
88  return false;
89  }
90  size_t subIndex = device.lut[j].deviceEntry;
91 
92  *min = 0.0;
93  *max = 0.0;
94 
95  SubDevice* p = device.getSubdevice(subIndex);
96  if (!p) {
97  return false;
98  }
99 
100  if (!p->lim) {
101  return false;
102  }
103  return p->lim->getVelLimits(static_cast<int>(off + p->base), min, max);
104 }
const yarp::os::LogComponent & CONTROLBOARD()
bool getLimits(int j, double *min, double *max) override
Get the software limits for a particular axis.
bool setLimits(int j, double min, double max) override
Set the software limits for a particular axis, the behavior of the control card when these limits are...
bool getVelLimits(int j, double *min, double *max) override
Get the software speed limits for a particular axis.
bool setVelLimits(int j, double min, double max) override
Set the software speed limits for a particular axis, the behavior of the control card when these limi...
yarp::dev::IControlLimits * lim
Definition: SubDevice.h:73
size_t base
Definition: SubDevice.h:55
std::vector< DevicesLutEntry > lut
Definition: SubDevice.h:122
SubDevice * getSubdevice(size_t i)
Definition: SubDevice.h:125
virtual bool getVelLimits(int axis, double *min, double *max)=0
Get the software speed limits for a particular axis.
virtual bool getLimits(int axis, double *min, double *max)=0
Get the software limits for a particular axis.
virtual bool setLimits(int axis, double min, double max)=0
Set the software limits for a particular axis, the behavior of the control card when these limits are...
virtual bool setVelLimits(int axis, double min, double max)=0
Set the software speed limits for a particular axis, the behavior of the control card when these limi...
#define yCError(component,...)
Definition: LogComponent.h:213