YARP
Yet Another Robot Platform
ImplementAxisInfo.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 
8 
9 #include <cstdio>
10 using namespace yarp::dev;
11 
13 // Encoder Interface Timed Implementation
15 {
16  iinfo=y;
17  helper = nullptr;
18 }
19 
21 {
22  uninitialize();
23 }
24 
25 bool ImplementAxisInfo::initialize(int size, const int *amap)
26 {
27  if (helper != nullptr) {
28  return false;
29  }
30 
31  helper=(void *)(new ControlBoardHelper(size, amap));
32  yAssert (helper != nullptr);
33 
34  return true;
35 }
36 
42 {
43  if (helper!=nullptr)
44  {
45  delete castToMapper(helper);
46  helper=nullptr;
47  }
48 
49 
50 
51  return true;
52 }
53 
54 bool ImplementAxisInfo::getAxisName(int axis, std::string& name)
55 {
56  bool ret;
57  int k = castToMapper(helper)->toHw(axis);
58  ret = iinfo->getAxisNameRaw(k, name);
59  return ret;
60 }
61 
63 {
64  bool ret;
65  int k = castToMapper(helper)->toHw(axis);
66  ret = iinfo->getJointTypeRaw(k, type);
67  return ret;
68 }
69 
70 bool ret;
yarp::dev::ControlBoardHelper * castToMapper(void *p)
bool ret
#define yAssert(x)
Definition: Log.h:294
Interface for getting information about specific axes, if available.
Definition: IAxisInfo.h:66
virtual bool getAxisNameRaw(int axis, std::string &name)=0
virtual bool getJointTypeRaw(int axis, yarp::dev::JointTypeEnum &type)
Definition: IAxisInfo.h:85
bool getJointType(int axis, yarp::dev::JointTypeEnum &type) override
bool uninitialize()
Clean up internal data and memory.
bool initialize(int size, const int *amap)
Initialize the internal data and alloc memory.
ImplementAxisInfo(yarp::dev::IAxisInfoRaw *y)
bool getAxisName(int axis, std::string &name) override
An interface for the device drivers.