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