YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ImplementEncodersTimed.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
10
11#include <cstdio>
12using namespace yarp::dev;
13using namespace yarp::os;
14
15namespace {
16YARP_LOG_COMPONENT(IMPLEMENT_LAYER_COMPONENT, "yarp.ImplementEncodersTimed")
17}
18
19
21// Encoder Interface Timed Implementation
23 m_iraw(y),
24 m_helper(nullptr)
25{;}
26
31
32bool ImplementEncodersTimed:: initialize (int size, const int *amap, const double *enc, const double *zos)
33{
34 if (m_helper != nullptr) {
35 return false;
36 }
37
38 m_helper=(void *)(new ControlBoardHelper(size, amap, enc, zos));
39 yAssert (m_helper != nullptr);
40
41 m_buffer_doubles.resize(size);
42 m_buffer_doubles2.resize(size);
43 m_buffer_ints.resize(size);
44
45 return true;
46}
47
53{
54 if (m_helper!=nullptr)
55 {
56 delete castToMapper(m_helper);
57 m_helper=nullptr;
58 }
59
60 return true;
61}
62
64{
65 std::lock_guard lock(m_imp_mutex);
66
68 return ReturnValue_ok;
69}
70
81
83{
84 std::lock_guard lock(m_imp_mutex);
85
86 return m_iraw->resetEncodersRaw();
87}
88
90{
91 std::lock_guard lock(m_imp_mutex);
93
94 int k;
95 double enc;
96
97 castToMapper(m_helper)->posA2E(val, j, enc, k);
98
99 return m_iraw->setEncoderRaw(k, enc);
100}
101
103{
104 std::lock_guard lock(m_imp_mutex);
106
109
110 return ret;
111}
112
114{
115 std::lock_guard lock(m_imp_mutex);
118
119 int k;
120 double enc;
121 ReturnValue ret;
122
124
125 ret=m_iraw->getEncoderRaw(k, &enc);
126
128
129 return ret;
130}
131
133{
134 std::lock_guard lock(m_imp_mutex);
136
139
140 return ret;
141}
142
144{
145 std::lock_guard lock(m_imp_mutex);
148
149 int k;
150 double enc;
151 ReturnValue ret;
152
154
156
158
159 return ret;
160}
161
172
174{
175 std::lock_guard lock(m_imp_mutex);
178
179 int k;
180 double enc;
181 ReturnValue ret;
182
184
186
188
189 return ret;
190}
191
202
204{
205 std::lock_guard lock(m_imp_mutex);
209
210 int k;
211 double enc;
212 ReturnValue ret;
213
215
216 ret=m_iraw->getEncoderTimedRaw(k, &enc, t);
217
219
220 return ret;
221}
222
223
yarp::dev::ControlBoardHelper * castToMapper(void *p)
#define yAssert(x)
Definition Log.h:388
#define ReturnValue_ok
Definition ReturnValue.h:82
void accE2A(double enc, int j, double &ang, int &k)
void velE2A(double enc, int j, double &ang, int &k)
void posE2A(double enc, int j, double &ang, int &k)
void posA2E(double ang, int j, double &enc, int &k)
virtual yarp::dev::ReturnValue getEncoderSpeedsRaw(double *spds)=0
Read the instantaneous acceleration of an axis.
virtual yarp::dev::ReturnValue getEncodersRaw(double *encs)=0
Read the position of all axes.
virtual yarp::dev::ReturnValue getEncoderRaw(int j, double *v)=0
Read the value of an encoder.
virtual yarp::dev::ReturnValue setEncoderRaw(int j, double val)=0
Set the value of the encoder for a given joint.
virtual yarp::dev::ReturnValue getEncoderAccelerationsRaw(double *accs)=0
Read the instantaneous acceleration of all axes.
virtual yarp::dev::ReturnValue setEncodersRaw(const double *vals)=0
Set the value of all encoders.
virtual yarp::dev::ReturnValue getEncoderSpeedRaw(int j, double *sp)=0
Read the instantaneous speed of an axis.
virtual yarp::dev::ReturnValue getEncoderAccelerationRaw(int j, double *spds)=0
Read the instantaneous acceleration of an axis.
virtual yarp::dev::ReturnValue resetEncoderRaw(int j)=0
Reset encoder, single joint.
virtual yarp::dev::ReturnValue resetEncodersRaw()=0
Reset encoders.
Control board, extend encoder raw interface adding timestamps.
virtual yarp::dev::ReturnValue getEncoderTimedRaw(int j, double *encs, double *stamp)=0
Read the instantaneous acceleration of all axes.
virtual yarp::dev::ReturnValue getEncodersTimedRaw(double *encs, double *stamps)=0
Read the instantaneous acceleration of all axes.
ImplementEncodersTimed(yarp::dev::IEncodersTimedRaw *y)
yarp::dev::ReturnValue getEncoders(double *encs) override
Read the position of all axes.
bool initialize(int size, const int *amap, const double *enc, const double *zos)
Initialize the internal data and alloc memory.
yarp::dev::ReturnValue getEncoderSpeeds(double *spds) override
Read the instantaneous speed of all axes.
yarp::dev::ReturnValue resetEncoder(int j) override
Reset encoder, single joint.
bool uninitialize()
Clean up internal data and memory.
yarp::dev::ReturnValue getEncoderAcceleration(int j, double *spds) override
Read the instantaneous acceleration of an axis.
yarp::dev::ReturnValue getEncoderAccelerations(double *accs) override
Read the instantaneous acceleration of all axes.
yarp::dev::ReturnValue getEncoderSpeed(int j, double *spds) override
Read the istantaneous speed of an axis.
yarp::dev::ReturnValue setEncoders(const double *vals) override
Set the value of all encoders.
yarp::dev::ReturnValue getEncoderTimed(int j, double *v, double *t) override
Read the instantaneous acceleration of all axes.
yarp::dev::ReturnValue getEncoder(int j, double *v) override
Read the value of an encoder.
yarp::dev::ReturnValue resetEncoders() override
Reset encoders.
yarp::dev::ReturnValue setEncoder(int j, double val) override
Set the value of the encoder for a given joint.
yarp::dev::ReturnValue getEncodersTimed(double *encs, double *time) override
Read the instantaneous acceleration of all axes.
yarp::dev::ReturnValue getAxes(size_t &ax) override
Get the number of controlled axes.
A mini-server for performing network communication in the background.
#define YARP_LOG_COMPONENT(name,...)
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.
Definition OSTestMsg.cpp:13