YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ImplementMotor.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
13#define JOINTIDCHECK if (m >= castToMapper(helper)->axes()){yError("motor id out of bound"); return false;}
14
16// Encoder Interface Timed Implementation
18 imotor(y),
19 helper(nullptr),
20 doubleBuffManager(nullptr)
21{ }
22
27
28bool ImplementMotor:: initialize (int size, const int *amap)
29{
30 if (helper != nullptr) {
31 return false;
32 }
33
34 helper=(void *)(new ControlBoardHelper(size, amap));
35 yAssert (helper != nullptr);
36
38 yAssert (doubleBuffManager != nullptr);
39
40 return true;
41}
42
48{
49 if (helper!=nullptr)
50 {
51 delete castToMapper(helper);
52 helper=nullptr;
53 }
54
56 {
57 delete doubleBuffManager;
58 doubleBuffManager=nullptr;
59 }
60
61 return true;
62}
63
65{
66 (*num)=castToMapper(helper)->axes();
67 return true;
68}
69
70bool ImplementMotor::getTemperature(int m, double* value)
71{
73 bool ret;
74 int k=castToMapper(helper)->toHw(m);
75
76 ret=imotor->getTemperatureRaw(k, value);
77
78 return ret;
79}
80
81bool ImplementMotor::getTemperatureLimit(int m, double* value)
82{
84 bool ret;
85 int k=castToMapper(helper)->toHw(m);
86
88
89 return ret;
90}
91
92bool ImplementMotor::setTemperatureLimit(int m, const double value)
93{
95 bool ret;
96 int k=castToMapper(helper)->toHw(m);
97
99
100 return ret;
101}
102
103bool ImplementMotor::getGearboxRatio(int m, double* value)
104{
106 bool ret;
107 int k = castToMapper(helper)->toHw(m);
108
109 ret = imotor->getGearboxRatioRaw(k, value);
110
111 return ret;
112}
113
114bool ImplementMotor::setGearboxRatio(int m, const double value)
115{
117 bool ret;
118 int k = castToMapper(helper)->toHw(m);
119
120 ret = imotor->setGearboxRatioRaw(k, value);
121
122 return ret;
123}
124
126{
128
129 bool ret = imotor->getTemperaturesRaw(buffValues.getData());
130 for (size_t i=0; i< buffValues.getSize(); i++)
131 {
132 int k = castToMapper(helper)->toHw(i);
133 v[i] = buffValues[k];
134 }
135 return ret;
136}
yarp::dev::ControlBoardHelper * castToMapper(void *p)
bool ret
#define JOINTIDCHECK
#define yAssert(x)
Definition Log.h:388
Control board, encoder interface.
Definition IMotor.h:24
virtual bool getTemperatureRaw(int m, double *val)=0
Get temperature of a motor.
virtual bool getTemperatureLimitRaw(int m, double *temp)=0
Retreives the current temperature limit for a specific motor.
virtual bool setGearboxRatioRaw(int m, const double val)
Set the gearbox ratio for a specific motor.
Definition IMotor.h:85
virtual bool getGearboxRatioRaw(int m, double *val)
Get the gearbox ratio for a specific motor.
Definition IMotor.h:77
virtual bool setTemperatureLimitRaw(int m, const double temp)=0
Set the temperature limit for a specific motor.
virtual bool getTemperaturesRaw(double *vals)=0
Get temperature of all the motors.
bool uninitialize()
Clean up internal data and memory.
ImplementMotor(yarp::dev::IMotorRaw *y)
yarp::dev::impl::FixedSizeBuffersManager< double > * doubleBuffManager
bool getTemperatureLimit(int m, double *val) override
Retreives the current temperature limit for a specific motor.
bool setTemperatureLimit(int m, const double val) override
Set the temperature limit for a specific motor.
bool getGearboxRatio(int m, double *val) override
Get the gearbox ratio for a specific motor.
bool getTemperatures(double *vals) override
Get temperature of all the motors.
bool initialize(int size, const int *amap)
Initialize the internal data and alloc memory.
bool setGearboxRatio(int m, const double val) override
Set the gearbox ratio for a specific motor.
bool getTemperature(int m, double *val) override
Get temperature of a motor.
bool getNumberOfMotors(int *num) override
Get the number of available motors.
Buffer contains info about a buffer of type T and it is used to exchange information with yarp::dev::...
T * getData()
Return the data pointer.
uint32_t getSize()
Return the number of element of buffer.
A manager of fixed size buffers in multi-thread environment.
Buffer< T > getBuffer()
Get a buffer and fill its information in @buffer.
For streams capable of holding different kinds of content, check what they actually have.
Definition jointData.cpp:13