YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ImplementMotorEncoders.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
14#define JOINTIDCHECK if (m >= castToMapper(helper)->axes()){yError("motor id out of bound"); return false;}
15
17// Encoder Interface Timed Implementation
19 iMotorEncoders(y),
20 helper(nullptr),
21 buffManager(nullptr)
22{;}
23
28
29bool ImplementMotorEncoders:: initialize (int size, const int *amap, const double *enc, const double *zos)
30{
31 if (helper != nullptr) {
32 return false;
33 }
34
35 helper=(void *)(new ControlBoardHelper(size, amap, enc, zos));
36 yAssert (helper != nullptr);
37
39 yAssert (buffManager != nullptr);
40 return true;
41}
42
48{
49 if (helper!=nullptr)
50 {
51 delete castToMapper(helper);
52 helper=nullptr;
53 }
54
55 if(buffManager)
56 {
57 delete buffManager;
58 buffManager=nullptr;
59 }
60
61 return true;
62}
63
65{
66 (*num)=castToMapper(helper)->axes();
67 return true;
68}
69
78
83
84bool ImplementMotorEncoders::setMotorEncoder(int m, const double val)
85{
87 int k;
88 double enc;
89
90 castToMapper(helper)->posA2E(val, m, enc, k);
91
93}
94
105
115
125
127{
129 int k;
130 double enc;
131 bool ret;
132
134
136
138
139 return ret;
140}
141
150
152{
154 int k;
155 double enc;
156 bool ret;
157
159
161
163
164 return ret;
165}
166
175
177{
179 int k;
180 double enc;
181 bool ret;
182
184
186
188
189 return ret;
190}
191
200
201bool ImplementMotorEncoders::getMotorEncoderTimed(int m, double *v, double *t)
202{
204 int k;
205 double enc;
206 bool ret;
207
209
211
213
214 return ret;
215}
216
217
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)
Control board, encoder interface.
virtual bool setMotorEncoderCountsPerRevolutionRaw(int m, const double cpr)=0
Sets number of counts per revolution for motor encoder m.
virtual bool getMotorEncoderRaw(int m, double *v)=0
Read the value of a motor encoder.
virtual bool getMotorEncoderAccelerationsRaw(double *accs)=0
Read the instantaneous acceleration of all motor encoders.
virtual bool resetMotorEncodersRaw()=0
Reset motor encoders.
virtual bool getMotorEncoderCountsPerRevolutionRaw(int m, double *cpr)=0
Gets number of counts per revolution for motor encoder m.
virtual bool getMotorEncoderSpeedRaw(int m, double *sp)=0
Read the istantaneous speed of a motor encoder.
virtual bool getMotorEncodersTimedRaw(double *encs, double *stamps)=0
Read the instantaneous position of all motor encoders.
virtual bool getMotorEncodersRaw(double *encs)=0
Read the position of all motor encoders.
virtual bool getMotorEncoderSpeedsRaw(double *spds)=0
Read the instantaneous speed of all motor encoders.
virtual bool setMotorEncodersRaw(const double *vals)=0
Set the value of all motor encoders.
virtual bool setMotorEncoderRaw(int m, const double val)=0
Set the value of the motor encoder for a given motor.
virtual bool resetMotorEncoderRaw(int m)=0
Reset motor encoder, single motor.
virtual bool getMotorEncoderTimedRaw(int m, double *encs, double *stamp)=0
Read the instantaneous position of a motor encoder.
virtual bool getMotorEncoderAccelerationRaw(int m, double *spds)=0
Read the instantaneous acceleration of a motor encoder.
bool getMotorEncoderAccelerations(double *accs) override
Read the instantaneous acceleration of all motor encoders.
bool setMotorEncoderCountsPerRevolution(int m, const double cpr) override
Sets number of counts per revolution for motor encoder m.
ImplementMotorEncoders(yarp::dev::IMotorEncodersRaw *y)
bool getMotorEncodersTimed(double *encs, double *time) override
Read the instantaneous position of all motor encoders.
bool uninitialize()
Clean up internal data and memory.
bool getMotorEncoderSpeeds(double *spds) override
Read the instantaneous speed of all motor encoders.
bool getMotorEncoderTimed(int m, double *v, double *t) override
Read the instantaneous position of a motor encoder.
bool getMotorEncoder(int m, double *v) override
Read the value of a motor encoder.
bool getMotorEncoderSpeed(int m, double *spds) override
Read the istantaneous speed of a motor encoder.
bool setMotorEncoder(int m, const double val) override
Set the value of the motor encoder for a given motor.
yarp::dev::impl::FixedSizeBuffersManager< double > * buffManager
bool getMotorEncoderAcceleration(int m, double *spds) override
Read the instantaneous acceleration of a motor encoder.
bool setMotorEncoders(const double *vals) override
Set the value of all motor encoders.
bool getMotorEncoderCountsPerRevolution(int m, double *cpr) override
Gets number of counts per revolution for motor encoder m.
bool resetMotorEncoder(int m) override
Reset motor encoder, single motor.
bool resetMotorEncoders() override
Reset motor encoders.
bool getMotorEncoders(double *encs) override
Read the position of all motor encoders.
bool getNumberOfMotorEncoders(int *num) override
Get the number of available motor encoders.
bool initialize(int size, const int *amap, const double *enc, const double *zos)
Initialize the internal data and alloc memory.
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.