RoboDK Plug-In Interface
Loading...
Searching...
No Matches
robodktypes.h
1#ifndef ROBODKTYPES_H
2#define ROBODKTYPES_H
3
4
5#include <QString>
6#include <QtGui/QMatrix4x4>
7#include <QDebug>
8
9#include "matrix4x4.h"
10#include "legacymatrix2d.h"
11#include "joints.h"
12
13
14#ifndef M_PI
15#define M_PI 3.14159265358979323846264338327950288
16#endif
17
18
19class IItem;
20class IRoboDK;
21typedef IItem* Item;
22typedef IRoboDK RoboDK;
23
24
25
26
28#define RDK_SIZE_JOINTS_MAX 12
29// IMPORTANT!! Do not change this value
30
32#define RDK_SIZE_MAX_CONFIG 4
33// IMPORTANT!! Do not change this value
34
35
40typedef double tXYZWPR[6];
41
43typedef double tXYZ[3];
44
45
60typedef double tConfig[RDK_SIZE_MAX_CONFIG];
61
62
63
65#define DOT(v,q) ((v)[0]*(q)[0] + (v)[1]*(q)[1] + (v)[2]*(q)[2])
66
68#define NORM(v) (sqrt((v)[0]*(v)[0] + (v)[1]*(v)[1] + (v)[2]*(v)[2]))
69
71#define NORMALIZE(inout){\
72 double norm;\
73 norm = sqrt((inout)[0]*(inout)[0] + (inout)[1]*(inout)[1] + (inout)[2]*(inout)[2]);\
74 (inout)[0] = (inout)[0]/norm;\
75 (inout)[1] = (inout)[1]/norm;\
76 (inout)[2] = (inout)[2]/norm;}
77
79#define CROSS(out,a,b) \
80 (out)[0] = (a)[1]*(b)[2] - (b)[1]*(a)[2]; \
81 (out)[1] = (a)[2]*(b)[0] - (b)[2]*(a)[0]; \
82 (out)[2] = (a)[0]*(b)[1] - (b)[0]*(a)[1];
83
85#define COPY3(out,in)\
86 (out)[0]=(in)[0];\
87 (out)[1]=(in)[1];\
88 (out)[2]=(in)[2];
89
91#define MULT_MAT(out,inA,inB)\
92 (out)[0] = (inA)[0]*(inB)[0] + (inA)[4]*(inB)[1] + (inA)[8]*(inB)[2];\
93 (out)[1] = (inA)[1]*(inB)[0] + (inA)[5]*(inB)[1] + (inA)[9]*(inB)[2];\
94 (out)[2] = (inA)[2]*(inB)[0] + (inA)[6]*(inB)[1] + (inA)[10]*(inB)[2];\
95 (out)[3] = 0;\
96 (out)[4] = (inA)[0]*(inB)[4] + (inA)[4]*(inB)[5] + (inA)[8]*(inB)[6];\
97 (out)[5] = (inA)[1]*(inB)[4] + (inA)[5]*(inB)[5] + (inA)[9]*(inB)[6];\
98 (out)[6] = (inA)[2]*(inB)[4] + (inA)[6]*(inB)[5] + (inA)[10]*(inB)[6];\
99 (out)[7] = 0;\
100 (out)[8] = (inA)[0]*(inB)[8] + (inA)[4]*(inB)[9] + (inA)[8]*(inB)[10];\
101 (out)[9] = (inA)[1]*(inB)[8] + (inA)[5]*(inB)[9] + (inA)[9]*(inB)[10];\
102 (out)[10] = (inA)[2]*(inB)[8] + (inA)[6]*(inB)[9] + (inA)[10]*(inB)[10];\
103 (out)[11] = 0;\
104 (out)[12] = (inA)[0]*(inB)[12] + (inA)[4]*(inB)[13] + (inA)[8]*(inB)[14] + (inA)[12];\
105 (out)[13] = (inA)[1]*(inB)[12] + (inA)[5]*(inB)[13] + (inA)[9]*(inB)[14] + (inA)[13];\
106 (out)[14] = (inA)[2]*(inB)[12] + (inA)[6]*(inB)[13] + (inA)[10]*(inB)[14] + (inA)[14];\
107 (out)[15] = 1;
108
110#define MULT_MAT_VECTOR(out,H,p)\
111 (out)[0] = (H)[0]*(p)[0] + (H)[4]*(p)[1] + (H)[8]*(p)[2];\
112 (out)[1] = (H)[1]*(p)[0] + (H)[5]*(p)[1] + (H)[9]*(p)[2];\
113 (out)[2] = (H)[2]*(p)[0] + (H)[6]*(p)[1] + (H)[10]*(p)[2];
114
116#define MULT_MAT_POINT(out,H,p)\
117 (out)[0] = (H)[0]*(p)[0] + (H)[4]*(p)[1] + (H)[8]*(p)[2] + (H)[12];\
118 (out)[1] = (H)[1]*(p)[0] + (H)[5]*(p)[1] + (H)[9]*(p)[2] + (H)[13];\
119 (out)[2] = (H)[2]*(p)[0] + (H)[6]*(p)[1] + (H)[10]*(p)[2] + (H)[14];
120
121
122
124struct tColor{
126 float r;
127
129 float g;
130
132 float b;
133
135 float a;
136};
137
138
139
141
149inline tMatrix2D* Matrix2D_Create()
150{
151 return robodk::legacy::Matrix2D_Create();
152}
153
161inline void Matrix2D_Delete(tMatrix2D** matrix)
162{
163 robodk::legacy::Matrix2D_Delete(matrix);
164}
165
175inline void Matrix2D_Set_Size(tMatrix2D* matrix, int rows, int columns)
176{
177 robodk::legacy::Matrix2D_SetDimensions(matrix, rows, columns);
178}
179
191inline int Matrix2D_Size(const tMatrix2D* matrix, int dimension)
192{
193 return robodk::legacy::Matrix2D_GetDimension(matrix, dimension);
194}
195
201inline int Matrix2D_Get_ncols(const tMatrix2D* matrix)
202{
203 return robodk::legacy::Matrix2D_ColumnCount(matrix);
204}
205
211inline int Matrix2D_Get_nrows(const tMatrix2D* matrix)
212{
213 return robodk::legacy::Matrix2D_RowCount(matrix);
214}
215
219inline double Matrix2D_Get_ij(const tMatrix2D* matrix, int row, int column)
220{
221 return robodk::legacy::Matrix2D_Get(matrix, row, column);
222}
223
227inline void Matrix2D_Set_ij(const tMatrix2D* matrix, int row, int column, double value)
228{
229 robodk::legacy::Matrix2D_Set(matrix, row, column, value);
230}
231
235inline double* Matrix2D_Get_col(const tMatrix2D* matrix, int column)
236{
237 return robodk::legacy::Matrix2D_GetColumn(matrix, column);
238}
239
247inline bool Matrix2D_Copy(const tMatrix2D* source, tMatrix2D* destination)
248{
249 return robodk::legacy::Matrix2D_Copy(source, destination);
250}
251
255inline void Debug_Array(const double* array, int size)
256{
257 robodk::legacy::Matrix2D_DebugArray(array, size);
258}
259
263inline void Debug_Matrix2D(const tMatrix2D* matrix)
264{
265 robodk::legacy::Matrix2D_Debug(matrix);
266}
267
273inline void Matrix2D_Save(QTextStream* stream, tMatrix2D* matrix, bool csv = false)
274{
275 robodk::legacy::Matrix2D_Save(stream, matrix, csv);
276}
277
281inline void Matrix2D_Save(QDataStream* stream, tMatrix2D* matrix)
282{
283 robodk::legacy::Matrix2D_Save(stream, matrix);
284}
285
289inline void Matrix2D_Load(QDataStream* stream, tMatrix2D** matrix)
290{
291 robodk::legacy::Matrix2D_Load(stream, matrix);
292}
293
294
295typedef robodk::Joints tJoints;
296typedef robodk::Matrix4x4 Mat;
297
298inline Mat transl(double x, double y, double z)
299{
300 return Mat::transl(x,y,z);
301}
302
303inline Mat rotx(double rx)
304{
305 return Mat::rotx(rx);
306}
307
308inline Mat roty(double ry)
309{
310 return Mat::roty(ry);
311}
312
313inline Mat rotz(double rz)
314{
315 return Mat::rotz(rz);
316}
317
318
319inline QDebug operator<<(QDebug dbg, const Mat &m)
320{
321 return dbg.noquote() << m.ToString();
322}
323
324inline QDebug operator<<(QDebug dbg, const tJoints &jnts)
325{
326 return dbg.noquote() << jnts.ToString();
327}
328
329inline QDebug operator<<(QDebug dbg, const Mat *m)
330{
331 return dbg.noquote() << (m == nullptr ? "Mat(null)" : m->ToString());
332}
333
334inline QDebug operator<<(QDebug dbg, const tJoints *jnts)
335{
336 return dbg.noquote() << (jnts == nullptr ? "tJoints(null)" : jnts->ToString());
337}
338
339
340#endif // ROBODKTYPES_H
The Item class represents an item in RoboDK station. An item can be a robot, a frame,...
Definition iitem.h:14
This class is the iterface to the RoboDK API. With the RoboDK API you can automate certain tasks and ...
Definition irobodk.h:14
The Joints class represents a joint position of a robot (robot axes).
Definition joints.h:51
The Matrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition matrix4x4.h:70
static Matrix4x4 transl(double x, double y, double z)
Constructs a matrix that translates coordinates by the components x, y, and z.
static Matrix4x4 rotx(double rx)
Constructs a matrix that rotates coordinates around X axis.
static Matrix4x4 rotz(double rz)
Constructs a matrix that rotates coordinates around Z axis.
static Matrix4x4 roty(double ry)
Constructs a matrix that rotates coordinates around Y axis.
The Matrix2D struct represents a variable size 2D matrix.
The Color struct represents an RGBA color (each color component should be in the range [0-1])
float r
Red color.
float a
Alpha value (0 = transparent; 1 = opaque)
float b
Blue color.
float g
Green color.