📄 motion.h
字号:
emcmot_comp_entry_t array[EMCMOT_COMP_SIZE+2]; /* +2 because array has -HUGE_VAL and +HUGE_VAL entries at the ends */ } emcmot_comp_t;/* motion controller states */ typedef enum { EMCMOT_MOTION_DISABLED = 0, EMCMOT_MOTION_FREE, EMCMOT_MOTION_TELEOP, EMCMOT_MOTION_COORD } motion_state_t;/* states for homing */ typedef enum { HOME_IDLE = 0, HOME_START, // 1 HOME_INITIAL_BACKOFF_START, // 2 HOME_INITIAL_BACKOFF_WAIT, // 3 HOME_INITIAL_SEARCH_START, // 4 HOME_INITIAL_SEARCH_WAIT, // 5 HOME_SET_COARSE_POSITION, // 6 HOME_FINAL_BACKOFF_START, // 7 HOME_FINAL_BACKOFF_WAIT, // 8 HOME_RISE_SEARCH_START, // 9 HOME_RISE_SEARCH_WAIT, // 10 HOME_FALL_SEARCH_START, // 11 HOME_FALL_SEARCH_WAIT, // 12 HOME_SET_SWITCH_POSITION, // 13 HOME_INDEX_ONLY_START, // 14 HOME_INDEX_SEARCH_START, // 15 HOME_INDEX_SEARCH_WAIT, // 16 HOME_SET_INDEX_POSITION, // 17 HOME_FINAL_MOVE_START, // 18 HOME_FINAL_MOVE_WAIT, // 19 HOME_FINISHED, // 20 HOME_ABORT // 21 } home_state_t; typedef enum { HOME_SEQUENCE_IDLE = 0, HOME_SEQUENCE_START, HOME_SEQUENCE_START_JOINTS, HOME_SEQUENCE_WAIT_JOINTS, } home_sequence_state_t;/* flags for homing */#define HOME_IGNORE_LIMITS 1#define HOME_USE_INDEX 2#define HOME_IS_SHARED 4/* flags for enabling spindle scaling, feed scaling, adaptive feed, and feed hold */#define SS_ENABLED 0x01#define FS_ENABLED 0x02#define AF_ENABLED 0x04#define FH_ENABLED 0x08/* This structure contains all of the data associated with a single joint. Note that this structure does not need to be in shared memory (but it can, if desired for debugging reasons). The portions of this structure that are considered "status" and need to be made available to user space are copied to a much smaller struct called emcmot_joint_status_t which is located in shared memory.*/ typedef struct { /* configuration info - changes rarely */ int type; /* 0 = linear, 1 = rotary */ double max_pos_limit; /* upper soft limit on joint pos */ double min_pos_limit; /* lower soft limit on joint pos */ double max_jog_limit; /* jog limits change when not homed */ double min_jog_limit; double vel_limit; /* upper limit of joint speed */ double acc_limit; /* upper limit of joint accel */ double min_ferror; /* zero speed following error limit */ double max_ferror; /* max speed following error limit */ double home_search_vel; /* dir/spd to look for home switch */ double home_latch_vel; /* dir/spd to latch switch/index pulse */ double home_offset; /* dir/dist from switch to home point */ double home; /* joint coordinate of home point */ int home_flags; /* flags for various homing options */ double backlash; /* amount of backlash */ int home_sequence; /* Order in homing sequence */ emcmot_comp_t comp; /* leadscrew correction data */ /* status info - changes regularly */ /* many of these need to be made available to higher levels */ /* they can either be copied to the status struct, or an array of joint structs can be made part of the status */ EMCMOT_AXIS_FLAG flag; /* see above for bit details */ double coarse_pos; /* trajectory point, before interp */ double pos_cmd; /* commanded joint position */ double vel_cmd; /* comanded joint velocity */ double backlash_corr; /* correction for backlash */ double backlash_filt; /* filtered backlash correction */ double backlash_vel; /* backlash velocity variable */ double motor_pos_cmd; /* commanded position, with comp */ double motor_pos_fb; /* position feedback, with comp */ double pos_fb; /* position feedback, comp removed */ double ferror; /* following error */ double ferror_limit; /* limit depends on speed */ double ferror_high_mark; /* max following error */ double free_pos_cmd; /* position command for free mode TP */ double free_vel_lim; /* velocity limit for free mode TP */ int free_tp_enable; /* if zero, joint stops ASAP */ int free_tp_active; /* if non-zero, move in progress */ int kb_jog_active; /* non-zero during a keyboard jog */ int wheel_jog_active; /* non-zero during a wheel jog */ /* internal info - changes regularly, not usually accessed from user space */ CUBIC_STRUCT cubic; /* cubic interpolator data */ int on_pos_limit; /* non-zero if on limit */ int on_neg_limit; /* non-zero if on limit */ double home_sw_pos; /* latched position of home sw */ int home_pause_timer; /* used to delay between homing states */ int index_enable; /* current state of index enable pin */ home_state_t home_state; /* state machine for homing */ double motor_offset; /* diff between internal and motor pos, used to set position to zero during homing */ int old_jog_counts; /* prior value, used for deltas */ /* stuff moved from the other structs that might be needed (or might not!) */ double big_vel; /* used for "debouncing" velocity */ } emcmot_joint_t;/* This structure contains only the "status" data associated with a joint. "Status" data is that data that should be reported to user space on a continuous basis. An array of these structs is part of the main status structure, and is filled in with data copied from the emcmot_joint_t structs every servo period. For now this struct contains more data than it really needs, but paring it down will take time (and probably needs to be done one or two items at a time, with much testing). My main goal right now is to get get the large joint struct out of status.*/ typedef struct { EMCMOT_AXIS_FLAG flag; /* see above for bit details */ double pos_cmd; /* commanded joint position */ double pos_fb; /* position feedback, comp removed */ double ferror; /* following error */ double ferror_high_mark; /* max following error *//*! \todo FIXME - the following are not really "status", but taskintf.cc expects them to be in the status structure. I don't know how or if they are used by the user space code. Ideally they will be removed from here, but each one will need to be investigated individually.*/ double backlash; /* amount of backlash */ double max_pos_limit; /* upper soft limit on joint pos */ double min_pos_limit; /* lower soft limit on joint pos */ double min_ferror; /* zero speed following error limit */ double max_ferror; /* max speed following error limit */ double home_offset; /* dir/dist from switch to home point */ } emcmot_joint_status_t; typedef struct { double speed; // spindle speed in RPMs double css_factor; double xoffset; int direction; // 0 stopped, 1 forward, -1 reverse int brake; // 0 released, 1 engaged } spindle_status; /********************************* STATUS STRUCTURE*********************************//* This is the status structure. There is one of these in shared memory, and it reports motion controller status to higher level code in user space. For the most part, this structure contains higher level variables - low level stuff is made visible to the HAL and troubleshooting, etc, is done using the HAL oscilliscope.*//*! \todo FIXME - this struct is broken into two parts... at the top are structure members that I understand, and that are needed for emc2. Other structure members follow. All the later ones need to be evaluated - either they move up, or they go away.*/ typedef struct emcmot_status_t { unsigned char head; /* flag count for mutex detect */ /* these three are updated only when a new command is handled */ cmd_code_t commandEcho; /* echo of input command */ int commandNumEcho; /* echo of input command number */ cmd_status_t commandStatus; /* result of most recent command */ /* these are config info, updated when a command changes them */ double feed_scale; /* velocity scale factor for all motion */ double spindle_scale; /* velocity scale factor for spindle speed */ unsigned char enables_new; /* flags for FS, SS, etc */ /* the above set is the enables in effect for new moves */ /* the rest are updated every cycle */ double net_feed_scale; /* net scale factor for all motion */ double net_spindle_scale; /* net scale factor for spindle */ unsigned char enables_queued; /* flags for FS, SS, etc */ /* the above set is the enables in effect for the currently executing move */ motion_state_t motion_state; /* operating state: FREE, COORD, etc. */ EMCMOT_MOTION_FLAG motionFlag; /* see above for bit details */ EmcPose carte_pos_cmd; /* commanded Cartesian position */ int carte_pos_cmd_ok; /* non-zero if command is valid */ EmcPose carte_pos_fb; /* actual Cartesian position */ int carte_pos_fb_ok; /* non-zero if feedback is valid */ EmcPose world_home; /* cartesean coords of home position */ int homing_active; /* non-zero if any axis is homing */ home_sequence_state_t homingSequenceState; emcmot_joint_status_t joint_status[EMCMOT_MAX_JOINTS]; /* all joint status data */ int on_soft_limit; /* non-zero if any axis is on soft limit */ int probeVal; /* debounced value of probe input */ int probeTripped; /* Has the probe signal changed since start of probe command? */ int probing; /* Currently looking for a probe signal? */ EmcPose probedPos; /* Axis positions stored as soon as possible after last probeTripped */ int spindle_index_enable; /* hooked to a canon encoder index-enable */ int spindleSync; /* we are doing spindle-synced motion */ double spindleRevs; /* position of spindle in revolutions */ double spindleSpeedIn; /* velocity of spindle in revolutions per minute */ spindle_status spindle; /* data types for spindle status */ int synch_di[EMCMOT_MAX_DIO]; /* inputs to the motion controller, queried by g-code */ double analog_input[EMCMOT_MAX_AIO]; /* inputs to the motion controller, queried by g-code *//*! \todo FIXME - all structure members beyond this point are in limbo */ /* dynamic status-- changes every cycle */ unsigned int heartbeat; int config_num; /* incremented whenever configuration changed. */ double computeTime; int id; /* id for executing motion */ int depth; /* motion queue depth */ int activeDepth; /* depth of active blend elements */ int queueFull; /* Flag to indicate the tc queue is full */ int paused; /* Flag to signal motion paused */ int overrideLimitMask; /* non-zero means one or more limits ignored */ /* 1 << (joint-num*2) = ignore neg limit */ /* 2 << (joint-num*2) = ignore pos limit */ /* static status-- only changes upon input commands, e.g., config */ double vel; /* scalar max vel */ double acc; /* scalar max accel */ int level; int motionType; double distance_to_go; /* in this move */ double current_vel; unsigned int tcqlen; unsigned char tail; /* flag count for mutex detect */ } emcmot_status_t;/********************************* CONFIG STRUCTURE*********************************//* This is the config structure. This is currently in shared memory, but I have no idea why... there are commands to set most of the items in this structure. It seems we should either put the struct in private memory and manipulate it with commands, or we should put it in shared memory and manipulate it directly - not both. The structure contains static or rarely changed information that describes the machine configuration. later: I think I get it now - the struct is in shared memory so user space can read the config at any time, but commands are used to change the config so they only take effect when the realtime code processes the command.*//*! \todo FIXME - this struct is broken into two parts... at the top are structure members that I understand, and that are needed for emc2. Other structure members follow. All the later ones need to be evaluated - either they move up, or they go away.*/ typedef struct emcmot_config_t { unsigned char head; /* flag count for mutex detect *//*! \todo FIXME - all structure members beyond this point are in limbo */ int config_num; /* Incremented everytime configuration changed, should match status.config_num */ /* FIXME at present, this is getting loaded with num_joints... more of the thrice-damned axis/joints confusion. */ int numAxes; /* The number of axes in the system (which must be between 1 and EMCMOT_MAX_AXIS, inclusive). Allegedly, holds a copy of the global num_axes - seems daft to maintain duplicates ! */ double trajCycleTime; /* the rate at which the trajectory loop runs.... (maybe) */ double servoCycleTime; /* the rate of the servo loop - Not the same as the traj time */ int interpolationRate; /* grep control.c for an explanation.... approx line 50 */ double limitVel; /* scalar upper limit on vel */ KINEMATICS_TYPE kinematics_type; int debug; /* copy of DEBUG, from .ini file */ unsigned char tail; /* flag count for mutex detect */ } emcmot_config_t;/********************************* INTERNAL STRUCTURE*********************************//* This is the internal structure. It contains stuff that is used internally by the motion controller that does not need to be in shared memory. It will wind up with a lot of the stuff that got tossed into the debug structure. FIXME - so far most if the stuff that was tossed in here got moved back out, maybe don't need it after all?*/ typedef struct emcmot_internal_t { unsigned char head; /* flag count for mutex detect */ int probe_debounce_cntr; unsigned char tail; /* flag count for mutex detect */ } emcmot_internal_t;/* error structure - A ring buffer used to pass formatted printf stings to usr space */ typedef struct emcmot_error_t { unsigned char head; /* flag count for mutex detect */ char error[EMCMOT_ERROR_NUM][EMCMOT_ERROR_LEN]; int start; /* index of oldest error */ int end; /* index of newest error */ int num; /* number of items */ unsigned char tail; /* flag count for mutex detect */ } emcmot_error_t;/* function prototypes for emcmot code*//* error ring buffer access functions */ extern int emcmotErrorInit(emcmot_error_t * errlog); extern int emcmotErrorPut(emcmot_error_t * errlog, const char *error); extern int emcmotErrorGet(emcmot_error_t * errlog, char *error);#ifdef __cplusplus}#endif#endif /* EMCMOT_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -