SimpleMessage.h
Go to the documentation of this file.
00001 // SimpleMessage.h
00002 //
00003 /*
00004 * Software License Agreement (BSD License) 
00005 *
00006 * Copyright (c) 2013, Yaskawa America, Inc.
00007 * All rights reserved.
00008 *
00009 * Redistribution and use in binary form, with or without modification,
00010 * is permitted provided that the following conditions are met:
00011 *
00012 *       * Redistributions in binary form must reproduce the above copyright
00013 *       notice, this list of conditions and the following disclaimer in the
00014 *       documentation and/or other materials provided with the distribution.
00015 *       * Neither the name of the Yaskawa America, Inc., nor the names 
00016 *       of its contributors may be used to endorse or promote products derived
00017 *       from this software without specific prior written permission.
00018 *
00019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00020 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00021 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00022 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00023 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00024 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00025 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00026 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00027 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00028 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00029 * POSSIBILITY OF SUCH DAMAGE.
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 // Prefix Section
00040 //----------------
00041 
00042 typedef struct
00043 {
00044         int length;
00045 } SmPrefix;
00046 
00047 //----------------
00048 // Header Section
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, // starts the servo motors
00100         ROS_CMD_STOP_SERVOS = 200113, // stops the servo motors and motion
00101         ROS_CMD_RESET_ALARM = 200114, // clears the error in the current controller
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 // Body Section
00174 //--------------
00175 
00176 struct _SmBodyRobotStatus               // ROS_MSG_ROBOT_STATUS = 13
00177 {
00178         int drives_powered;                     // Servo Power: -1=Unknown, 1=ON, 0=OFF
00179         int e_stopped;                          // Controller E-Stop state: -1=Unknown, 1=True(ON), 0=False(OFF)
00180         int error_code;                         // Alarm code
00181         int in_error;                           // Is there an alarm:   -1=Unknown, 1=True, 0=False 
00182         int in_motion;                          // Is currently executing a motion command:  -1=Unknown, 1=True, 0=False 
00183         int mode;                                       // Controller/Pendant mode: -1=Unknown, 1=Manual(TEACH), 2=Auto(PLAY)
00184         int motion_possible;            // Is the controller ready to receive motion: -1=Unknown, 1=ENABLED, 0=DISABLED 
00185 } __attribute__((__packed__));
00186 typedef struct _SmBodyRobotStatus SmBodyRobotStatus;
00187 
00188 struct _SmBodyJointTrajPtFull   // ROS_MSG_JOINT_TRAJ_PT_FULL = 14
00189 {
00190         int groupNo;                            // Robot/group ID;  0 = 1st robot 
00191         int sequence;                           // Index of point in trajectory; 0 = Initial trajectory point, which should match the robot current position.
00192         FlagsValidFields validFields;   // Bit-mask indicating which “optional” fields are filled with data. 1=time, 2=position, 4=velocity, 8=acceleration
00193         float time;                                     // Timestamp associated with this trajectory point; Units: in seconds 
00194         float pos[ROS_MAX_JOINT];       // Desired joint positions in radian.  Base to Tool joint order  
00195         float vel[ROS_MAX_JOINT];       // Desired joint velocities in radian/sec.  
00196         float acc[ROS_MAX_JOINT];       // Desired joint accelerations in radian/sec^2.
00197 } __attribute__((__packed__));
00198 typedef struct _SmBodyJointTrajPtFull SmBodyJointTrajPtFull;
00199 
00200 struct _SmBodyJointFeedback             // ROS_MSG_JOINT_FEEDBACK = 15
00201 {
00202         int groupNo;                            // Robot/group ID;  0 = 1st robot 
00203         FlagsValidFields validFields;   // Bit-mask indicating which “optional” fields are filled with data. 1=time, 2=position, 4=velocity, 8=acceleration
00204         float time;                                     // Timestamp associated with this trajectory point; Units: in seconds 
00205         float pos[ROS_MAX_JOINT];       // Feedback joint positions in radian.  Base to Tool joint order  
00206         float vel[ROS_MAX_JOINT];       // Feedback joint velocities in radian/sec.  
00207         float acc[ROS_MAX_JOINT];       // Feedback joint accelerations in radian/sec^2.
00208 } __attribute__((__packed__));
00209 typedef struct _SmBodyJointFeedback SmBodyJointFeedback;
00210 
00211 
00212 struct _SmBodyMotoMotionCtrl    // ROS_MSG_MOTO_MOTION_CTRL = 2001
00213 {
00214         int groupNo;                            // Robot/group ID;  0 = 1st robot 
00215         int sequence;                           // Optional message tracking number that will be echoed back in the response.
00216         SmCommandType command;          // Desired command
00217         float data[ROS_MAX_JOINT];      // Command data - for future use  
00218 } __attribute__((__packed__));
00219 typedef struct _SmBodyMotoMotionCtrl SmBodyMotoMotionCtrl;
00220 
00221 
00222 struct _SmBodyMotoMotionReply   // ROS_MSG_MOTO_MOTION_REPLY = 2002
00223 {
00224         int groupNo;                            // Robot/group ID;  0 = 1st robot 
00225         int sequence;                           // Optional message tracking number that will be echoed back in the response.
00226         int command;                            // Reference to the received message command or type
00227         SmResultType result;            // High level result code
00228         int subcode;                            // More detailed result code (optional)
00229         float data[ROS_MAX_JOINT];      // Reply data - for future use 
00230 } __attribute__((__packed__));
00231 typedef struct _SmBodyMotoMotionReply SmBodyMotoMotionReply;
00232 
00233 struct _SmBodyJointTrajPtExData
00234 {
00235         int groupNo;                            // Robot/group ID;  0 = 1st robot 
00236         FlagsValidFields validFields;   // Bit-mask indicating which “optional” fields are filled with data. 1=time, 2=position, 4=velocity, 8=acceleration
00237         float time;                                     // Timestamp associated with this trajectory point; Units: in seconds 
00238         float pos[ROS_MAX_JOINT];       // Desired joint positions in radian.  Base to Tool joint order  
00239         float vel[ROS_MAX_JOINT];       // Desired joint velocities in radian/sec.  
00240         float acc[ROS_MAX_JOINT];       // Desired joint accelerations in radian/sec^2.
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 // IO Commands
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   // ROS_MSG_MOTO_IOCTRL_REPLY = 2011
00317 {
00318         SmResultType result;            // High level result code
00319         int subcode;                            // More detailed result code (optional)
00320 } __attribute__((__packed__));
00321 typedef struct _SmBodyMotoIoCtrlReply SmBodyMotoIoCtrlReply;
00322 
00323 //--------------
00324 // Body Union
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 // SimpleMsg Section
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 // Function Section
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 //Uncomment the DEBUG definition to enable debug-messages at runtime
00371 //#define DEBUG  1
00372 
00373 #ifdef DEBUG
00374 #warning Dont forget to disable the DEBUG flag
00375 // function to dump data structure for debugging
00376 extern void Ros_SimpleMsg_DumpTrajPtFull(SmBodyJointTrajPtFull* data);
00377 #endif
00378 
00379 #endif


motoman_driver
Author(s): Jeremy Zoss (Southwest Research Institute)
autogenerated on Sat Jun 8 2019 19:06:58