The RMP Motion Controller APIs
cartesianrobot.h
1#pragma once
2#ifndef _CARTESIANROBOT_H
3#define _CARTESIANROBOT_H
4
5#include "rsi.h" // HAS_CARTESIAN_ROBOT defined in rsi.h
6#if defined(HAS_CARTESIAN_ROBOT)
7#include <cmath>
8
9
10// doxygen requires these stacked namespaces, you CANNOT use RSI::RapidCode::Cartesian {
11namespace RSI
12{
13namespace RapidCode
14{
15
17namespace Cartesian
18{
21
23 enum class PathState
24 {
26 Idle,
27 Moving,
28 Stopping,
29 };
30
31 constexpr double pi = 3.1415926535897932384626433832795028841971693993751;
32
34 enum class PathMode
35 {
36 Absolute,
37 Relative,
38 };
39
42 {
43 Clockwise,
45 };
46
48 enum class Plane
49 {
50 None,
51 XY,
52 XZ,
53 YZ,
54 };
55
57 enum class GCodeWorkOffset {
58 Machine = 0,
59 G54 = 54,
60 G55 = 55,
61 G56 = 56,
62 G57 = 57,
63 G58 = 58,
64 G59 = 59,
65 G92 = 92,
66 };
67
69 enum class LinearUnits
70 {
71 None,
73 Inches,
74 Feet,
76 Meters,
77
78 };
79
88 enum class CartesianAxis
89 {
90 X = 0,
91 Y = 1,
92 Z = 2,
93 Roll = 3,
94 Pitch = 4,
95 Yaw = 5,
96 };
97
99
100 class Gcode; // forward declaration
101
102 template<typename ContainerClass>
103 class RSI_API RapidVectorIterator
104 {
105 public:
107 typedef typename ContainerClass::ValueType ValueType;
108
110 typedef typename ContainerClass::PointerType PointerType;
111
114 ValueType& operator*();
115
118 const ValueType& operator*() const;
119
122 RapidVectorIterator& operator++();
123
126 RapidVectorIterator operator++(int);
127
130 bool operator==(const RapidVectorIterator&) const;
131
134 bool operator!=(const RapidVectorIterator&) const;
135
137 RapidVectorIterator(PointerType pointerArgument, PointerType startArgument, const size_t containerSize);
138
140 RapidVectorIterator(const RapidVectorIterator&) = default;
141
143 RapidVectorIterator& operator=(const RapidVectorIterator&) = default;
144
146 RapidVectorIterator(RapidVectorIterator&&) noexcept = default;
147
149 RapidVectorIterator& operator=(RapidVectorIterator&&) noexcept = default;
150 private:
151 PointerType pointer;
152 PointerType start, end;
153 void VerifyPointer() const;
154 };
155
157 template<typename Type>
159
162
170 template<typename Type>
171 class RSI_API RapidVector
172 {
173 private:
174 // The pointer to the implementation.
176 public:
180 Type& operator[](const size_t index);
181
185 const Type& operator[](const size_t index) const;
186
190 Type& At(const size_t index);
191
195 const Type& At(const size_t index) const;
196
199 void PushBack(const Type& element);
200
203 const size_t Size() const;
204
206 void Clear();
207
209 void PopBack();
210
213 Type& Front();
214
217 const Type& Front() const;
218
221 Type& Back();
222
225 const Type& Back() const;
226
229
231 RapidVector(const size_t size);
232
235
238
241
244
246 RapidVector(RapidVector&& other) noexcept;
247
250
251 typedef typename Type* PointerType;
252 typedef typename Type ValueType;
253
255 typedef typename RapidVectorIterator<RapidVector> Iterator;
256
259 Iterator begin() noexcept;
260
263 Iterator begin() const noexcept;
264
268 Iterator end() const noexcept;
269 };
270
272 class RSI_API Vector3d
273 {
274 public:
276 double X;
277
279 double Y;
280
282 double Z;
283
286
288 Vector3d(double x, double y, double z);
289
291 Vector3d(const Vector3d& rightHandSide);
292
294 double Dot(const Vector3d& rightHandSide) const;
295
300 Vector3d Cross(const Vector3d& rightHandSide) const;
301
303 Vector3d& Set(double x, double y, double z);
304
306 Vector3d& Set(const Vector3d& rightHandSide);
307
310 bool Equals(const Vector3d& rightHandSide, const double tolerance) const;
311
313 double SumSquares() const;
314
316 double Length() const;
317
320
323
325 Vector3d& operator=(const Vector3d& rightHandSide);
327 bool operator==(const Vector3d& rightHandSide) const;
329 bool operator!=(const Vector3d& rightHandSide) const;
331 Vector3d operator*(double scalar) const;
333 Vector3d& operator*=(double scalar);
335 Vector3d operator+(const Vector3d& rightHandSide) const;
337 Vector3d& operator+=(const Vector3d& rightHandSide);
339 Vector3d operator-(const Vector3d& rightHandSide) const;
343 Vector3d& operator-=(const Vector3d& rightHandSide);
345 Vector3d operator/(double scalar) const;
347 Vector3d& operator/=(double scalar);
350 };
351
353 class RSI_API Quaternion
354 {
355 public:
358
360 double W;
361
364
370 Quaternion(double w, double x, double y, double z);
371
374 Quaternion(const Quaternion& otherQuaternion);
375
379 Quaternion(double w, const Vector3d& v);
380
385 Quaternion(double x, double y, double z);
386
389 Quaternion(const Vector3d& rpy);
390
394 bool operator==(const Quaternion& rightHandSide) const;
395
399 bool operator!=(const Quaternion& rightHandSide) const;
400
404 Quaternion& operator=(const Quaternion& rightHandSide);
405
409 Quaternion operator+(const Quaternion& rightHandSide) const;
410
414 Quaternion& operator+=(const Quaternion& rightHandSide);
415
419 Quaternion operator-(const Quaternion& rightHandSide) const;
420
424 Quaternion& operator-=(const Quaternion& rightHandSide);
425
429 Quaternion operator*(const Quaternion& rightHandSide) const;
430
434 Quaternion operator*(double s) const;
435
440
444 Vector3d operator*(const Vector3d& rightHandSide) const;
445
449
453 double Dot(const Quaternion& rightHandSide) const;
454
458 Quaternion& Set(const Quaternion& otherQuaternion);
459
466 Quaternion& Set(double w, double x, double y, double z);
467
472 Quaternion& Set(double w, const Vector3d& vec);
473
480 Quaternion& Set(double x, double y, double z);
481
485 Quaternion& Set(const Vector3d& vec);
486
491 bool Equals(const Quaternion& rightHandSide, const double tolerance) const;
492
496
500
501
504 double SumSquares() const;
505
508 double Magnitude() const;
509
513
517
518
519
524 static Quaternion FromAngleAxis(double angle, const Vector3d& axis);
525
529 void ToAngleAxis(double& outAngle, Vector3d& outAxis) const;
530
534
535
542 static Quaternion FromMatrix(const double* const matrix);
543
544
550 void ToMatrix(double* matrix) const;
551 };
552
554 class RSI_API Pose {
555 public:
558
561
564
567 Pose(const Pose& pose);
568
572 Pose(const Vector3d position, const Quaternion& quaternion);
573
576 Pose(const Vector3d& position);
577
582 Pose(double x, double y, double z);
583
586 Pose(const Quaternion& quaternion);
587
592 bool Equals(const Pose& rightHandSide, double tolerance) const;
593
597 Pose Rotate(const Pose& rightHandSide) const;
598
602 Vector3d operator*(const Vector3d& rightHandSide) const;
603
607 Pose operator*(const Pose& rightHandSide) const;
608
611 Pose Inverse() const;
612 };
613
615 class RSI_API RobotPosition
616 {
617 public:
620
623
629 RobotPosition(const Cartesian::Pose& newPose, const size_t numberOfFreeAxes = 0);
631 RobotPosition(const Cartesian::Pose& newPose, const RapidVector<double>& freeAxes);
637 void AxisValueSet(uint32_t index, double value);
639 double AxisValueGet(uint32_t index) const;
640 };
641
643 class RSI_API KinematicModel
644 {
645 public:
646 virtual const char* const NameGet() const = 0;
647 virtual uint32_t AxisCountGet() const = 0;
648
649 virtual LinearUnits UnitsGet() const = 0;
650
651 virtual bool IsConfigured() const = 0;
652
653 virtual const char* const* const ExpectedAxisNamesGet() const = 0;
654 virtual uint32_t ExpectedAxisNamesCountGet() const = 0;
655
656 // input function
657 // inputPose requires this to be in robot centric coordinates.
658 // remove tool offset and robot base offset
659 virtual bool InverseKinematicsSolve(const Pose& inputPose, void* outputPointerSolutionVector) const = 0;
660
661 virtual bool InverseKinematicsSolve(const RobotPosition& inputPosition, void* vpSols) const = 0;
662
663 // ouput function
664 // inputJointPositions requires this to be in robot centric coordinates.
665 // apply tool offset and robot base offset
666 virtual void ForwardKinematicsSolve(const double* inputJointPositions, Pose& outputPose) const = 0;
667
668 virtual void ForwardKinematicsSolve(const double* inputJointPositions, RobotPosition& outputPosition) const = 0;
669
670 };
671
673 struct RSI_API ModelAxisMapping
674 {
675
676 public:
680
682 double Scaling;
683 static constexpr double DefaultScaling = 1.0;
684
686 double Offset;
687 static constexpr double DefaultOffset = 0.0;
688
690 static constexpr int MaxLabelSize = 16;
691 static constexpr int ExpectedLabelBufferSize = MaxLabelSize + 1;
692
696 char ExpectedLabel[ExpectedLabelBufferSize];
697
699 ModelAxisMapping(int jointIndex);
700
702 ModelAxisMapping(int jointIndex, double scaling, double offset, const char* const label);
703
704 // ModelAxisMapping Destructor.
705 virtual ~ModelAxisMapping() = default;
706 };
707
713 {
714 private:
715 struct Storage;
716 Storage* storage;
717
718 protected:
723 KinematicModelBuilder(const char* const label);
724
725 // Protect the copy constructor, for internal use only.
727
728
729 class ProtectedAccessor;
730 // Provide derived classes with protected access to certain members.
731 ProtectedAccessor ProtectedAccessGet();
732
733 public:
734 virtual ~KinematicModelBuilder();
735
736 // Delete the copy-assignment constructor.
737 KinematicModelBuilder& operator=(const KinematicModelBuilder&) = delete;
738
739 // Move constructors
741 KinematicModelBuilder& operator=(KinematicModelBuilder&&) noexcept;
742
747 virtual const KinematicModel& ModelBuild() = 0;
748
752 const KinematicModel& ModelGet();
753
756 void UnitsSet(LinearUnits units);
757
760 LinearUnits UnitsGet() const;
761
764 void LabelSet(const char* const label);
765
768 const char* const LabelGet() const;
769
771 void TransformFromKinematicOriginToRobotOriginSet(const Pose& KinematicOriginToRobotOrigin);
772
774 Pose TransformFromKinematicOriginToRobotOriginGet() const;
775
777 void FreeAxisAdd(const ModelAxisMapping& freeAxis);
778 };
779
794 struct RSI_API LinearJointMapping : public ModelAxisMapping
795 {
796 public:
800
801 LinearJointMapping(int jointIndex, CartesianAxis cartesianCoordinate);
802 LinearJointMapping(int jointIndex, CartesianAxis cartesianCoordinate, double scaling, double offset, const char* const label);
803 };
804
808 {
809 struct Storage;
810 Storage* storage;
811
812 public:
813
818 const KinematicModel& ModelBuild() override;
819
821 void JointAdd(const LinearJointMapping& joint);
822
825 LinearModelBuilder(const char* const label);
827
828 // Move constructors
829 LinearModelBuilder(LinearModelBuilder&& other) noexcept;
830 LinearModelBuilder& operator=(LinearModelBuilder&&) noexcept;
831
832 // Disable copy constructors
833 LinearModelBuilder(const LinearModelBuilder&) = delete;
834 LinearModelBuilder& operator=(const LinearModelBuilder&) = delete;
835 };
836
837 // UNSUPPORTED
838 class RSI_API ArticulatedModelBuilder : public KinematicModelBuilder
839 {
840 struct Storage;
841 Storage* storage;
842
843 public:
844 const KinematicModel& ModelBuild() override;
845 ArticulatedModelBuilder();
846 ~ArticulatedModelBuilder();
847
848 };
849
868 int32_t LineNumber;
869
874 const char* LineText;
875
885 };
886
899 class RSI_API GcodeCallback
900 {
901 public:
914 virtual void Execute(GcodeCallbackData* data) {};
915
916 virtual ~GcodeCallback() = default; // Virtual destructor for C++ base classes
917 };
918
922 class RSI_API Robot : public virtual RapidCodeObject
923 {
924 public:
925
930
944 static Robot* RobotCreate(MotionController* controller, MultiAxis* multiAxis, KinematicModelBuilder* builder, uint32_t motionFrameBufferSize);
945
950 static Robot* RobotCreate(MotionController* controller, MultiAxis* multiAxis, const char* const modelIdentifier);
951
956 static Robot* RobotCreate(MotionController* controller, MultiAxis* multiAxis, const char* const modelIdentifier, uint32_t motionFrameBufferSize);
957
959 static void RobotDelete(MotionController* controller, Robot* robot);
960
962
963
968
970 static constexpr uint64_t TimeoutForever = 0xFFFFFFFFFFFFFFFF;
971
976 static constexpr uint32_t MotionFrameBufferSizeDefault = 256;
977
982 static constexpr uint32_t MotionFrameBufferSizeMinimum = 50;
984
985
990
995 virtual PathState PathStateGet() = 0;
996
1001 virtual bool PathStateWait(PathState stateWaitFor, uint64_t timeoutMilliseconds) = 0;
1002
1007 virtual bool PathStateWaitChange(PathState stateWaitChange, uint64_t timeoutMilliseconds) = 0;
1008
1009
1014 virtual uint64_t MotionCounterGet() = 0;
1015
1020 virtual bool MotionCounterWait(uint64_t motionWaitFor, uint64_t timeoutMilliseconds) = 0;
1021
1026 virtual bool MotionCounterWaitChange(uint64_t motionWaitChange, uint64_t timeoutMilliseconds) = 0;
1027
1028
1029
1033 virtual bool IsRunning() = 0;
1034
1038 virtual bool PathIsRunning() = 0;
1039
1046 virtual bool MotionDoneGet() = 0;
1047
1054 virtual uint64_t MotionDoneWait() = 0;
1055
1063 virtual uint64_t MotionDoneWait(uint64_t timeoutMilliseconds) = 0;
1064
1070 virtual bool HasError() = 0;
1071
1076 virtual const char* const ErrorMessageGet() = 0;
1077
1079
1080
1084
1087 virtual void Resume() = 0;
1088
1091 virtual void Stop() = 0;
1092
1095 virtual void EStopAbort() = 0;
1096
1099 virtual void Abort() = 0;
1100
1104 virtual void AmpEnableSet(bool enable, int32_t ampActiveTimeoutMilliseconds) = 0;
1105
1112 virtual void EStop() = 0;
1113
1115 virtual void ClearFaults() = 0;
1116
1117
1118
1122
1128 virtual Pose ActualPoseGet() = 0;
1129
1136
1137
1144 virtual Pose ActualPoseGet(LinearUnits units) = 0;
1145
1153
1154
1160 virtual Pose CommandPoseGet() = 0;
1161
1168
1174 virtual Pose CommandPoseGet(LinearUnits units) = 0;
1175
1182
1188
1194
1200
1206
1212 virtual Pose ForwardKinematics(const RapidVector<double>& joints) = 0;
1213
1220
1224
1227 virtual const KinematicModel& ModelGet() = 0;
1228
1232 virtual void EndEffectorTransformSet(const Pose& transform) = 0;
1233
1237 virtual void OriginTransformSet(const Pose& transform) = 0;
1238
1241 virtual const Pose& EndEffectorTransformGet() = 0;
1242
1245 virtual const Pose& OriginTransformGet() = 0;
1246
1247
1252 virtual const double ScaleFactorBetweenUnitsGet(LinearUnits from, LinearUnits to) = 0;
1253
1254
1258
1267 virtual void MoveAbsolute(const Pose& absolutePose) = 0;
1268
1269
1279 virtual void MoveRelative(const Pose& relativePose) = 0;
1280
1281
1286
1290 virtual void PathClear() = 0;
1291
1296 virtual void PathVelocitySet(double unitsPerSecond) = 0;
1297
1302 virtual double PathVelocityGet() = 0;
1303
1308 virtual void PathAccelerationSet(double unitsPerSecondSquared) = 0;
1309
1313
1315 virtual double PathAccelerationGet() = 0;
1316
1323 virtual void PathProgrammingModeSet(PathMode mode) = 0;
1324
1331
1338 virtual void PathArc(const Pose& target, double radius, RotationDirection direction) = 0;
1339
1346 virtual void PathArc(const RobotPosition& target, double radius, RotationDirection direction) = 0;
1347
1352 virtual void PathArc(const Pose& target, const Vector3d& center, RotationDirection direction) = 0;
1353
1358 virtual void PathArc(const RobotPosition& RobotPosition, const Vector3d& center, RotationDirection direction) = 0;
1359
1360
1361 // @brief Appends a line on the current path
1365 virtual void PathLine(const Pose& target) = 0;
1366
1367 // @brief Appends a line on the current path
1371 virtual void PathLine(const RobotPosition& position) = 0;
1372
1376 virtual void PathPlaneSet(Plane plane) = 0;
1377
1381 virtual Plane PathPlaneGet() = 0;
1382
1388 virtual void PathLinearScalingSet(double scaleFactor) = 0;
1389
1396 virtual double PathLinearScalingGet()const = 0;
1397
1402 virtual void PathUnitsSet(LinearUnits units) = 0;
1403
1407 virtual LinearUnits PathUnitsGet()const = 0;
1408
1409
1413 virtual double PathProcessLoadedMoves() = 0;
1414
1425 virtual RapidVector<RobotPosition> PathPlannedPositionsGet(uint64_t startFrame, uint64_t frameCount) = 0;
1426
1431 virtual double PathDurationGet() = 0;
1432
1438 virtual void Run() = 0;
1439
1456 virtual uint32_t MotionFrameBufferSizeGet()=0;
1457
1459
1462
1463 };
1464
1468 class RSI_API Gcode : public virtual RapidCodeObject
1469 {
1470 public:
1471 virtual bool Load(const char* const text) = 0;
1472 virtual bool LoadFile(const char* const file) = 0;
1477 virtual void ReloadLines(int32_t start = 0, int32_t end = -1) = 0;
1478
1481 virtual int32_t LineCountGet() = 0;
1486
1487 virtual const char* const ProgramGet() = 0;
1495 virtual int32_t SyntaxErrorLineNumberGet() = 0;
1496
1504 virtual const char* const LineTextGet(uint32_t lineNumber) = 0;
1505
1510 virtual void FeedRateSet(double programmingUnitsPerMinute) = 0;
1511
1518 virtual double FeedRateGet() = 0;
1519
1524 virtual void AccelerationRateSet(double programmingUnitsPerMinuteSquared) = 0;
1525
1531 virtual double AccelerationRateGet() = 0;
1532
1538 virtual void Run() = 0;
1539
1544 virtual double DurationGet() = 0;
1545
1557 virtual void Cancel() = 0;
1558
1570 virtual uint64_t DoneWait(uint64_t timeoutMilliseconds) = 0;
1571
1577 virtual RapidVector<RobotPosition> PlannedPositionsGet(uint64_t startFrame, uint64_t frameCount) = 0;
1578
1586 virtual void UnitsSet(LinearUnits units) = 0;
1587
1594 virtual LinearUnits UnitsGet() = 0;
1595
1602 virtual void WorkOffsetConfigure(GCodeWorkOffset workOffset, Vector3d offsetValues) = 0;
1603
1609 virtual void ActiveWorkOffsetSelect(GCodeWorkOffset workOffset) = 0;
1610
1617
1623 virtual const Pose& ActiveWorkOffsetValuesGet() = 0;
1624
1626 virtual bool IsRunning() = 0;
1627
1630 virtual int32_t ExecutingLineNumberGet() = 0;
1631
1635 virtual void FreeAxisLetterSet(const char gcodeLetter, const int freeAxisIndex) = 0;
1636
1638 virtual void CallbackRegister(Cartesian::GcodeCallback* callback) = 0;
1639 };
1640
1642
1643} // Cartesian namespace
1644} // RapidCode namespace
1645} // RSI namespace
1646
1647#endif // defined(HAS_CARTESIAN_ROBOT)
1648#endif // _CARTESIANROBOT_H
void Cancel()=0
Cancel the currently running G-code program.
void ReloadLines(int32_t start=0, int32_t end=-1)=0
Reloads the lines from the last call to GcodeStringLoad() but only between start line and end of file...
uint64_t DoneWait(uint64_t timeoutMilliseconds)=0
Wait for the completion of G-code program execution with a timeout.
const char *const LineTextGet(uint32_t lineNumber)=0
Gives you the text of a specific line from the last loaded program excluding all comments and with on...
GCodeWorkOffset ActiveWorkOffsetGet()=0
Gets the enum representing the location where the current offset is saved.
void ActiveWorkOffsetSelect(GCodeWorkOffset workOffset)=0
Apply the offset saved under the specified location.
int32_t LineCountGet()=0
Get the number of lines in the last loaded G-Code program.
int32_t SyntaxErrorLineNumberGet()=0
Gets the line number of any errors in the G-Code syntax.
const char *const ProgramGet()=0
Gets the raw file contents of the last loaded program.
int32_t ExecutingLineNumberGet()=0
Get the currently executing line number.
const Pose & ActiveWorkOffsetValuesGet()=0
Gets the actual values of the currently applied offset.
LinearUnits UnitsGet()=0
Get the currently active unit as set by G20/G21.
void AccelerationRateSet(double programmingUnitsPerMinuteSquared)=0
Sets the target acceleration for the machine (units/minute^2). Should be set apprpriately based on yo...
double AccelerationRateGet()=0
Gets the target acceleration for the machine (GcodeUnitsGet()/minute^2).
void UnitsSet(LinearUnits units)=0
Set the currently active unit (same as calling G20/G21)
double DurationGet()=0
Get the time duration required to run the loaded G-Code program in seconds.
RapidVector< RobotPosition > PlannedPositionsGet(uint64_t startFrame, uint64_t frameCount)=0
Get RobotPositions representing the planned G-Code motion in cartesian space that will happen when ru...
double FeedRateGet()=0
Gets the target feed rate for the machine (GcodeUnitsGet()/minute).
void FreeAxisLetterSet(const char gcodeLetter, const int freeAxisIndex)=0
Map a letter in a Gcode file to a free axis. It will be used to specify the free axis' motion.
void WorkOffsetConfigure(GCodeWorkOffset workOffset, Vector3d offsetValues)=0
Save an XYZ offset to be used with specified G-Code work offset.
void FeedRateSet(double programmingUnitsPerMinute)=0
Sets the target feed rate for the machine (units/minute).
void Run()=0
Run the loaded G-Code file (or string). The behavior is non-blocking. Use Robot.MotionDoneWait() to b...
void Execute(GcodeCallbackData *data)
Executes the M-code callback.
Handles callbacks for M-codes within a G-code file.
Represents a G-code program executor. This class provides an interface to load and run G-code program...
void CallbackRegister(Cartesian::GcodeCallback *callback)=0
G-code callback register.
bool IsRunning()=0
Returns true if a Gcode program is executing, false otherwise.
The abstract class for Kinematic Model builders. Constructs a single Kinematic Model to use when crea...
KinematicModelBuilder(const char *const label)
The KinematicModelBuilder constructor is protected so that only derived classes can use it....
Describes the mathematical kinematic model of a robot.
const KinematicModel & ModelBuild() override
Construct the model using the information the builder currently has. The builder will maintain a refe...
LinearModelBuilder(const char *const label)
constructs a LinearModelBuilder instance.
The Builder for a linear kinematic model. Constructs a single Linear Kinematic Model to use when crea...
void JointAdd(const LinearJointMapping &joint)
adds a joint to the model using the configuration specified within the LinearJoint structure.
Pose operator*(const Pose &rightHandSide) const
Transforms rightHandSide by this. Rotates rightHandSide.position by this, adds this....
Vector3d operator*(const Vector3d &rightHandSide) const
Transforms rightHandSide by this. Rotates rightHandSide by this, and adds this.position to it.
Pose Inverse() const
Returns an inverted copy of this. this * this.inverse() = I.
Pose(const Pose &pose)
Constructor from an existing Pose.
Pose(const Quaternion &quaternion)
Constructor.
Pose Rotate(const Pose &rightHandSide) const
Rotates rightHandSide by the rotation component of this (ONLY the rotation component)
bool Equals(const Pose &rightHandSide, double tolerance) const
Approximate equality check. Checks whether all components are within the tolerance of each other.
Pose(const Vector3d position, const Quaternion &quaternion)
Constructor.
Pose(const Vector3d &position)
Constructor from an existing position Vector3d.
Pose(double x, double y, double z)
Constructor from X,Y,Z with an identity "no rotation" default Quaternion.
Vector3d Position
The position component of the Pose.
Quaternion Orientation
The orientation component of the Pose.
Pose()
Default constructor. Vector(0,0,0) Quaterion(1,0,0,0)
Vector3d operator*(const Vector3d &rightHandSide) const
Multiplication (vector rotation) operator. Rotates vector by this.
Quaternion & operator-=(const Quaternion &rightHandSide)
Subtraction assignment. Subtracts other from this. See operator-.
Quaternion & operator+=(const Quaternion &rightHandSide)
Addition assignment. Adds rightHandSide into this. See operator+.
Quaternion & Set(double w, const Vector3d &vec)
Assigns other into this.
Quaternion operator+(const Quaternion &rightHandSide) const
Adds two quaternions together. this.w + rightHandSide.w, this.v+rightHandSide.v.
Quaternion & operator=(const Quaternion &rightHandSide)
Assignment operator. Copies underlying.
Quaternion(double x, double y, double z)
Euler constructor.
Quaternion & operator*=(double s)
Multiplication (scalar) assignment operator. See operator*(double)
Quaternion Conjugate() const
Negates the imaginary component of the Quaternion.
Quaternion Inverse() const
Conjugate scaled by 1 / SumSquares()
Quaternion operator-(const Quaternion &rightHandSide) const
Subtraction operator. this.w - rightHandSide.w, this.v-rightHandSide.v.
Quaternion operator-() const
Negates this quaternion (w, and v)
Quaternion Normalized() const
Retunrs a normalized copy of this.
void ToAngleAxis(double &outAngle, Vector3d &outAxis) const
Gets the axis angle representation of this quaternion.
Quaternion & Set(const Quaternion &otherQuaternion)
Assigns other into this.
Quaternion & Set(double x, double y, double z)
Assigns the quaternion defined by the Euler angles into this. If you get unexpected values,...
bool operator==(const Quaternion &rightHandSide) const
Exact equality check. See equals for approximately equal to.
double Magnitude() const
Gets the magnitude of this. sqrt(SumSquares())
Vector3d ToEuler() const
Gets the Euler Angle representation of this quaternion.
Quaternion operator*(double s) const
Multiplication (scalar) operator. w*s, v*s.
static Quaternion FromAngleAxis(double angle, const Vector3d &axis)
Creates a quaternion from an axis angle representation.
Quaternion operator*(const Quaternion &rightHandSide) const
Multiplication (rotation) operator. Rotates other by this.
Quaternion(double w, const Vector3d &v)
Constructor.
bool operator!=(const Quaternion &rightHandSide) const
Exact inequality check. See equals for approximately equal to.
Quaternion(const Vector3d &rpy)
Euler Constructor (Alternate)
Quaternion & Normalize()
Normalizes this. Scales each component by 1 / magnitude.
Quaternion(const Quaternion &otherQuaternion)
Constructor.
double SumSquares() const
Gets the sum of the components squared (w*w+this.dot(this))
Quaternion(double w, double x, double y, double z)
Constructor.
double Dot(const Quaternion &rightHandSide) const
Returns the dot product of each element. w*rightHandSide.w+v.dot(rightHandSide.v)
Quaternion & Set(double w, double x, double y, double z)
Assigns each component into this.
Quaternion & Set(const Vector3d &vec)
Assigns the quaternion defined by the Euler Angles into this.
bool Equals(const Quaternion &rightHandSide, const double tolerance) const
Equality check within tolerance.
void ToMatrix(double *matrix) const
Quaternion To Matrix.
static Quaternion FromMatrix(const double *const matrix)
Matrix to Quaternion.
Quaternion for representing rotations.
double W
W (real component) of Quaternion. Do not modify this unless you know what you are doing.
Quaternion()
Default Constructor. W=1, X=Y=Z=0.
Vector3d V
Vector3d (imaginary) component of Quaternion. 1->x, 2->y, 3->z. Do not modify this unless you know wh...
const size_t Size() const
Returns the number of elements in the vector.
const Type & operator[](const size_t index) const
Returns a const reference to the element at the location specified by the index.
const Type & Back() const
Returns a const reference to the last element in the vector.
Iterator begin() noexcept
Returns a RapidVectorIterator to the first element of the vector. The naming convention follows STL c...
Type & Front()
Returns a reference to the first element in the vector.
const Type & Front() const
Returns a const reference to the first element in the vector.
const Type & At(const size_t index) const
Returns a const reference to the element at the location specified by the index.
void PushBack(const Type &element)
Appends the given element to the end of the vector.
Type & Back()
Returns a reference to the last element in the vector.
Type & operator[](const size_t index)
Returns a reference to the element at the location specified by the index.
Type & At(const size_t index)
Returns a reference to the element at the location specified by the index.
A wrapper class for the C++ STL vector class that aims to maintain application binary interface....
RapidVector(RapidVector &&other) noexcept
Move constructor. Replaces contents with those of the other RapidVector.
RapidVectorIterator< RapidVector > Iterator
The iterator type for this RapidVector.
~RapidVector()
Destructs the vector and deallocates used storage.
RapidVector & operator=(const RapidVector &other)
Copy assignment operator. Replaces contents with the contents of the other RapidVector.
RapidVector(const RapidVector &other)
Copy constructor. Constructs a RapidVector as a deep-copy.
RapidVector(RapidVectorImplementation< Type > *)
Constructs a RapidVector with the given implementation. Intended for RSI internal use only.
void Clear()
Erases all elements from the vector.
void PopBack()
Removes the last element from the container. Calling PopBack() on an empty container results in undef...
RapidVector(const size_t size)
Constructs a vector with the specified size.
RapidVector & operator=(RapidVector &&other) noexcept
Move assignment operator. Replaces contents with those of the other RapidVector. The original content...
RapidVector()
Default constructor that constructs an empty vector.
Forward declaration of the implementation class for RapidVector.
RapidVector< double > JointsActualPositionsGet()=0
Get the actual positions of the axes in the underlying MultiAxis.
const Pose & EndEffectorTransformGet()=0
End of Robot to TCP.
bool MotionDoneGet()=0
Check to see if motion is done and settled.
double PathAccelerationGet()=0
Gets the target acceleration for the machine (UserUnits/second^2).
bool PathStateWait(PathState stateWaitFor, uint64_t timeoutMilliseconds)=0
Waits for a specific path state.
void OriginTransformSet(const Pose &transform)=0
Transform that defines the origin of the robot in the world. For example if you have a gantry that is...
bool PathStateWaitChange(PathState stateWaitChange, uint64_t timeoutMilliseconds)=0
Waits for the path state to not be the specified state.
RobotPosition ActualPositionGet()=0
Get the current actual position of the robot from the trajectory executor, in the Robot model's units...
void PathArc(const RobotPosition &target, double radius, RotationDirection direction)=0
Appends an arc on to the current on the PathPlaneGet() plane XY by default.
uint64_t MotionDoneWait()=0
Waits for a move to complete.
void Stop()=0
Stop an axis.
Pose CommandPoseGet(LinearUnits units)=0
Get the current commanded pose of the robot from the trajectory executor in the specified units.
double PathVelocityGet()=0
Gets the target velocity for the machine (UserUnits/second).
Pose CommandPoseGet()=0
Get the current commanded pose of the robot from the trajectory executor, in the Robot model's units.
RapidVector< RobotPosition > PathPlannedPositionsGet(uint64_t startFrame, uint64_t frameCount)=0
Get Positions (see RobotPosition) representing the planned motion in cartesian space that will happen...
uint32_t MotionFrameBufferSizeGet()=0
Gets the TrajectoryExecutor's buffer size in frames, one frame is used per RMP sample period.
void PathLine(const RobotPosition &position)=0
static Robot * RobotCreate(MotionController *controller, MultiAxis *multiAxis, const char *const modelIdentifier, uint32_t motionFrameBufferSize)
void PathVelocitySet(double unitsPerSecond)=0
Sets the target linear cartesian velocity for each move (UserUnits/second).
Plane PathPlaneGet()=0
Gets the plane some arcs will be forced to be on.
const char *const ErrorMessageGet()=0
Get the text of any error in the Trajectory Executor.
RobotPosition CommandPositionGet(LinearUnits units)=0
Get the current commanded position of the robot from the trajectory executor in the specified units.
uint64_t MotionDoneWait(uint64_t timeoutMilliseconds)=0
Waits for a move to complete.
bool IsRunning()=0
Returns whether or not the robot is in motion (from executor or other source). Can be used to determi...
void Abort()=0
Abort an axis.
bool HasError()=0
Get the error state of the underlying Trajectory Executor.
double PathProcessLoadedMoves()=0
Processes our loaded moves. Used internally and to check whether loaded moves are valid,...
void EndEffectorTransformSet(const Pose &transform)=0
Transform that defines the control point relative to the end end of the current kinematic model For e...
bool MotionCounterWait(uint64_t motionWaitFor, uint64_t timeoutMilliseconds)=0
Waits for the counter to be greater than or equal to the specified state.
RobotPosition ActualPositionGet(LinearUnits units)=0
Get the current actual position of the robot from the trajectory executor in the specified units.
void PathPlaneSet(Plane plane)=0
Sets the plane for the purposes of ambiguous cases (arcs >= 180deg). Last set plane or XY plane is de...
const Pose & OriginTransformGet()=0
Offset for the origin location.
double PathLinearScalingGet() const =0
Gets scaling between input to path motion and output of path motion to the kinematic model.
RapidVector< double > InverseKinematics(Pose pose)=0
Run the given pose through the current inverse kinematic model to see the joint positions the robot w...
Pose ActualPoseGet(LinearUnits units)=0
Get the current actual pose of the robot from the trajectory executor in the specified units.
PathMode PathProgrammingModeGet()=0
Gets the programming mode (Relative/Absolute).
static Robot * RobotCreate(MotionController *controller, MultiAxis *multiAxis, const char *const modelIdentifier)
RobotPosition ForwardKinematicsPosition(const RapidVector< double > &joints)=0
Get the Actual position of the robot from the the joint MultiAxis positions.
void PathLinearScalingSet(double scaleFactor)=0
Sets scaling between the input to path motion and output of path motion to the kinematic model.
static Robot * RobotCreate(MotionController *controller, MultiAxis *multiAxis, KinematicModelBuilder *builder, uint32_t motionFrameBufferSize)
Create a Robot object to use G-Code, path motion, etc.
void AmpEnableSet(bool enable, int32_t ampActiveTimeoutMilliseconds)=0
Enable all amplifiers.
void EStopAbort()=0
E-Stop, then abort an axis.
void PathAccelerationSet(double unitsPerSecondSquared)=0
Sets the target acceleration for the machine (UserUnits/second^2). Should be set appropriately based ...
LinearUnits PathUnitsGet() const =0
Gets the units of path motion.
bool PathIsRunning()=0
Returns whether or not a planned path is being executed. All G-Code gets converted to path....
void PathArc(const Pose &target, double radius, RotationDirection direction)=0
Appends an arc on to the current on the PathPlaneGet() plane XY by default.
RobotPosition CommandPositionGet()=0
Get the current commanded position of the robot from the trajectory executor, in the Robot model's un...
Pose ActualPoseGet()=0
Get the current actual pose of the robot from the trajectory executor, in the Robot model's units.
void PathUnitsSet(LinearUnits units)=0
Defines the units Cartesian Path Motion is in.
void PathLine(const Pose &target)=0
void MoveAbsolute(const Pose &absolutePose)=0
Executes a point-to-point absolute motion in cartesian space.
PathState PathStateGet()=0
Gets the path state of the Robot.
void EStop()=0
Commands a joint EStop and clears the loaded moves.
void MoveRelative(const Pose &relativePose)=0
Executes a point-to-point motion relative to the current end effector Pose.
RapidVector< double > JointsCommandPositionsGet()=0
Get the commanded positions of the axes in the underlying MultiAxis.
Pose ForwardKinematics(const RapidVector< double > &joints)=0
Get the Actual pose of the robot from the the joint MultiAxis positions.
void PathProgrammingModeSet(PathMode mode)=0
Sets the programming mode (Relative/Absolute).
void PathArc(const Pose &target, const Vector3d &center, RotationDirection direction)=0
Appends an arc on to the current path with end pose about a specific center point.
uint64_t MotionCounterGet()=0
Gets the current motion counter of the Robot.
const double ScaleFactorBetweenUnitsGet(LinearUnits from, LinearUnits to)=0
Gets scaling for scale factor needed to convert from -> to units by multiplying
bool MotionCounterWaitChange(uint64_t motionWaitChange, uint64_t timeoutMilliseconds)=0
Waits for the state to change off the specified counter value.
void PathArc(const RobotPosition &RobotPosition, const Vector3d &center, RotationDirection direction)=0
Appends an arc on to the current path with end pose about a specific center point.
double PathDurationGet()=0
Get total (seconds) duration of the planned motion that will happen when run is called.
void Resume()=0
Resume an axis.
RapidVector< double > InverseKinematics(RobotPosition pose)=0
Run the given pose through the current inverse kinematic model to see the joint positions the robot w...
void Run()=0
Run the loaded path lines/arcs. The behavior is non-blocking. Use Robot.MotionDoneWait() to block.
Represents a collection of joints in Cartesian space with forward and inverse kinematics....
void ClearFaults()=0
Clears the MultiAxis fault then the Robot's error bit.
const KinematicModel & ModelGet()=0
Get the model this robot was created with Visit our Topic Page for more information.
void PathClear()=0
Clears out all loaded lines and arcs from the path. Part of the PathMotion method group....
static void RobotDelete(MotionController *controller, Robot *robot)
Delete a Robot.
RSI::RapidCode::Cartesian::Gcode * Gcode
An object to load and run Gcode files.
A representation of the robot containing the Pose and the positions of the free axes.
RobotPosition(const Cartesian::Pose &newPose, const RapidVector< double > &freeAxes)
Copies the new pose into this->Pose. Makes a deep copy of the given RapidVector for this->FreeAxes.
RobotPosition()
Default constructor. Initializes all values to 0. Leaves the FreeAxes RapidVector empty.
Cartesian::RobotPosition operator*(const Cartesian::RobotPosition &otherPosition) const
multiplies this->Pose by otherPosition.Pose and adds otherPosition.FreeAxes to this->FreeAxes (since ...
double AxisValueGet(uint32_t index) const
Gets the freeAxis value at the specified index. Returns 0 if index is out of bounds of the FreeAxes.
RobotPosition(const Cartesian::Pose &newPose, const size_t numberOfFreeAxes=0)
Copies the new pose into this->Pose. Specified number of free axes initialized with zeroes for their ...
void AxisValueSet(uint32_t index, double value)
Sets the freeaxis value at specified index to the passed value. Does nothing if index is out of bound...
RobotPosition(const Cartesian::RobotPosition &otherPosition)
Copy constructor. Copies values of Pose and FreeAxes.
RapidVector< double > FreeAxes
The Robot's free axes. Will have elements added to it for each free axis in the robot.
Cartesian::RobotPosition operator*(const Cartesian::Pose &otherPose) const
multiplies this->Pose by pose. Does not modify this->FreeAxes.
Vector3d is used for three-dimensional points and vectors.
Vector3d Normal() const
Returns a normalized copy of this.
Vector3d operator*(double scalar) const
Returns a Vector3d scaled scaled by. X*scalar, Y*scalar, Z*scalar.
Vector3d & Set(double x, double y, double z)
Sets X=x, Y=y, Z=z.
Vector3d operator+(const Vector3d &rightHandSide) const
Returns a copy of rightHandSide added to this. this.X+rightHandSide.X, this.Y+rightHandSide....
Vector3d operator/(double scalar) const
Returns a Vector3d scaled scaled by. X/scalar, Y/scalar, Z/scalar.
Vector3d & Set(const Vector3d &rightHandSide)
Sets X=rightHandSide.X, Y=rightHandSide.Y, Z=rightHandSide.Z.
Vector3d operator-(const Vector3d &rightHandSide) const
Returns a copy of rightHandSide subtracted from this. this.X-rightHandSide.X, this....
Vector3d & operator*=(double scalar)
Scales each element by scalar. X*=scalar, Y*=scalar, Z*=scalar.
Vector3d operator-() const
Returns a copy of this with elements negated. -X, -Y, -Z.
double Length() const
Returns the length of the vector. Aka the magnitude =sqrt(SumSquares)
bool operator!=(const Vector3d &rightHandSide) const
Returns whether this is not exactly equal to rightHandSide.
bool operator==(const Vector3d &rightHandSide) const
Returns whether this is exactly equal to rightHandSide.
Vector3d & operator/=(double scalar)
Scales each element by scalar. X/=scalar, Y/=scalar, Z/=scalar.
double SumSquares() const
Returns the sum of squares. X*X+Y*Y+Z*Z.
Vector3d()
Default constructor. X=Y=Z=0.
Vector3d & operator-=(const Vector3d &rightHandSide)
Subtracts rightHandSide from this. this.X-=rightHandSide.X, this.Y-=rightHandSide....
Vector3d & operator+=(const Vector3d &rightHandSide)
Adds rightHandSide to this. this.X+=rightHandSide.X, this.Y+=rightHandSide.Y, this....
double Dot(const Vector3d &rightHandSide) const
Dot Product. this.X*rightHandSide.X + this.Y*rightHandSide.Y + this.Z*rightHandSide....
Vector3d Inverse() const
Returns an inverted copy of this. this * this.inverse() = I.
Vector3d Cross(const Vector3d &rightHandSide) const
Cross Product. Vector.X = this.Y*rightHandSide.z - this.Z*rightHandSide.Y Vector.Y = this....
Vector3d & operator=(const Vector3d &rightHandSide)
Sets this = rightHandSide.
Vector3d(double x, double y, double z)
Constructor. X=x, Y=y, Z=z.
bool Equals(const Vector3d &rightHandSide, const double tolerance) const
Checks whether this.X==rightHandSide.X && this.Y==rightHandSide.Y && this.Z==rightHandSide....
Vector3d & Normalize()
Normalizes this.
Vector3d(const Vector3d &rightHandSide)
Constructor. X=rightHandSide.X, Y=rightHandSide.Y, Z=rightHandSide.Z.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
Definition rsi.h:762
Represents multiple axes of motion control, allows you to map two or more Axis objects together for e...
Definition rsi.h:10564
The RapidCode base class. All non-error objects are derived from this class.
Definition rsi.h:178
Represents the error details thrown as an exception by all RapidCode classes. This class contains an ...
Definition rsi.h:105
PathMode
Motion types. For G-code use and Cartesian path motion.
Plane
Rotational directions about and axis.
CartesianAxis
This enum specifies which Cartesian axis a LinearJointMapping maps a robot joint to.
PathState
State of the Robot.
@ Stopping
Motion was interrupted by a stop command or error on the MultiAxis. EStop time will be used....
@ Moving
A path motion is in progress.
@ Idle
The path motion is not moving or in progress. If the joints are moved directly, the PathState will be...
@ Uninitialized
Library is loading. Wait until it is idle.
RotationDirection
Rotational directions about an axis.
LinearUnits
Unit types. For G-code use.
GCodeWorkOffset
Register names for G-Code work offsets.
const char * LineText
The actual line content from the G-code file.
RsiError * UserError
Allows the user to set give error details to the G-Code execution thread what occurred during the exe...
int32_t LineNumber
The line number in the G-code file where the M-code is encountered.
Holds data for the G-code M-code callback mechanism.
Data for adding joint or free-axis mappings when building a kinematic model.
double Offset
The offset value that will be added to the scaled joint position.
int JointIndex
The index of the robot's joint to map (within an array of joint positions). Often this index will ref...
ModelAxisMapping(int jointIndex)
Constructor that sets the FointIndex and uses defaults for the rest of the data members.
double Scaling
The scaling value that the joint position will be multiplied by.
ModelAxisMapping(int jointIndex, double scaling, double offset, const char *const label)
Constructor that sets all data members in the struct.