RoboDK Plug-In Interface
Loading...
Searching...
No Matches
joints.h
1/****************************************************************************
2**
3** Copyright (c) 2015-2026 RoboDK Global.
4** Contact: https://robodk.com/
5**
6** This file is part of the RoboDK API.
7**
8** Permission is hereby granted, free of charge, to any person obtaining a copy
9** of this software and associated documentation files (the "Software"), to deal
10** in the Software without restriction, including without limitation the rights
11** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12** copies of the Software, and to permit persons to whom the Software is
13** furnished to do so, subject to the following conditions:
14**
15** The above copyright notice and this permission notice shall be included in all
16** copies or substantial portions of the Software.
17**
18** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24** SOFTWARE.
25**
26** RoboDK is a registered trademark of RoboDK Global.
27**
28****************************************************************************/
29
30#ifndef ROBODK_JOINTS_H
31#define ROBODK_JOINTS_H
32
33
34#ifdef QT_GUI_LIB
35#include <QString>
36#else
37#error "This class cannot yet be used without the Qt Framework"
38#endif
39
40
41namespace robodk
42{
43
44namespace legacy
45{
46struct Matrix2D;
47}
48
50class Joints
51{
52public:
54 Joints();
55
58 explicit Joints(int ndofs);
59
63 Joints(const double* joints, int ndofs = 0);
64
68 Joints(const float* joints, int ndofs = 0);
69
72 Joints(const Joints& joints) = default;
73
74 Joints& operator=(const Joints& joints) = default;
75
80 Joints(const legacy::Matrix2D* mat2d, int column = 0, int ndofs = -1);
81
84 Joints(const QString& str);
85
86 ~Joints() = default;
87
90 const double* ValuesD() const;
91
94 const float* ValuesF() const;
95
96#ifdef ROBODK_API_FLOATS
99 const float* Values() const;
100#else
103 const double* Values() const;
104#endif
105
106
107 double Compare(const Joints &other) const;
108
111 double *Data();
112
115 int Length() const;
116
118 void setLength(int new_length);
119
123 bool Valid();
124
128 int GetValues(double *joints);
129
133 void SetValues(const double *joints, int ndofs = -1);
134
138 void SetValues(const float *joints, int ndofs = -1);
139
140#ifdef QT_GUI_LIB
142 inline operator QString() const { return ToString(); }
143
148 QString ToString(
149 const QString& separator = QLatin1String(", "),
150 int precision = 3) const;
151
155 bool FromString(const QString& str);
156#endif
157
158public:
159 static constexpr int MaximumJoints = 12;
160
163
165 double _joints[MaximumJoints];
166
168 mutable float _jointsFloat[MaximumJoints];
169};
170
171
172} // namespace robodk
173
174
175#endif // ROBODK_JOINTS_H
The Joints class represents a joint position of a robot (robot axes).
Definition joints.h:51
int GetValues(double *joints)
GetValues.
Definition joints.cpp:184
float _jointsFloat[MaximumJoints]
joint values (floats, used to return a copy as a float pointer)
Definition joints.h:168
int Length() const
Number of joint axes of the robot (or degrees of freedom)
Definition joints.cpp:140
double _joints[MaximumJoints]
joint values (doubles, used to store the joint values)
Definition joints.h:165
const double * Values() const
Joint values.
Definition joints.cpp:119
bool Valid()
Check if the joints are valid. For example, when we request the Inverse kinematics and there is no so...
Definition joints.cpp:153
Joints(const Joints &joints)=default
Create a copy of an object.
int _dofCount
number of degrees of freedom
Definition joints.h:162
double * Data()
Definition joints.cpp:135
const double * ValuesD() const
Joint values.
Definition joints.cpp:98
void setLength(int new_length)
Set the length of the array (only shrinking the array is allowed)
Definition joints.cpp:145
Joints()
Joints.
Definition joints.cpp:43
const float * ValuesF() const
Joint values.
Definition joints.cpp:103
void SetValues(const double *joints, int ndofs=-1)
Set the joint values in deg or mm. You can also important provide the number of degrees of freedom (6...
Definition joints.cpp:158
The Matrix2D struct represents a variable size 2D matrix.