00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef SIMPLE_MSG_H
00033 #define SIMPLE_MSG_H
00034
00035 #define ROS_MAX_JOINT 10
00036 #define MOT_MAX_GR 4
00037
00038
00039
00040
00041
00042 typedef struct
00043 {
00044 int length;
00045 } SmPrefix;
00046
00047
00048
00049
00050
00051 typedef enum
00052 {
00053 ROS_MSG_GET_VERSION = 2,
00054 ROS_MSG_ROBOT_STATUS = 13,
00055
00056 ROS_MSG_JOINT_TRAJ_PT_FULL = 14,
00057 ROS_MSG_JOINT_FEEDBACK = 15,
00058
00059 ROS_MSG_MOTO_MOTION_CTRL = 2001,
00060 ROS_MSG_MOTO_MOTION_REPLY = 2002,
00061
00062 ROS_MSG_MOTO_READ_IO_BIT = 2003,
00063 ROS_MSG_MOTO_READ_IO_BIT_REPLY = 2004,
00064 ROS_MSG_MOTO_WRITE_IO_BIT = 2005,
00065 ROS_MSG_MOTO_WRITE_IO_BIT_REPLY = 2006,
00066 ROS_MSG_MOTO_READ_IO_GROUP = 2007,
00067 ROS_MSG_MOTO_READ_IO_GROUP_REPLY = 2008,
00068 ROS_MSG_MOTO_WRITE_IO_GROUP = 2009,
00069 ROS_MSG_MOTO_WRITE_IO_GROUP_REPLY = 2010,
00070 ROS_MSG_MOTO_IOCTRL_REPLY = 2011,
00071
00072 ROS_MSG_MOTO_JOINT_TRAJ_PT_FULL_EX = 2016,
00073 ROS_MSG_MOTO_JOINT_FEEDBACK_EX = 2017
00074 } SmMsgType;
00075
00076
00077 typedef enum
00078 {
00079 ROS_COMM_INVALID = 0,
00080 ROS_COMM_TOPIC = 1,
00081 ROS_COMM_SERVICE_REQUEST = 2,
00082 ROS_COMM_SERVICE_REPLY = 3
00083 } SmCommType;
00084
00085
00086 typedef enum
00087 {
00088 ROS_REPLY_INVALID = 0,
00089 ROS_REPLY_SUCCESS = 1,
00090 ROS_REPLY_FAILURE = 2,
00091 } SmReplyType;
00092
00093
00094 typedef enum
00095 {
00096 ROS_CMD_CHECK_MOTION_READY = 200101,
00097 ROS_CMD_CHECK_QUEUE_CNT = 200102,
00098 ROS_CMD_STOP_MOTION = 200111,
00099 ROS_CMD_START_SERVOS = 200112,
00100 ROS_CMD_STOP_SERVOS = 200113,
00101 ROS_CMD_RESET_ALARM = 200114,
00102 ROS_CMD_START_TRAJ_MODE = 200121,
00103 ROS_CMD_STOP_TRAJ_MODE = 200122,
00104 ROS_CMD_DISCONNECT = 200130
00105 } SmCommandType;
00106
00107
00108 typedef enum
00109 {
00110 ROS_RESULT_SUCCESS = 0,
00111 ROS_RESULT_TRUE = 0,
00112 ROS_RESULT_BUSY = 1,
00113 ROS_RESULT_FAILURE = 2,
00114 ROS_RESULT_FALSE = 2,
00115 ROS_RESULT_INVALID = 3,
00116 ROS_RESULT_ALARM = 4,
00117 ROS_RESULT_NOT_READY = 5,
00118 ROS_RESULT_MP_FAILURE = 6
00119 } SmResultType;
00120
00121
00122 typedef enum
00123 {
00124 ROS_RESULT_INVALID_UNSPECIFIED = 3000,
00125 ROS_RESULT_INVALID_MSGSIZE,
00126 ROS_RESULT_INVALID_MSGHEADER,
00127 ROS_RESULT_INVALID_MSGTYPE,
00128 ROS_RESULT_INVALID_GROUPNO,
00129 ROS_RESULT_INVALID_SEQUENCE,
00130 ROS_RESULT_INVALID_COMMAND,
00131 ROS_RESULT_INVALID_DATA = 3010,
00132 ROS_RESULT_INVALID_DATA_START_POS,
00133 ROS_RESULT_INVALID_DATA_POSITION,
00134 ROS_RESULT_INVALID_DATA_SPEED,
00135 ROS_RESULT_INVALID_DATA_ACCEL,
00136 ROS_RESULT_INVALID_DATA_INSUFFICIENT
00137 } SmInvalidSubCode;
00138
00139
00140 typedef enum
00141 {
00142 ROS_RESULT_NOT_READY_UNSPECIFIED = 5000,
00143 ROS_RESULT_NOT_READY_ALARM,
00144 ROS_RESULT_NOT_READY_ERROR,
00145 ROS_RESULT_NOT_READY_ESTOP,
00146 ROS_RESULT_NOT_READY_NOT_PLAY,
00147 ROS_RESULT_NOT_READY_NOT_REMOTE,
00148 ROS_RESULT_NOT_READY_SERVO_OFF,
00149 ROS_RESULT_NOT_READY_HOLD,
00150 ROS_RESULT_NOT_READY_NOT_STARTED,
00151 ROS_RESULT_NOT_READY_WAITING_ROS,
00152 ROS_RESULT_NOT_READY_SKILLSEND
00153 } SmNotReadySubcode;
00154
00155
00156 struct _SmHeader
00157 {
00158 SmMsgType msgType;
00159 SmCommType commType;
00160 SmReplyType replyType;
00161 } __attribute__((__packed__));
00162 typedef struct _SmHeader SmHeader;
00163
00164 typedef enum
00165 {
00166 Valid_Time = 1,
00167 Valid_Position = 2,
00168 Valid_Velocity = 4,
00169 Valid_Acceleration = 8
00170 } FlagsValidFields;
00171
00172
00173
00174
00175
00176 struct _SmBodyRobotStatus
00177 {
00178 int drives_powered;
00179 int e_stopped;
00180 int error_code;
00181 int in_error;
00182 int in_motion;
00183 int mode;
00184 int motion_possible;
00185 } __attribute__((__packed__));
00186 typedef struct _SmBodyRobotStatus SmBodyRobotStatus;
00187
00188 struct _SmBodyJointTrajPtFull
00189 {
00190 int groupNo;
00191 int sequence;
00192 FlagsValidFields validFields;
00193 float time;
00194 float pos[ROS_MAX_JOINT];
00195 float vel[ROS_MAX_JOINT];
00196 float acc[ROS_MAX_JOINT];
00197 } __attribute__((__packed__));
00198 typedef struct _SmBodyJointTrajPtFull SmBodyJointTrajPtFull;
00199
00200 struct _SmBodyJointFeedback
00201 {
00202 int groupNo;
00203 FlagsValidFields validFields;
00204 float time;
00205 float pos[ROS_MAX_JOINT];
00206 float vel[ROS_MAX_JOINT];
00207 float acc[ROS_MAX_JOINT];
00208 } __attribute__((__packed__));
00209 typedef struct _SmBodyJointFeedback SmBodyJointFeedback;
00210
00211
00212 struct _SmBodyMotoMotionCtrl
00213 {
00214 int groupNo;
00215 int sequence;
00216 SmCommandType command;
00217 float data[ROS_MAX_JOINT];
00218 } __attribute__((__packed__));
00219 typedef struct _SmBodyMotoMotionCtrl SmBodyMotoMotionCtrl;
00220
00221
00222 struct _SmBodyMotoMotionReply
00223 {
00224 int groupNo;
00225 int sequence;
00226 int command;
00227 SmResultType result;
00228 int subcode;
00229 float data[ROS_MAX_JOINT];
00230 } __attribute__((__packed__));
00231 typedef struct _SmBodyMotoMotionReply SmBodyMotoMotionReply;
00232
00233 struct _SmBodyJointTrajPtExData
00234 {
00235 int groupNo;
00236 FlagsValidFields validFields;
00237 float time;
00238 float pos[ROS_MAX_JOINT];
00239 float vel[ROS_MAX_JOINT];
00240 float acc[ROS_MAX_JOINT];
00241 } __attribute__((__packed__));
00242 typedef struct _SmBodyJointTrajPtExData SmBodyJointTrajPtExData;
00243
00244 struct _SmBodyJointTrajPtFullEx
00245 {
00246 int numberOfValidGroups;
00247 int sequence;
00248 SmBodyJointTrajPtExData jointTrajPtData[MOT_MAX_GR];
00249 } __attribute__((__packed__));
00250 typedef struct _SmBodyJointTrajPtFullEx SmBodyJointTrajPtFullEx;
00251
00252
00253 struct _SmBodyJointFeedbackEx
00254 {
00255 int numberOfValidGroups;
00256 SmBodyJointFeedback jointTrajPtData[MOT_MAX_GR];
00257 } __attribute__((__packed__));
00258 typedef struct _SmBodyJointFeedbackEx SmBodyJointFeedbackEx;
00259
00260
00261
00262
00263
00264 struct _SmBodyMotoReadIOBit
00265 {
00266 UINT32 ioAddress;
00267 } __attribute__((__packed__));
00268 typedef struct _SmBodyMotoReadIOBit SmBodyMotoReadIOBit;
00269
00270 struct _SmBodyMotoReadIOBitReply
00271 {
00272 UINT32 value;
00273 UINT32 resultCode;
00274 } __attribute__((__packed__));
00275 typedef struct _SmBodyMotoReadIOBitReply SmBodyMotoReadIOBitReply;
00276
00277 struct _SmBodyMotoWriteIOBit
00278 {
00279 UINT32 ioAddress;
00280 UINT32 ioValue;
00281 } __attribute__((__packed__));
00282 typedef struct _SmBodyMotoWriteIOBit SmBodyMotoWriteIOBit;
00283
00284 struct _SmBodyMotoWriteIOBitReply
00285 {
00286 UINT32 resultCode;
00287 } __attribute__((__packed__));
00288 typedef struct _SmBodyMotoWriteIOBitReply SmBodyMotoWriteIOBitReply;
00289
00290 struct _SmBodyMotoReadIOGroup
00291 {
00292 UINT32 ioAddress;
00293 } __attribute__((__packed__));
00294 typedef struct _SmBodyMotoReadIOGroup SmBodyMotoReadIOGroup;
00295
00296 struct _SmBodyMotoReadIOGroupReply
00297 {
00298 UINT32 value;
00299 UINT32 resultCode;
00300 } __attribute__((__packed__));
00301 typedef struct _SmBodyMotoReadIOGroupReply SmBodyMotoReadIOGroupReply;
00302
00303 struct _SmBodyMotoWriteIOGroup
00304 {
00305 UINT32 ioAddress;
00306 UINT32 ioValue;
00307 } __attribute__((__packed__));
00308 typedef struct _SmBodyMotoWriteIOGroup SmBodyMotoWriteIOGroup;
00309
00310 struct _SmBodyMotoWriteIOGroupReply
00311 {
00312 UINT32 resultCode;
00313 } __attribute__((__packed__));
00314 typedef struct _SmBodyMotoWriteIOGroupReply SmBodyMotoWriteIOGroupReply;
00315
00316 struct _SmBodyMotoIoCtrlReply
00317 {
00318 SmResultType result;
00319 int subcode;
00320 } __attribute__((__packed__));
00321 typedef struct _SmBodyMotoIoCtrlReply SmBodyMotoIoCtrlReply;
00322
00323
00324
00325
00326
00327 typedef union
00328 {
00329 SmBodyRobotStatus robotStatus;
00330 SmBodyJointTrajPtFull jointTrajData;
00331 SmBodyJointFeedback jointFeedback;
00332 SmBodyMotoMotionCtrl motionCtrl;
00333 SmBodyMotoMotionReply motionReply;
00334 SmBodyJointTrajPtFullEx jointTrajDataEx;
00335 SmBodyJointFeedbackEx jointFeedbackEx;
00336 SmBodyMotoReadIOBit readIOBit;
00337 SmBodyMotoReadIOBitReply readIOBitReply;
00338 SmBodyMotoWriteIOBit writeIOBit;
00339 SmBodyMotoWriteIOBitReply writeIOBitReply;
00340 SmBodyMotoReadIOGroup readIOGroup;
00341 SmBodyMotoReadIOGroupReply readIOGroupReply;
00342 SmBodyMotoWriteIOGroup writeIOGroup;
00343 SmBodyMotoWriteIOGroupReply writeIOGroupReply;
00344 SmBodyMotoIoCtrlReply ioCtrlReply;
00345 } SmBody;
00346
00347
00348
00349
00350 struct _SimpleMsg
00351 {
00352 SmPrefix prefix;
00353 SmHeader header;
00354 SmBody body;
00355 } __attribute__((__packed__));
00356 typedef struct _SimpleMsg SimpleMsg;
00357
00358
00359
00360
00361
00362
00363 extern int Ros_SimpleMsg_JointFeedback(CtrlGroup* ctrlGroup, SimpleMsg* sendMsg);
00364 extern void Ros_SimpleMsg_JointFeedbackEx_Init(int numberOfGroups, SimpleMsg* sendMsg);
00365 extern int Ros_SimpleMsg_JointFeedbackEx_Build(int groupIndex, SimpleMsg* src_msgFeedback, SimpleMsg* dst_msgExtendedFeedback);
00366
00367 extern int Ros_SimpleMsg_MotionReply(SimpleMsg* receiveMsg, int result, int subcode, SimpleMsg* replyMsg, int ctrlGrp);
00368 extern int Ros_SimpleMsg_IoReply(int result, int subcode, SimpleMsg* replyMsg);
00369
00370
00371
00372
00373 #ifdef DEBUG
00374 #warning Dont forget to disable the DEBUG flag
00375
00376 extern void Ros_SimpleMsg_DumpTrajPtFull(SmBodyJointTrajPtFull* data);
00377 #endif
00378
00379 #endif