Go to the documentation of this file.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 MOTOMAN_MOTION_CTRL_H
00033 #define MOTOMAN_MOTION_CTRL_H
00034
00035 #ifdef ROS
00036 #include "simple_message/simple_serialize.h"
00037 #include "simple_message/shared_types.h"
00038 #include "simple_message/log_wrapper.h"
00039 #endif
00040
00041 #ifdef MOTOPLUS
00042 #include "simple_serialize.h"
00043 #include "shared_types.h"
00044 #include "log_wrapper.h"
00045 #endif
00046
00047 namespace motoman
00048 {
00049 namespace simple_message
00050 {
00051 namespace motion_ctrl
00052 {
00053
00057 namespace MotionControlCmds
00058 {
00059 enum MotionControlCmd
00060 {
00061 UNDEFINED = 0,
00062 CHECK_MOTION_READY = 200101,
00063 CHECK_QUEUE_CNT = 200102,
00064 STOP_MOTION = 200111,
00065 START_TRAJ_MODE = 200121,
00066 STOP_TRAJ_MODE = 200122,
00067 };
00068 }
00069 typedef MotionControlCmds::MotionControlCmd MotionControlCmd;
00070
00092 class MotionCtrl : public industrial::simple_serialize::SimpleSerialize
00093 {
00094 public:
00101 MotionCtrl(void);
00106 ~MotionCtrl(void);
00107
00112 void init();
00113
00118 void init(industrial::shared_types::shared_int robot_id,
00119 industrial::shared_types::shared_int sequence,
00120 MotionControlCmd command,
00121 industrial::shared_types::shared_real data);
00122
00128 void setRobotID(industrial::shared_types::shared_int robot_id)
00129 {
00130 this->robot_id_ = robot_id;
00131 }
00132
00138 industrial::shared_types::shared_int getRobotID()
00139 {
00140 return this->robot_id_;
00141 }
00142
00148 void setSequence(industrial::shared_types::shared_int sequence)
00149 {
00150 this->sequence_ = sequence;
00151 }
00152
00158 industrial::shared_types::shared_int getSequence()
00159 {
00160 return this->sequence_;
00161 }
00162
00168 void setCommand(MotionControlCmd command)
00169 {
00170 this->command_ = command;
00171 }
00172
00178 MotionControlCmd getCommand()
00179 {
00180 return (MotionControlCmd)this->command_;
00181 }
00182
00186 void clearData()
00187 {
00188 for (size_t i=0; i<MAX_DATA_CNT; ++i)
00189 this->data_[i] = 0.0;
00190 }
00191
00198 void setData(size_t idx, industrial::shared_types::shared_real val)
00199 {
00200 if (idx<MAX_DATA_CNT)
00201 this->data_[idx] = val;
00202 else
00203 LOG_ERROR("MotionCtrl data index out-of-range (%d >= %d)",
00204 (int)idx, (int)MAX_DATA_CNT);
00205 }
00206
00213 industrial::shared_types::shared_real getData(size_t idx)
00214 {
00215 if (idx<MAX_DATA_CNT)
00216 {
00217 return this->data_[idx];
00218 }
00219 else
00220 {
00221 LOG_ERROR("MotionCtrl data index out-of-range (%d >= %d)",
00222 (int)idx, (int)MAX_DATA_CNT);
00223
00224 return 0;
00225 }
00226 }
00227
00233 void copyFrom(MotionCtrl &src);
00234
00240 bool operator==(MotionCtrl &rhs);
00241
00242
00243 bool load(industrial::byte_array::ByteArray *buffer);
00244 bool unload(industrial::byte_array::ByteArray *buffer);
00245 unsigned int byteLength()
00246 {
00247 return 3*sizeof(industrial::shared_types::shared_int) +
00248 MAX_DATA_CNT*sizeof(industrial::shared_types::shared_real);
00249 }
00250
00251 private:
00252
00257 industrial::shared_types::shared_int robot_id_;
00258
00262 industrial::shared_types::shared_int sequence_;
00263
00267 industrial::shared_types::shared_int command_;
00268
00272 static const size_t MAX_DATA_CNT = 10;
00273
00278 industrial::shared_types::shared_real data_[MAX_DATA_CNT];
00279
00280 };
00281
00282 }
00283 }
00284 }
00285
00286 #endif