tp_types.h
1 /******************************************************************** 2 * Description: tp_types.h 3 * Trajectory planner types and constants 4 * 5 * Derived from a work by Fred Proctor & Will Shackleford 6 * 7 * Author: 8 * License: GPL Version 2 9 * System: Linux 10 * 11 * Copyright (c) 2004 All rights reserved. 12 * 13 ********************************************************************/ 14 #ifndef TP_TYPES_H 15 #define TP_TYPES_H 16 17 #include "posemath.h" 18 #include "tc_types.h" 19 #include "tcq.h" 20 21 #include <rtapi_bool.h> 22 23 #define TP_DEFAULT_QUEUE_SIZE 32 24 /* Minimum length of a segment in cycles (must be greater than 1 to ensure each 25 * segment is hit at least once.) */ 26 #define TP_MIN_SEGMENT_CYCLES 1.02 27 /* Values chosen for accel ratio to match parabolic blend acceleration 28 * limits. */ 29 #define TP_OPTIMIZATION_CUTOFF 4 30 /* If the queue is shorter than the threshold, assume that we're approaching 31 * the end of the program */ 32 #define TP_QUEUE_THRESHOLD 3 33 34 /* closeness to zero, for determining if a move is pure rotation */ 35 #define TP_PURE_ROTATION_EPSILON 1e-6 36 37 /* "neighborhood" size (if two values differ by less than the epsilon, 38 * then they are effectively equal.)*/ 39 #define TP_ACCEL_EPSILON 1e-4 40 #define TP_VEL_EPSILON 1e-8 41 #define TP_POS_EPSILON 1e-12 42 #define TP_TIME_EPSILON 1e-12 43 #define TP_ANGLE_EPSILON 1e-6 44 #define TP_ANGLE_EPSILON_SQ (TP_ANGLE_EPSILON * TP_ANGLE_EPSILON) 45 #define TP_MIN_ARC_ANGLE 1e-3 46 #define TP_MIN_ARC_LENGTH 1e-6 47 #define TP_BIG_NUM 1e10 48 49 /** 50 * TP return codes. 51 * This enum is a catch-all for useful return statuses from TP 52 * internal functions. This may be replaced with a better system in 53 * the future. 54 */ 55 typedef enum { 56 TP_ERR_INVALID = -9, 57 TP_ERR_INPUT_TYPE = -8, 58 TP_ERR_TOLERANCE = -7, 59 TP_ERR_RADIUS_TOO_SMALL = -6, 60 TP_ERR_GEOM = -5, 61 TP_ERR_RANGE = -4, 62 TP_ERR_MISSING_OUTPUT = -3, 63 TP_ERR_MISSING_INPUT = -2, 64 TP_ERR_FAIL = -1, 65 TP_ERR_OK = 0, 66 TP_ERR_NO_ACTION, 67 TP_ERR_SLOWING, 68 TP_ERR_STOPPED, 69 TP_ERR_WAITING, 70 TP_ERR_ZERO_LENGTH, 71 TP_ERR_REVERSE_EMPTY, 72 TP_ERR_LAST 73 } tp_err_t; 74 75 /** 76 * Persistant data for spindle status within tpRunCycle. 77 * This structure encapsulates some static variables to simplify refactoring of 78 * synchronized motion code. 79 */ 80 typedef struct { 81 int spindle_num; 82 double offset; 83 double revs; 84 int waiting_for_index; 85 int waiting_for_atspeed; 86 } tp_spindle_t; 87 88 /** 89 * Trajectory planner state structure. 90 * Stores persistant data for the trajectory planner that should be accessible 91 * by outside functions. 92 */ 93 typedef struct { 94 TC_QUEUE_STRUCT queue; 95 tp_spindle_t spindle; //Spindle data 96 97 EmcPose currentPos; 98 EmcPose goalPos; 99 100 int queueSize; 101 double cycleTime; 102 103 double vMax; /* vel for subsequent moves */ 104 double ini_maxvel; /* max velocity allowed by machine 105 constraints (ini file) for 106 subsequent moves */ 107 double vLimit; /* absolute upper limit on all vels */ 108 109 double aMax; /* max accel (unused) */ 110 //FIXME this shouldn't be a separate limit, 111 double aMaxCartesian; /* max cartesian acceleration by machine bounds */ 112 double aLimit; /* max accel (unused) */ 113 114 double wMax; /* rotational velocity max */ 115 double wDotMax; /* rotational accelleration max */ 116 int nextId; 117 int execId; 118 int termCond; 119 int done; 120 int depth; /* number of total queued motions */ 121 int activeDepth; /* number of motions blending */ 122 int aborting; 123 int pausing; 124 int reverse_run; /* Indicates that TP is running in reverse */ 125 int motionType; 126 double tolerance; /* for subsequent motions, stay within this 127 distance of the programmed path during 128 blends */ 129 int synchronized; // spindle sync required for this move 130 int velocity_mode; /* TRUE if spindle sync is in velocity mode, 131 FALSE if in position mode */ 132 double uu_per_rev; /* user units per spindle revolution */ 133 134 135 syncdio_t syncdio; //record tpSetDout's here 136 137 } TP_STRUCT; 138 139 140 /** 141 * Describes blend modes used in the trajectory planner. 142 * @note these values are used as array indices, so make sure valid options 143 * start at 0 and increase by one. 144 */ 145 typedef enum { 146 NO_BLEND = -1, 147 PARABOLIC_BLEND, 148 TANGENT_SEGMENTS_BLEND, 149 ARC_BLEND 150 } tc_blend_type_t; 151 152 #endif /* TP_TYPES_H */