|
The RMP Motion Controller APIs
|
2 #ifndef _CARTESIANROBOT_H
3 #define _CARTESIANROBOT_H
6 #if defined(HAS_CARTESIAN_ROBOT)
10 #if defined(__cplusplus)
24 static constexpr uint32_t MotionFrameBufferSizeMinimum=50;
38 constexpr
double pi = 3.1415926535897932384626433832795028841971693993751;
443 Pose(
double x,
double y,
double z);
479 virtual const char*
const NameGet()
const = 0;
480 virtual uint32_t AxisCountGet()
const = 0;
484 virtual bool IsConfigured()
const = 0;
486 virtual const char*
const*
const ExpectedAxisNamesGet()
const = 0;
487 virtual uint32_t ExpectedAxisNamesCountGet()
const = 0;
492 virtual bool SolveInverse(
const Pose& inputPose,
void* outputPointerSolutionVector)
const = 0;
497 virtual void SolveForward(
const double* inputJointPositions,
Pose& outputPose)
const = 0;
523 Storage* StorageGet();
524 const Storage* StorageGet()
const;
525 void StorageSet(Storage*);
587 static constexpr
double DEFAULT_SCALING = 1.0;
591 static constexpr
double DEFAULT_OFFSET = 0.0;
594 static constexpr
int MAX_LABEL_SIZE = 16;
595 static constexpr
int EXPECTED_LABEL_BUFFER_SIZE = MAX_LABEL_SIZE + 1;
600 char ExpectedLabel[EXPECTED_LABEL_BUFFER_SIZE];
643 ArticulatedModelBuilder();
644 ~ArticulatedModelBuilder();
694 static constexpr uint64_t TimeoutForever = 0xFFFFFFFFFFFFFFFF;
814 virtual void AmpEnableSet(
bool enable, int32_t ampActiveTimoutMilliseconds) = 0;
1056 virtual uint64_t
PathPlannedPointsGet(
double* points,
double* times, uint64_t startFrame, uint64_t frameCount) = 0;
1289 #if defined(__cplusplus)
1291 #endif // defined(__cplusplus)
1292 #endif // defined(HAS_CARTESIAN_ROBOT)
1293 #endif // _CARTESIANROBOT_H
void PathAccelerationSet(double unitsPerSecondSquared)=0
Sets the target acceleration for the machine (UserUnits/second^2). Should be set apprpriately based o...
void PathLinearScalingSet(double scaleFactor)=0
Sets scaling between the input to path motion and output of path motion to the kinematic model.
bool PathIsRunning()=0
Returns whether or not a planned path is being executed. All G-Code gets converted to path....
GCodeWorkOffset GcodeWorkOffsetGet()=0
Gets the enum representing the location where the current offset is saved.
The MultiAxis object allows you to map two or more axes together and command synchronized motion.
void ToMatrix(double *mat) const
Quaternion To Matrix.
The Robot class for Path, G-Code and RapidRobot motion for any actuator. Use RobotCreate() to make on...
PathMode GcodeProgrammingModeGet()=0
Gets the G-Code programming mode (Relative/Absolute).
bool operator!=(const Quaternion &rhs) const
Exact inequality check. See equals for approximately equal to.
void Resume()=0
Resume an axis.
Quaternion Orientation
The orientation component of the Pose.
Quaternion Conjugate() const
Negates the imaginary component of the Quaternion.
double PathProcessLoadedMoves()=0
Processes our loaded moves. Used internally and to check whether loaded moves are valid,...
RotationDirection
Rotational directions about an axis.
bool GcodeFileLoad(const char *const filePath)=0
Open a file at the specified file path. Calls GcodeStringLoad() with the contents of the file.
double Offset
The offset value that will be added to the scaled joint position.
Quaternion operator*(double s) const
Multiplication (scalar) operator. w*s, v*s.
double SumSquares() const
Returns the sum of squares. X*X+Y*Y+Z*Z.
Vector3d Position
The position component of the Pose.
void GcodeReload(int32_t startLine, int32_t endLine)=0
Reloads the lines from the last call to GcodeStringLoad() but only between start and end line numbers...
const KinematicModel & ModelGet()=0
Get the model this robot was created with Visit our Topic Page for more information.
void Abort()=0
Abort an axis.
double PathVelocityGet()=0
Gets the target velocity for the machine (UserUnits/second).
double Dot(const Quaternion &rhs) const
Returns the dot product of each element. w*rhs.w+v.dot(rhs.v)
Vector3d operator/(double scalar) const
Returns a Vector3d scaled scaled by. X/scalar, Y/scalar, Z/scalar.
Quaternion(const Quaternion &rhs)
Constructor.
void GcodeProgrammingModeSet(PathMode mode)=0
Sets the programming mode (Relative/Absolute).
Quaternion operator+(const Quaternion &rhs) const
Adds two quaternions together. this.w + rhs.w, this.v+rhs.v.
const KinematicModel & ModelGet()
Get a constant reference to the Kinematic model that is currently built. The builder instance maintai...
void JointAdd(const LinearJointMapping &joint)
adds a joint to the model using the configuration specified within the LinearJoint structure.
void EndEffectorTransformSet(const Pose &transform)=0
Transform that defines the control point relative to the end end of the current kinematic model For e...
Pose(double x, double y, double z)
Constructor from X,Y,Z with an identity "no rotation" default Quaternion.
void Stop()=0
Stop an axis.
Vector3d ToEuler() const
Gets the Euler Angle representation of this quaternion.
double Scaling
The scaling value that the joint position will be multiplied by.
double Magnitude() const
Gets the magnitude of this. sqrt(SumSquares())
void PathArc(const Pose &target, const Vector3d ¢er, RotationDirection direction)=0
Appends an arc on to the current path with end pose about a specific center point.
void LabelSet(const char *const label)
Set the model name.
double X
The X coordinate.
Vector3d & operator/=(double scalar)
Scales each element by scalar. X/=scalar, Y/=scalar, Z/=scalar.
Vector3d & Set(const Vector3d &rhs)
Sets X=rhs.X, Y=rhs.Y, Z=rhs.Z.
Plane
Rotational directions about and axis.
Quaternion operator*(const Quaternion &rhs) const
Multiplication (rotation) operator. Rotates other by this.
Quaternion for representing rotations.
bool operator!=(const Vector3d &rhs) const
Returns whether this is not exactly equal to rhs.
const KinematicModel & ModelBuild()=0
Construct the model using the information the builder currently has. The builder will maintain a refe...
void AmpEnableSet(bool enable, int32_t ampActiveTimoutMilliseconds)=0
Enable all amplifiers.
Describes the mathematical kinematic model of a robot.
void PathVelocitySet(double unitsPerSecond)=0
Sets the target linear cartesian velocity for each move (UserUnits/second).
Vector3d & operator*=(double scalar)
Scales each element by scalar. X*=scalar, Y*=scalar, Z*=scalar.
uint64_t MotionDoneWait(uint64_t timeoutMilliseconds)=0
Waits for a move to complete.
void PathPlaneSet(Plane plane)=0
Sets the plane for the purposes of ambigous cases (arcs >= 180deg). Last set plane or XY plane is def...
double Y
The Y coordinate.
LinearModelBuilder(const char *const label)
constructs a LinearModelBuilder instance.
void GcodeReload()=0
Reloads the all lines from the last call to GcodeStringLoad(). Automatically called by GcodeStringLoa...
void UnitsSet(LinearUnits units)
Set the units the built model will use.
double Length() const
Returns the length of the vector. Aka the magnitude =sqrt(SumSquares)
Quaternion(double w, double x, double y, double z)
Constructor.
Quaternion(const Vector3d &rpy)
Euler Constructor (Alternate)
Vector3d operator+(const Vector3d &rhs) const
Returns a copy of rhs added to this. this.X+rhs.X, this.Y+rhs.Y, this.Z+rhs.Z.
void ToAngleAxis(double &out_angle, Vector3d &out_axis) const
Gets the axis angle representation of this quaternion.
Quaternion & operator-=(const Quaternion &rhs)
Subtraction assignment. Subtracts other from this. See operator-.
Pose Inverse() const
Returns an inverted copy of this. this * this.inverse() = I.
Vector3d operator*(const Vector3d &rhs) const
Multiplication (vector rotation) operator. Rotates vector by this.
bool MotionDoneGet()=0
Check to see if motion is done and settled.
void GcodeWorkOffsetConfigure(GCodeWorkOffset offset, Vector3d offsetValues)=0
Save an XYZ offset to be used with specified G-Code work offset.
Vector3d Inverse() const
Returns an inverted copy of this. this * this.inverse() = I.
Pose ForwardKinematics(double *inJoints, uint16_t inJointsSize)=0
Get the Actual pose of the robot from the the joint MultiAxis positions.
void PathUnitsSet(LinearUnits units)=0
Defines the units Cartesian Path Motion is in.
Vector3d V
Vector3d (imaginary) component of Quaternion. 1->x, 2->y, 3->z. Do not modify this unless you know wh...
void PathArc(const Pose &target, double radius, RotationDirection direction)=0
Appends an arc on to the current on the PathPlaneGet() plane XY by default.
Vector3d & operator=(const Vector3d &rhs)
Sets this = rhs.
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...
int32_t GcodeExecutingLineNumberGet()=0
Returns the line number of the currently executing G-Code line or -1 if there is none.
Pose(const Pose &pose)
Constructor from an existing Pose.
const Pose & EndEffectorTransformGet()=0
End of Robot to TCP.
double Dot(const Vector3d &rhs) const
Dot Product. this.X*rhs.X + this.Y*rhs.Y + this.Z*rhs.Z.
void Run()=0
Run the loaded path lines/arcs. The behavior is non-blocking. Use Robot.MotionDoneWait() to block....
Quaternion operator-(const Quaternion &rhs) const
Subtraction operator. this.w - rhs.w, this.v-rhs.v.
Quaternion & operator*=(double s)
Multiplication (scalar) assignment operator. See operator*(double)
Vector3d()
Default constructor. X=Y=Z=0.
const Pose & OriginTransformGet()=0
Offset for the origin location.
The RapidCode base class. All non-error objects are derived from this class.
void EStopAbort()=0
E-Stop, then abort an axis.
The abstract class for Kinematic Model builders. Constructs a single Kinematic Model to use when crea...
void ClearFaults()=0
Clears the MultiAxis fault then the Robot's error bit.
Vector3d operator*(double scalar) const
Returns a Vector3d scaled scaled by. X*scalar, Y*scalar, Z*scalar.
int32_t GcodeNumberOfLinesGet()=0
Returns the total line number count in the last loaded item.
bool Equals(const Vector3d &rhs, const double tolerance) const
Checks whether this.X==rhs.X && this.Y==rhs.Y && this.Z==rhs.Z within tolerance abs(a-b) < tolerance.
bool PathStateWait(PathState stateWaitFor, uint64_t timeoutMilliseconds)=0
Waits for a specific path state.
void TransformFromKinematicOriginToRobotOriginSet(const Pose &KinematicOriginToRobotOrigin)
Set the kin origin to robot origin tf.
bool operator==(const Vector3d &rhs) const
Returns whether this is exactly equal to rhs.
Quaternion & Set(double w, double x, double y, double z)
Assigns each component into this.
uint32_t MotionFrameBufferSizeGet()=0
Gets the frame buffer size that is set at creation.
void JointsActualPositionsGet(double *positions, uint16_t sz)=0
Get the actual position of the axes in the underlying MultiAxis.
static Robot * RobotCreate(MotionController *controller, MultiAxis *multiAxis, const char *const modelIdentifier, uint32_t motionFrameBufferSize)
Create a Robot object to use G-Code, path motion, etc.
double Z
The Z coordinate.
static void RobotDelete(MotionController *controller, Robot *robot)
Delete a Robot.
Vector3d operator*(const Vector3d &rhs) const
Transforms rhs by this. Rotates rhs by this, and adds this.position to it.
bool operator==(const Quaternion &rhs) const
Exact equality check. See equals for approximately equal to.
bool MotionCounterWait(uint64_t motionWaitFor, uint64_t timeoutMilliseconds)=0
Waits for the counter to be greater than or euqal to the specified state.
Quaternion & Normalize()
Normalizes this. Scales each component by 1 / magnitude.
Quaternion & Set(double x, double y, double z)
Assigns the quaternion defined by the Euler angles into this. If you get unexpected values,...
Vector3d & operator-=(const Vector3d &rhs)
Subtracts rhs from this. this.X-=rhs.X, this.Y-=rhs.Y, this.Z-=rhs.Z.
static Robot * RobotCreate(MotionController *controller, MultiAxis *multiAxis, const char *const modelIdentifier)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Pose ActualPoseGet()=0
Get the actual pose of the robot from the trajectory exectutor.
void MoveAbsolute(const Pose &absolutePose)=0
Executes a point-to-point absolute motion in cartesian space.
void PathLine(const Pose &target)=0
Vector3d operator-(const Vector3d &rhs) const
Returns a copy of rhs subtracted from this. this.X-rhs.X, this.Y-rhs.Y, this.Z-rhs....
Quaternion operator-() const
Negates this quaternion (w, and v)
Vector3d Normal() const
Returns a normalized copy of this.
const Pose & GcodeWorkOffsetValuesGet()=0
Gets the actual values of the currently applied offset.
The Builder for a linear kinematic model. Constructs a single Linear Kinematic Model to use when crea...
bool PathStateWaitChange(PathState stateWaitChange, uint64_t timeoutMilliseconds)=0
Waits for the path state to not be the specified state.
bool Equals(const Quaternion &rhs, const double tolerance) const
Equality check within tolerance.
int32_t GcodeErrorLineNumberGet()=0
Gets the line number of any errors in the G-Code syntax.
CartesianAxis
This enum specifies which Cartesian axis a LinearJointMapping maps a robot joint to.
const char *const GcodeLineTextGet(uint32_t lineNumber)=0
Gives you the text of a specific line from the last loaded program excluding all comments and with on...
Vector3d(double x, double y, double z)
Constructor. X=x, Y=y, Z=z.
void EStop()=0
Commands a joint EStop and clears the loaded moves.
Quaternion & Set(const Vector3d &vec)
Assigns the quaternion defined by the Euler Angles into this.
void GcodePlaneSet(Plane plane)=0
Set the plane for arcs (same as calling G17/G18/G19)
const char *const ErrorMessageGet()=0
Get the text of any error in the Trajectory Executor.
double GcodeFeedRateGet()=0
Gets the target feed rate for the machine (GcodeUnitsGet()/minute).
double SumSquares() const
Gets the sum of the components squared (w*w+this.dot(this))
double PathLinearScalingGet() const =0
Gets scaling between 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.
@ Uninitialized
Library is loading. Wait until it is idle.
Vector3d(const Vector3d &rhs)
Constructor. X=rhs.X, Y=rhs.Y, Z=rhs.Z.
const char *const GcodeProgramGet()=0
Gets the raw file contents of the last loaded program.
The MotionController object represents the RMP INtime soft motion controller.
Plane PathPlaneGet()=0
Gets the plane some arcs will be forced to be on.
double W
W (real component) of Quaternion. Do not modify this unless you know what you are doing.
void GcodeFeedRateSet(double unitsPerMinute)=0
Sets the target feed rate for the machine (units/minute). Same as the "F" Command in a G-Code file.
Quaternion(double x, double y, double z)
Euler constructor.
Vector3d is used for three-dimensional points and vectors.
Quaternion Normalized() const
Retunrs a normalized copy of this.
Vector3d operator-() const
Returns a copy of this with elements negated. -X, -Y, -Z.
const double ScaleFactorBetweenUnitsGet(LinearUnits from, LinearUnits to)=0
Gets scaling for scale factor needed to convert from -> to units by multiplying
Vector3d & operator+=(const Vector3d &rhs)
Adds rhs to this. this.X+=rhs.X, this.Y+=rhs.Y, this.Z+=rhs.Z.
Quaternion & operator+=(const Quaternion &rhs)
Addition assignment. Adds rhs into this. See operator+.
Pose(const Vector3d &position)
Constructor from an existing position Vector3d.
Pose operator*(const Pose &rhs) const
Transforms rhs by this. Rotates rhs.position by this, adds this.position to it, and rotates rhs....
uint64_t MotionDoneWait()=0
Waits for a move to complete.
PathState PathStateGet()=0
Gets the path state of the Robot.
Quaternion & operator=(const Quaternion &rhs)
Assignment operator. Copies underlying.
Pose Rotate(const Pose &rhs) const
Rotates rhs by the rotation component of this (ONLY the rotation component)
Quaternion & Set(const Quaternion &rhs)
Assigns other into this.
void PathClear()=0
Clears out all loaded lines and arcs from the path.
Quaternion & Set(double w, const Vector3d &vec)
Assigns other into this.
Vector3d & Normalize()
Normalizes this.
bool IsRunning()=0
Returns whether or not the robot is in motion (from executor or other source). Can be used to determi...
double PathDurationGet()=0
Get total (seconds) duration of the planned motion that will happen when run is called.
uint64_t PathPlannedPointsGet(double *points, double *times, uint64_t startFrame, uint64_t frameCount)=0
Get points representing the planned motion in cartesian space that will happen when run is called.
void MoveRelative(const Pose &relativePose)=0
Executes a point-to-point motion relative to the current end effector Pose.
void GcodeUnitsSet(LinearUnits units)=0
Set the currently active unit (same as calling G20/G21)
LinearUnits PathUnitsGet() const =0
Gets the units of path motion.
Quaternion Inverse() const
Conjugate scaled by 1 / SumSquares()
Pose(const Vector3d position, const Quaternion &quaternion)
Constructor.
double PathAccelerationGet()=0
Gets the target acceleration for the machine (UserUnits/second^2).
Quaternion()
Default Constructor. W=1, X=Y=Z=0.
void GcodeReload(int32_t startLine)=0
Reloads the lines from the last call to GcodeStringLoad() but only between start line and end of file...
LinearUnits
Unit types. For G-code use.
static Quaternion FromAngleAxis(double angle, const Vector3d &axis)
Creates a quaternion from an axis angle representation.
void PathProgrammingModeSet(PathMode mode)=0
Sets the programming mode (Relative/Absolute).
void InverseKinematics(Pose pose, double *outJoints, uint16_t outJointsSize)=0
Run the given pose through the current inverse kinematic model to see the joint positions the robot w...
bool GcodeStringLoad(const char *const text)=0
Interpret a string as contents of a G-Code file and prepare it for execution.
Pose CommandPoseGet()=0
Get the commanded pose of the robot from the trajectory exectutor.
Vector3d Cross(const Vector3d &rhs) const
Cross Product. Vector.X = this.Y*rhs.z - this.Z*rhs.Y Vector.Y = this.Z*rhs.X - this....
PathMode PathProgrammingModeGet()=0
Gets the programming mode (Relative/Absolute).
Pose(const Quaternion &quaternion)
Constructor.
bool MotionCounterWaitChange(uint64_t motionWaitChange, uint64_t timeoutMilliseconds)=0
Waits for the state to change off the specified counter value.
LinearUnits GcodeUnitsGet()=0
Get the currently active unit as set by G20/G21.
void JointsCommandPositionsGet(double *positions, uint16_t sz)=0
Get the commanded position of the axes in the underlying MultiAxis.
const KinematicModel & ModelBuild() override
Construct the model using the information the builder currently has. The builder will maintain a refe...
void GcodeWorkOffsetSelect(GCodeWorkOffset offset)=0
Apply the offset saved under the specified location.
static Quaternion FromMatrix(const double *const mat)
Matrix to Quaternion.
PathState
State of the Robot.
KinematicModelBuilder(const char *const label)
The KinematicModelBuilder constructor is protected so that only derived classes can use it....
CartesianAxis CartesianCoordinate
PathMode
Motion types. For G-code use and Cartesian path motion.
Quaternion(double w, const Vector3d &v)
Constructor.
bool HasError()=0
Get the error state of the underlying Trajectory Executor.
void GcodeAccelerationRateSet(double unitsPerMinuteSquared)=0
Sets the target acceleration for the machine (units/minute^2). Should be set apprpriately based on yo...
Pose()
Default constructor. Vector(0,0,0) Quaterion(1,0,0,0)
GCodeWorkOffset
Register names for G-Code work offsets.
uint64_t MotionCounterGet()=0
Gets the current motion counter of the Robot.
Vector3d & Set(double x, double y, double z)
Sets X=x, Y=y, Z=z.
double GcodeAccelerationRateGet()=0
Gets the target acceleration for the machine (GcodeUnitsGet()/minute^2).
bool Equals(const Pose &rhs, double tolerance) const
Approximate equality check. Checks whether all components are within the tolerance of each other.