YARP
Yet Another Robot Platform
ImplementAxisInfo.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 
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::ImplementAxisInfo::helper
void * helper
Definition: ImplementAxisInfo.h:24
yarp::dev::ImplementAxisInfo::iinfo
IAxisInfoRaw * iinfo
Definition: ImplementAxisInfo.h:23
yarp::dev::ControlBoardHelper::toHw
int toHw(int axis)
Definition: ControlBoardHelper.cpp:245
yarp::dev::ImplementAxisInfo::~ImplementAxisInfo
virtual ~ImplementAxisInfo()
Definition: ImplementAxisInfo.cpp:23
yarp::dev::ImplementAxisInfo::initialize
bool initialize(int size, const int *amap)
Initialize the internal data and alloc memory.
Definition: ImplementAxisInfo.cpp:28
ret
bool ret
Definition: ImplementAxisInfo.cpp:72
yarp::dev
An interface for the device drivers.
Definition: audioBufferSizeData.cpp:17
ImplementAxisInfo.h
ControlBoardHelper.h
yarp::dev::IAxisInfoRaw::getJointTypeRaw
virtual bool getJointTypeRaw(int axis, yarp::dev::JointTypeEnum &type)
Definition: IAxisInfo.h:88
yarp::dev::ImplementAxisInfo::getJointType
bool getJointType(int axis, yarp::dev::JointTypeEnum &type) override
Definition: ImplementAxisInfo.cpp:64
castToMapper
yarp::dev::ControlBoardHelper * castToMapper(void *p)
Definition: ControlBoardHelper.h:180
yarp::dev::IAxisInfoRaw
Interface for getting information about specific axes, if available.
Definition: IAxisInfo.h:69
yarp::dev::ControlBoardHelper
Definition: ControlBoardHelper.h:60
yarp::dev::ImplementAxisInfo::uninitialize
bool uninitialize()
Clean up internal data and memory.
Definition: ImplementAxisInfo.cpp:43
yarp::dev::IAxisInfoRaw::getAxisNameRaw
virtual bool getAxisNameRaw(int axis, std::string &name)=0
yAssert
#define yAssert(x)
Definition: Log.h:297
yarp::dev::ImplementAxisInfo::getAxisName
bool getAxisName(int axis, std::string &name) override
Definition: ImplementAxisInfo.cpp:56
yarp::dev::JointTypeEnum
JointTypeEnum
Definition: IAxisInfo.h:29
yarp::dev::ImplementAxisInfo::ImplementAxisInfo
ImplementAxisInfo(yarp::dev::IAxisInfoRaw *y)
Definition: ImplementAxisInfo.cpp:17