YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ImplementVelocityControl.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
6#include <cstdio>
7
10#include <yarp/os/Log.h>
12
13using namespace yarp::dev;
14using namespace yarp::os;
15#define JOINTIDCHECK if (j >= castToMapper(helper)->axes()){yError("joint id out of bound"); return false;}
16
18 iVelocity(y),
19 helper(nullptr),
20 intBuffManager(nullptr),
21 doubleBuffManager(nullptr)
22{;}
23
28
29bool ImplementVelocityControl::initialize(int size, const int *axis_map, const double *enc, const double *zeros)
30{
31 if (helper != nullptr) {
32 return false;
33 }
34
35 helper=(void *)(new ControlBoardHelper(size, axis_map, enc, zeros));
36 yAssert (helper != nullptr);
37
39 yAssert (intBuffManager != nullptr);
40
42 yAssert (doubleBuffManager != nullptr);
43
44 return true;
45}
46
48{
49 if(helper != nullptr)
50 {
51 delete castToMapper(helper);
52 helper = nullptr;
53 }
54
56 {
57 delete intBuffManager;
58 intBuffManager=nullptr;
59 }
60
62 {
63 delete doubleBuffManager;
64 doubleBuffManager=nullptr;
65 }
66
67 return true;
68}
69
71{
72 (*ax)=castToMapper(helper)->axes();
73 return true;
74}
75
77{
79 int k;
80 double enc;
83}
84
105
114
115bool ImplementVelocityControl::getRefVelocity(const int j, double* vel)
116{
118 int k;
119 double tmp;
122 *vel=castToMapper(helper)->velE2A(tmp, k);
123 return ret;
124}
125
134
136{
137 if (!castToMapper(helper)->checkAxesIds(n_joint, joints)) {
138 return false;
139 }
140
143
144 for(int idx=0; idx<n_joint; idx++)
145 {
147 }
148
149 bool ret = iVelocity->getRefVelocitiesRaw(n_joint, buffJoints.getData(), buffValues.getData());
150
151 for(int idx=0; idx<n_joint; idx++)
152 {
154 }
155
158 return ret;
159}
160
162{
164 int k;
165 double enc;
168}
169
190
199
201{
203 int k;
204 double enc;
208 return ret;
209}
210
212{
213 if (!castToMapper(helper)->checkAxesIds(n_joint, joints)) {
214 return false;
215 }
216
219
220 for(int idx=0; idx<n_joint; idx++)
221 {
223 }
224
225 bool ret = iVelocity->getRefAccelerationsRaw(n_joint, buffJoints.getData(), buffValues.getData());
226
227 for(int idx=0; idx<n_joint; idx++)
228 {
230 }
231
234 return ret;
235}
236
237
246
247
249{
251 int k;
253 return iVelocity->stopRaw(k);
254}
255
256
258{
259 if (!castToMapper(helper)->checkAxesIds(n_joint, joints)) {
260 return false;
261 }
262
264 for(int idx=0; idx<n_joint; idx++)
265 {
267 }
268 bool ret = iVelocity->stopRaw(n_joint, buffJoints.getData());
270 return ret;
271}
272
273
275{
276 return iVelocity->stopRaw();
277}
yarp::dev::ControlBoardHelper * castToMapper(void *p)
bool ret
#define JOINTIDCHECK
#define yAssert(x)
Definition Log.h:388
void velE2A(double enc, int j, double &ang, int &k)
void velA2E(double ang, int j, double &enc, int &k)
void accA2E_abs(double ang, int j, double &enc, int &k)
void accE2A_abs(double enc, int j, double &ang, int &k)
Interface for control boards implementig velocity control in encoder coordinates.
virtual bool setRefAccelerationRaw(int j, double acc)=0
Set reference acceleration for a joint.
virtual bool stopRaw(int j)=0
Stop motion, single joint.
virtual bool velocityMoveRaw(int j, double sp)=0
Start motion at a given speed, single joint.
virtual bool setRefAccelerationsRaw(const double *accs)=0
Set reference acceleration on all joints.
virtual bool getRefVelocityRaw(const int joint, double *vel)
Get the last reference speed set by velocityMove for single joint.
virtual bool getRefVelocitiesRaw(double *vels)
Get the last reference speed set by velocityMove for all joints.
virtual bool getRefAccelerationRaw(int j, double *acc)=0
Get reference acceleration for a joint.
virtual bool getRefAccelerationsRaw(double *accs)=0
Get reference acceleration of all joints.
yarp::dev::impl::FixedSizeBuffersManager< int > * intBuffManager
yarp::dev::impl::FixedSizeBuffersManager< double > * doubleBuffManager
bool getRefAccelerations(double *accs) override
Get reference acceleration of all joints.
bool getRefAcceleration(int j, double *acc) override
Get reference acceleration for a joint.
ImplementVelocityControl(yarp::dev::IVelocityControlRaw *y)
Constructor.
bool uninitialize()
Clean up internal data and memory.
bool setRefAcceleration(int j, double acc) override
Set reference acceleration for a joint.
bool stop() override
Stop motion, multiple joints.
bool initialize(int size, const int *amap, const double *enc, const double *zos)
Initialize the internal data and alloc memory.
bool setRefAccelerations(const double *accs) override
Set reference acceleration on all joints.
bool getRefVelocity(const int joint, double *vel) override
Get the last reference speed set by velocityMove for single joint.
bool getRefVelocities(double *vels) override
Get the last reference speed set by velocityMove for all joints.
bool getAxes(int *axes) override
Get the number of controlled axes.
bool velocityMove(int j, double sp) override
Start motion at a given speed, single joint.
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.