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_DRIVER_SIMPLE_MESSAGE_MOTOMAN_MOTION_CTRL_H
00033 #define MOTOMAN_DRIVER_SIMPLE_MESSAGE_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 {
00056 namespace MotionControlCmds
00057 {
00058 enum MotionControlCmd
00059 {
00060 UNDEFINED = 0,
00061 CHECK_MOTION_READY = 200101,
00062 CHECK_QUEUE_CNT = 200102,
00063 STOP_MOTION = 200111,
00064 START_TRAJ_MODE = 200121,
00065 STOP_TRAJ_MODE = 200122,
00066 };
00067 }
00068 typedef MotionControlCmds::MotionControlCmd MotionControlCmd;
00069
00091 class MotionCtrl : public industrial::simple_serialize::SimpleSerialize
00092 {
00093 public:
00100 MotionCtrl(void);
00105 ~MotionCtrl(void);
00106
00111 void init();
00112
00117 void init(industrial::shared_types::shared_int robot_id,
00118 industrial::shared_types::shared_int sequence,
00119 MotionControlCmd command,
00120 industrial::shared_types::shared_real data);
00121
00127 void setRobotID(industrial::shared_types::shared_int robot_id)
00128 {
00129 this->robot_id_ = robot_id;
00130 }
00131
00137 industrial::shared_types::shared_int getRobotID()
00138 {
00139 return this->robot_id_;
00140 }
00141
00147 void setSequence(industrial::shared_types::shared_int sequence)
00148 {
00149 this->sequence_ = sequence;
00150 }
00151
00157 industrial::shared_types::shared_int getSequence()
00158 {
00159 return this->sequence_;
00160 }
00161
00167 void setCommand(MotionControlCmd command)
00168 {
00169 this->command_ = command;
00170 }
00171
00177 MotionControlCmd getCommand()
00178 {
00179 return (MotionControlCmd)this->command_;
00180 }
00181
00185 void clearData()
00186 {
00187 for (size_t i = 0; i < MAX_DATA_CNT; ++i)
00188 this->data_[i] = 0.0;
00189 }
00190
00197 void setData(size_t idx, industrial::shared_types::shared_real val)
00198 {
00199 if (idx < MAX_DATA_CNT)
00200 this->data_[idx] = val;
00201 else
00202 LOG_ERROR("MotionCtrl data index out-of-range (%d >= %d)",
00203 static_cast<int>(idx), static_cast<int>(MAX_DATA_CNT));
00204 }
00205
00212 industrial::shared_types::shared_real getData(size_t idx)
00213 {
00214 if (idx < MAX_DATA_CNT)
00215 {
00216 return this->data_[idx];
00217 }
00218 else
00219 {
00220 LOG_ERROR("MotionCtrl data index out-of-range (%d >= %d)",
00221 static_cast<int>(idx), static_cast<int>(MAX_DATA_CNT));
00222
00223 return 0;
00224 }
00225 }
00226
00232 void copyFrom(MotionCtrl &src);
00233
00239 bool operator==(MotionCtrl &rhs);
00240
00241
00242 bool load(industrial::byte_array::ByteArray *buffer);
00243 bool unload(industrial::byte_array::ByteArray *buffer);
00244 unsigned int byteLength()
00245 {
00246 return 3 * sizeof(industrial::shared_types::shared_int) +
00247 MAX_DATA_CNT * sizeof(industrial::shared_types::shared_real);
00248 }
00249
00250 private:
00255 industrial::shared_types::shared_int robot_id_;
00256
00260 industrial::shared_types::shared_int sequence_;
00261
00265 industrial::shared_types::shared_int command_;
00266
00270 static const size_t MAX_DATA_CNT = 10;
00271
00276 industrial::shared_types::shared_real data_[MAX_DATA_CNT];
00277 };
00278 }
00279 }
00280 }
00281
00282 #endif