⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 motion.h

📁 Source code for an Numeric Cmputer
💻 H
📖 第 1 页 / 共 2 页
字号:
   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;	/* jogs stop just short of soft limits */	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 */	int switch_flags;	/* config flags for limit switches */	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 */	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 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 */	/* internal info - changes regularly, not usually accessed from user	   space */	CUBIC_STRUCT cubic;	/* cubic interpolator data */	double pos_limit_pos;	/* latched position of limit sw */	int pos_limit_latch;	/* non-zero if on limit */	double neg_limit_pos;	/* latched position of limit sw */	int neg_limit_latch;	/* non-zero if on limit */	double home_sw_pos;	/* latched position of home sw */	int home_pause_timer;	/* used to delay between homing states */	char home_sw_old;	/* previous value, for edge detection */	int index_pulse;	/* current state of index pulse input */	int index_pulse_edge;	/* non-zero if rising edge detected */	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 */	/* 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;/*********************************        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 {	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 qVscale;		/* velocity scale factor for all motion */	/* the rest are updated every cycle */	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 */	emcmot_joint_status_t joint_status[EMCMOT_MAX_AXIS];	/* all joint status data */	int onSoftLimit;	/* non-zero if any axis is on soft limit */	int probeVal;		/* debounced value of probe input *//*! \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 overrideLimits;	/* non-zero means limits are ignored */	/* static status-- only changes upon input commands, e.g., config */#if 0	double axVscale[EMCMOT_MAX_AXIS];	/* axis velocity scale factor 						 */#endif	double vel;		/* scalar max vel */	double acc;		/* scalar max accel */	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 level;	unsigned char tail;	/* flag count for mutex detect */        int motionType;                int spindleSync;        /* request synchronization:                                    tell spindle encoder to not reset at index */        double spindleRevs;     /* position of spindle in revolutions */    } 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 {	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 */	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 {	unsigned char head;	/* flag count for mutex detect */	int probe_debounce_cntr;	unsigned char tail;	/* flag count for mutex detect */    } emcmot_internal_t;/*********************************        DEBUG STRUCTURE*********************************//* This is the debug structure.  I guess it was intended to make some   of the motion controller's internal variables visible from user   space for debugging, but it has evolved into a monster.   180K last time I checked - most of it (174K or so) is the traj   planner queues... each entry is 720 bytes, and there are 210   entries in the main queue.   I'll figure it out eventually though.   Low level things will be exported thru the HAL so they can be   monitored with halscope.  High level things will remain here,   and things that are internal will be moved to a private structure.*//*! \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.*//*! \todo FIXME - this has become a dumping ground for all kinds of stuff */    typedef struct {	unsigned char head;	/* flag count for mutex detect *//*! \todo FIXME - all structure members beyond this point are in limbo */	double tMin, tMax, tAvg;	/* trajectory min, max, avg times */	double sMin, sMax, sAvg;	/* servo min, max, avg times */	double nMin, nMax, nAvg;	/* min, max, avg times in DISABLED					   mode */	double yMin, yMax, yAvg;	/* min, max, avg times cycle times					   rather than compute */	double fMin, fMax, fAvg;	/* min, max, avg times frequency */	double fyMin, fyMax, fyAvg;	/* min, max, avg times frequency					   cycle times rather than compute */	EMC_TELEOP_DATA teleop_data;	int split;		/* number of split command reads */	/* flag for enabling, disabling watchdog; multiple for down-stepping */	int wdEnabling;	int wdEnabled;	int wdWait;	int wdCount;	unsigned char wdToggle;	/* flag that all active axes are homed */	unsigned char allHomed;	TP_STRUCT queue;	/* coordinated mode planner *//* space for trajectory planner queues, plus 10 more for safety *//*! \todo FIXME-- default is used; dynamic is not honored */	TC_STRUCT queueTcSpace[DEFAULT_TC_QUEUE_SIZE + 10];	EmcPose oldPos;		/* last position, used for vel differencing */	EmcPose oldVel, newVel;	/* velocities, used for acc differencing */	EmcPose newAcc;		/* differenced acc */	int enabling;		/* starts up disabled */	int coordinating;	/* starts up in free mode */	int teleoperating;	/* starts up in free mode */#if 0	int wasOnLimit;		/* non-zero means we already aborted				   everything due to a soft limit, and need				   not re-abort. It's cleared only when all				   limits are cleared. */	int onLimit;		/* non-zero means at least one axis is on a				   soft limit */#endif	int overriding;		/* non-zero means we've initiated an axis				   move while overriding limits */	int stepping;	int idForStep;#ifdef STRUCTS_IN_SHMEM	emcmot_joint_t joints[EMCMOT_MAX_AXIS];	/* joint data */#endif	/* min-max-avg structs for traj and servo cycles */	MMXAVG_STRUCT tMmxavg;	MMXAVG_STRUCT sMmxavg;	MMXAVG_STRUCT nMmxavg;	MMXAVG_STRUCT yMmxavg;	MMXAVG_STRUCT fMmxavg;	MMXAVG_STRUCT fyMmxavg;	double tMmxavgSpace[DEFAULT_MMXAVG_SIZE];	double sMmxavgSpace[DEFAULT_MMXAVG_SIZE];	double nMmxavgSpace[DEFAULT_MMXAVG_SIZE];	double yMmxavgSpace[DEFAULT_MMXAVG_SIZE];	double fMmxavgSpace[DEFAULT_MMXAVG_SIZE];	double fyMmxavgSpace[DEFAULT_MMXAVG_SIZE];	double start_time;	double running_time;	double cur_time;	double last_time;	unsigned char tail;	/* flag count for mutex detect */    } emcmot_debug_t;/* error structure - A ring buffer used to pass formatted printf stings to usr space */    typedef struct {	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;/* big comm structure, for upper memory */    typedef struct {	emcmot_command_t command;	/* struct used to pass commands/data					   to the RT module from usr space */	emcmot_status_t status;	/* Struct used to store RT status */	emcmot_config_t config;	/* Struct used to store RT config */	emcmot_debug_t debug;	/* Struct used to store RT status and debug				   data - 2nd largest block */	emcmot_internal_t internal;	/*! \todo FIXME - doesn't need to be in					   shared memory */	emcmot_error_t error;	/* ring buffer for error messages */    } emcmot_struct_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 + -