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
9
10#include <cstdio>
11using namespace yarp::dev;
12using namespace yarp::os;
13#define JOINTIDCHECK if (j >= castToMapper(helper)->axes()){yError("joint id out of bound"); return false;}
14
16// Encoder Interface Timed Implementation
18 iEncoders(y),
19 helper(nullptr),
20 buffManager(nullptr)
21{;}
22
27
28bool ImplementEncodersTimed:: initialize (int size, const int *amap, const double *enc, const double *zos)
29{
30 if (helper != nullptr) {
31 return false;
32 }
33
34 helper=(void *)(new ControlBoardHelper(size, amap, enc, zos));
35 yAssert (helper != nullptr);
36
38 yAssert (buffManager != nullptr);
39 return true;
40}
41
47{
48 if (helper!=nullptr)
49 {
50 delete castToMapper(helper);
51 helper=nullptr;
52 }
53
54 if (buffManager!=nullptr)
55 {
56 delete buffManager;
57 buffManager=nullptr;
58 }
59 return true;
60}
61
63{
64 (*ax)=castToMapper(helper)->axes();
65 return true;
66}
67
76
81
83{
85 int k;
86 double enc;
87
88 castToMapper(helper)->posA2E(val, j, enc, k);
89
90 return iEncoders->setEncoderRaw(k, enc);
91}
92
101
103{
105 int k;
106 double enc;
107 bool ret;
108
110
112
114
115 return ret;
116}
117
126
128{
130 int k;
131 double enc;
132 bool ret;
133
135
137
139
140 return ret;
141}
142
151
153{
155 int k;
156 double enc;
157 bool ret;
158
160
162
164
165 return ret;
166}
167
176
177bool ImplementEncodersTimed::getEncoderTimed(int j, double *v, double *t)
178{
180 int k;
181 double enc;
182 bool ret;
183
185
187
189
190 return ret;
191}
192
193
yarp::dev::ControlBoardHelper * castToMapper(void *p)
bool ret
#define JOINTIDCHECK
#define yAssert(x)
Definition Log.h:388
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 bool getEncoderSpeedsRaw(double *spds)=0
Read the instantaneous acceleration of an axis.
virtual bool resetEncoderRaw(int j)=0
Reset encoder, single joint.
virtual bool setEncoderRaw(int j, double val)=0
Set the value of the encoder for a given joint.
virtual bool getEncoderSpeedRaw(int j, double *sp)=0
Read the instantaneous speed of an axis.
virtual bool getEncoderAccelerationsRaw(double *accs)=0
Read the instantaneous acceleration of all axes.
virtual bool getEncodersRaw(double *encs)=0
Read the position of all axes.
virtual bool getEncoderRaw(int j, double *v)=0
Read the value of an encoder.
virtual bool getEncoderAccelerationRaw(int j, double *spds)=0
Read the instantaneous acceleration of an axis.
virtual bool resetEncodersRaw()=0
Reset encoders.
virtual bool setEncodersRaw(const double *vals)=0
Set the value of all encoders.
Control board, extend encoder raw interface adding timestamps.
virtual bool getEncoderTimedRaw(int j, double *encs, double *stamp)=0
Read the instantaneous acceleration of all axes.
virtual bool getEncodersTimedRaw(double *encs, double *stamps)=0
Read the instantaneous acceleration of all axes.
ImplementEncodersTimed(yarp::dev::IEncodersTimedRaw *y)
bool getEncoder(int j, double *v) override
Read the value of an encoder.
bool getEncoderSpeed(int j, double *spds) override
Read the istantaneous speed of an axis.
bool initialize(int size, const int *amap, const double *enc, const double *zos)
Initialize the internal data and alloc memory.
bool getEncoderAcceleration(int j, double *spds) override
Read the instantaneous acceleration of an axis.
bool uninitialize()
Clean up internal data and memory.
bool setEncoders(const double *vals) override
Set the value of all encoders.
bool resetEncoders() override
Reset encoders.
bool setEncoder(int j, double val) override
Set the value of the encoder for a given joint.
bool getEncoderAccelerations(double *accs) override
Read the instantaneous acceleration of all axes.
bool getEncoderTimed(int j, double *v, double *t) override
Read the instantaneous acceleration of all axes.
bool resetEncoder(int j) override
Reset encoder, single joint.
bool getEncodersTimed(double *encs, double *time) override
Read the instantaneous acceleration of all axes.
yarp::dev::impl::FixedSizeBuffersManager< double > * buffManager
bool getEncoders(double *encs) override
Read the position of all axes.
bool getAxes(int *ax) override
Get the number of controlled axes.
bool getEncoderSpeeds(double *spds) override
Read the instantaneous speed of all axes.
Buffer contains info about a buffer of type T and it is used to exchange information with yarp::dev::...
A manager of fixed size buffers in multi-thread environment.
Buffer< T > getBuffer()
Get a buffer and fill its information in @buffer.
void releaseBuffer(Buffer< T > &buffer)
Release a buffer.
A mini-server for performing network communication in the background.
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.