YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
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
9
10#include <cstdio>
11using namespace yarp::dev;
12
13namespace {
14YARP_LOG_COMPONENT(IMPLEMENT_LAYER_COMPONENT, "yarp.ImplementAxisInfo")
15}
16
18// Encoder Interface Timed Implementation
24
29
30bool ImplementAxisInfo::initialize(int size, const int *amap)
31{
32 if (m_helper != nullptr) {
33 return false;
34 }
35
36 m_helper=(void *)(new ControlBoardHelper(size, amap));
37 yAssert (m_helper != nullptr);
38
39 m_buffer_ints.resize (size);
40 m_buffer_doubles.resize(size);
41
42 return true;
43}
44
50{
51 if (m_helper!=nullptr)
52 {
53 delete castToMapper(m_helper);
54 m_helper=nullptr;
55 }
56
57
58
59 return true;
60}
61
63{
64 std::lock_guard lock(m_imp_mutex);
65
67 (ax) = castToMapper(m_helper)->axes();
68 return ret;
69}
70
71ReturnValue ImplementAxisInfo::getAxisName(int axis, std::string& name)
72{
73 std::lock_guard lock(m_imp_mutex);
74 JOINTIDCHECK(IMPLEMENT_LAYER_COMPONENT,axis);
75
76 ReturnValue ret;
77 int k = castToMapper(m_helper)->toHw(axis);
78 ret = m_iraw->getAxisNameRaw(k, name);
79 return ret;
80}
81
83{
84 std::lock_guard lock(m_imp_mutex);
85 JOINTIDCHECK(IMPLEMENT_LAYER_COMPONENT,axis);
86
87 ReturnValue ret;
88 int k = castToMapper(m_helper)->toHw(axis);
89 ret = m_iraw->getJointTypeRaw(k, type);
90 return ret;
91}
yarp::dev::ControlBoardHelper * castToMapper(void *p)
#define yAssert(x)
Definition Log.h:388
#define ReturnValue_ok
Definition ReturnValue.h:82
Interface for getting information about specific axes, if available.
Definition IAxisInfo.h:73
virtual yarp::dev::ReturnValue getJointTypeRaw(int axis, yarp::dev::JointTypeEnum &type)
Definition IAxisInfo.h:100
virtual yarp::dev::ReturnValue getAxisNameRaw(int axis, std::string &name)=0
std::vector< double > m_buffer_doubles
bool uninitialize()
Clean up internal data and memory.
bool initialize(int size, const int *amap)
Initialize the internal data and alloc memory.
yarp::dev::ReturnValue getAxisName(int axis, std::string &name) override
ImplementAxisInfo(yarp::dev::IAxisInfoRaw *y)
yarp::dev::ReturnValue getJointType(int axis, yarp::dev::JointTypeEnum &type) override
yarp::dev::ReturnValue getAxes(size_t &ax) override
Get the number of controlled axes.
#define YARP_LOG_COMPONENT(name,...)
For streams capable of holding different kinds of content, check what they actually have.