YARP
Yet Another Robot Platform
ImplementAxisInfo.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2021 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 
11 
12 #include <cstdio>
13 using namespace yarp::dev;
14 
16 // Encoder Interface Timed Implementation
18 {
19  iinfo=y;
20  helper = nullptr;
21 }
22 
24 {
25  uninitialize();
26 }
27 
28 bool ImplementAxisInfo::initialize(int size, const int *amap)
29 {
30  if (helper!=nullptr)
31  return false;
32 
33  helper=(void *)(new ControlBoardHelper(size, amap));
34  yAssert (helper != nullptr);
35 
36  return true;
37 }
38 
44 {
45  if (helper!=nullptr)
46  {
47  delete castToMapper(helper);
48  helper=nullptr;
49  }
50 
51 
52 
53  return true;
54 }
55 
56 bool ImplementAxisInfo::getAxisName(int axis, std::string& name)
57 {
58  bool ret;
59  int k = castToMapper(helper)->toHw(axis);
60  ret = iinfo->getAxisNameRaw(k, name);
61  return ret;
62 }
63 
65 {
66  bool ret;
67  int k = castToMapper(helper)->toHw(axis);
68  ret = iinfo->getJointTypeRaw(k, type);
69  return ret;
70 }
71 
72 bool ret;
yarp::dev::ControlBoardHelper * castToMapper(void *p)
bool ret
#define yAssert(x)
Definition: Log.h:297
Interface for getting information about specific axes, if available.
Definition: IAxisInfo.h:69
virtual bool getAxisNameRaw(int axis, std::string &name)=0
virtual bool getJointTypeRaw(int axis, yarp::dev::JointTypeEnum &type)
Definition: IAxisInfo.h:88
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.