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_REPLY_H
00033 #define MOTOMAN_DRIVER_SIMPLE_MESSAGE_MOTOMAN_MOTION_REPLY_H
00034
00035 #include <string>
00036 #ifdef ROS
00037 #include "simple_message/simple_serialize.h"
00038 #include "simple_message/shared_types.h"
00039 #include "simple_message/log_wrapper.h"
00040 #endif
00041
00042 #ifdef MOTOPLUS
00043 #include "simple_serialize.h"
00044 #include "shared_types.h"
00045 #include "log_wrapper.h"
00046 #endif
00047
00048 namespace motoman
00049 {
00050 namespace simple_message
00051 {
00052 namespace motion_reply
00053 {
00054
00058 namespace MotionReplyResults
00059 {
00060 enum MotionReplyResult
00061 {
00062 SUCCESS = 0,
00063 TRUE = 0,
00064 BUSY = 1,
00065 FAILURE = 2,
00066 FALSE = 2,
00067 INVALID = 3,
00068 ALARM = 4,
00069 NOT_READY = 5,
00070 MP_FAILURE = 6
00071 };
00072 }
00073 typedef MotionReplyResults::MotionReplyResult MotionReplyResult;
00074
00075
00076
00077
00078 namespace MotionReplySubcodes
00079 {
00080 namespace Invalid
00081 {
00082 enum InvalidCode
00083 {
00084 UNSPECIFIED = 3000,
00085 MSGSIZE,
00086 MSGHEADER,
00087 MSGTYPE,
00088 GROUPNO,
00089 SEQUENCE,
00090 COMMAND,
00091 DATA = 3010,
00092 DATA_START_POS,
00093 DATA_POSITION,
00094 DATA_SPEED,
00095 DATA_ACCEL,
00096 DATA_INSUFFICIENT
00097 };
00098 }
00099
00100 namespace NotReady
00101 {
00102 enum NotReadyCode
00103 {
00104 UNSPECIFIED = 5000,
00105 ALARM,
00106 ERROR,
00107 ESTOP,
00108 NOT_PLAY,
00109 NOT_REMOTE,
00110 SERVO_OFF,
00111 HOLD,
00112 NOT_STARTED,
00113 WAITING_ROS,
00114 SKILLSEND
00115 };
00116 }
00117 }
00118
00141 class MotionReply : public industrial::simple_serialize::SimpleSerialize
00142 {
00143 public:
00150 MotionReply(void);
00155 ~MotionReply(void);
00156
00161 void init();
00162
00167 void init(industrial::shared_types::shared_int robot_id,
00168 industrial::shared_types::shared_int sequence,
00169 industrial::shared_types::shared_int command,
00170 MotionReplyResult result,
00171 industrial::shared_types::shared_int subcode,
00172 industrial::shared_types::shared_real data);
00173
00179 void setRobotID(industrial::shared_types::shared_int robot_id)
00180 {
00181 this->robot_id_ = robot_id;
00182 }
00183
00189 industrial::shared_types::shared_int getRobotID() const
00190 {
00191 return this->robot_id_;
00192 }
00193
00199 void setSequence(industrial::shared_types::shared_int sequence)
00200 {
00201 this->sequence_ = sequence;
00202 }
00203
00209 industrial::shared_types::shared_int getSequence() const
00210 {
00211 return this->sequence_;
00212 }
00213
00219 void setCommand(industrial::shared_types::shared_int command)
00220 {
00221 this->command_ = command;
00222 }
00223
00229 industrial::shared_types::shared_int getCommand() const
00230 {
00231 return this->command_;
00232 }
00233
00239 void setResult(industrial::shared_types::shared_int result)
00240 {
00241 this->result_ = result;
00242 }
00243
00249 industrial::shared_types::shared_int getResult() const
00250 {
00251 return this->result_;
00252 }
00253
00259 void setSubcode(industrial::shared_types::shared_int subcode)
00260 {
00261 this->subcode_ = subcode;
00262 }
00263
00269 industrial::shared_types::shared_int getSubcode() const
00270 {
00271 return this->subcode_;
00272 }
00273
00277 void clearData()
00278 {
00279 for (size_t i = 0; i < MAX_DATA_CNT; ++i)
00280 this->data_[i] = 0.0;
00281 }
00282
00289 void setData(size_t idx, industrial::shared_types::shared_real val)
00290 {
00291 if (idx < MAX_DATA_CNT)
00292 this->data_[idx] = val;
00293 else
00294 LOG_ERROR("MotionReply data index out-of-range (%d >= %d)",
00295 static_cast<int>(idx), static_cast<int>(MAX_DATA_CNT));
00296 }
00297
00304 industrial::shared_types::shared_real getData(size_t idx) const
00305 {
00306 if (idx < MAX_DATA_CNT)
00307 {
00308 return this->data_[idx];
00309 }
00310 else
00311 {
00312 LOG_ERROR("MotionReply data index out-of-range (%d >= %d)",
00313 static_cast<int>(idx), static_cast<int>(MAX_DATA_CNT));
00314
00315 return 0;
00316 }
00317 }
00318
00319
00320
00321
00322
00323
00324 static std::string getResultString(industrial::shared_types::shared_int code);
00325 std::string getResultString() const
00326 {
00327 return getResultString(this->result_);
00328 }
00329
00330
00331
00332
00333
00334
00335 static std::string getSubcodeString(industrial::shared_types::shared_int code);
00336 std::string getSubcodeString() const
00337 {
00338 return getSubcodeString(this->subcode_);
00339 }
00340
00341
00347 void copyFrom(MotionReply &src);
00348
00354 bool operator==(MotionReply &rhs);
00355
00356
00357 bool load(industrial::byte_array::ByteArray *buffer);
00358 bool unload(industrial::byte_array::ByteArray *buffer);
00359 unsigned int byteLength()
00360 {
00361 return 5 * sizeof(industrial::shared_types::shared_int) +
00362 MAX_DATA_CNT * sizeof(industrial::shared_types::shared_real);
00363 }
00364
00365 private:
00370 industrial::shared_types::shared_int robot_id_;
00371
00375 industrial::shared_types::shared_int sequence_;
00376
00380 industrial::shared_types::shared_int command_;
00381
00385 industrial::shared_types::shared_int result_;
00386
00390 industrial::shared_types::shared_int subcode_;
00391
00395 static const size_t MAX_DATA_CNT = 10;
00396
00401 industrial::shared_types::shared_real data_[MAX_DATA_CNT];
00402 };
00403 }
00404 }
00405 }
00406
00407 #endif // MOTOMAN_DRIVER_SIMPLE_MESSAGE_MOTOMAN_MOTION_REPLY_H