motoman_motion_reply.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  * Copyright (c) 2013, Southwest Research Institute
00005  * All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions are met:
00009  *
00010  *      * Redistributions of source code must retain the above copyright
00011  *      notice, this list of conditions and the following disclaimer.
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 Southwest Research Institute, 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 MOTOMAN_MOTION_REPLY_H
00033 #define MOTOMAN_MOTION_REPLY_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_reply
00052 {
00053 
00057 namespace MotionReplyResults
00058 {
00059   enum MotionReplyResult
00060   {
00061     SUCCESS    = 0,
00062     TRUE       = 0,
00063     BUSY       = 1,
00064     FAILURE    = 2,
00065     FALSE      = 2,
00066     INVALID    = 3,
00067     ALARM      = 4,
00068     NOT_READY  = 5,
00069     MP_FAILURE = 6
00070   };
00071 }
00072 typedef MotionReplyResults::MotionReplyResult MotionReplyResult;
00073 
00074 /*
00075  * \brief Enumeration of Motion reply subcodes
00076  */
00077 namespace MotionReplySubcodes
00078 {
00079 namespace Invalid
00080 {
00081 enum InvalidCode
00082 {
00083   UNSPECIFIED = 3000,
00084   MSGSIZE,
00085   MSGHEADER,
00086   MSGTYPE,
00087   GROUPNO,
00088   SEQUENCE,
00089   COMMAND,
00090   DATA = 3010,
00091   DATA_START_POS,
00092   DATA_POSITION,
00093   DATA_SPEED,
00094   DATA_ACCEL,
00095   DATA_INSUFFICIENT
00096 };
00097 }
00098 
00099 namespace NotReady
00100 {
00101 enum NotReadyCode
00102 {
00103   UNSPECIFIED = 5000,
00104   ALARM,
00105   ERROR,
00106   ESTOP,
00107   NOT_PLAY,
00108   NOT_REMOTE,
00109   SERVO_OFF,
00110   HOLD,
00111   NOT_STARTED,
00112   WAITING_ROS
00113 };
00114 }
00115 } // MotionReplySubcodes
00116 
00139 class MotionReply : public industrial::simple_serialize::SimpleSerialize
00140 {
00141 public:
00148   MotionReply(void);
00153   ~MotionReply(void);
00154 
00159   void init();
00160 
00165   void init(industrial::shared_types::shared_int robot_id,
00166             industrial::shared_types::shared_int sequence,
00167             industrial::shared_types::shared_int command,
00168             MotionReplyResult result,
00169             industrial::shared_types::shared_int subcode,
00170             industrial::shared_types::shared_real data);
00171 
00177   void setRobotID(industrial::shared_types::shared_int robot_id)
00178   {
00179     this->robot_id_ = robot_id;
00180   }
00181 
00187   industrial::shared_types::shared_int getRobotID() const
00188   {
00189     return this->robot_id_;
00190   }
00191 
00197   void setSequence(industrial::shared_types::shared_int sequence)
00198   {
00199     this->sequence_ = sequence;
00200   }
00201 
00207   industrial::shared_types::shared_int getSequence() const
00208   {
00209     return this->sequence_;
00210   }
00211 
00217   void setCommand(industrial::shared_types::shared_int command)
00218   {
00219     this->command_ = command;
00220   }
00221 
00227   industrial::shared_types::shared_int getCommand() const
00228   {
00229     return this->command_;
00230   }
00231 
00237   void setResult(industrial::shared_types::shared_int result)
00238   {
00239     this->result_ = result;
00240   }
00241 
00247   industrial::shared_types::shared_int getResult() const
00248   {
00249     return this->result_;
00250   }
00251 
00257   void setSubcode(industrial::shared_types::shared_int subcode)
00258   {
00259     this->subcode_ = subcode;
00260   }
00261 
00267   industrial::shared_types::shared_int getSubcode() const
00268   {
00269     return this->subcode_;
00270   }
00271 
00275   void clearData()
00276   {
00277     for (size_t i=0; i<MAX_DATA_CNT; ++i)
00278       this->data_[i] = 0.0;
00279   }
00280 
00287   void setData(size_t idx, industrial::shared_types::shared_real val)
00288   {
00289     if (idx<MAX_DATA_CNT)
00290       this->data_[idx] = val;
00291     else
00292       LOG_ERROR("MotionReply data index out-of-range (%d >= %d)",
00293                 (int)idx, (int)MAX_DATA_CNT);
00294   }
00295 
00302   industrial::shared_types::shared_real getData(size_t idx) const
00303   {
00304     if (idx<MAX_DATA_CNT)
00305     {
00306       return this->data_[idx];
00307     }
00308     else
00309     {
00310       LOG_ERROR("MotionReply data index out-of-range (%d >= %d)",
00311                 (int)idx, (int)MAX_DATA_CNT);
00312 
00313       return 0;
00314     }
00315   }
00316 
00317   /*
00318    * \brief Returns a string interpretation of a result code
00319    * \param code result code
00320    * \return string message associated with result code
00321    */
00322   static std::string getResultString(industrial::shared_types::shared_int code);
00323   std::string getResultString() const { return getResultString(this->result_); }
00324 
00325   /*
00326    * \brief Returns a string interpretation of a result subcode
00327    * \param code result subcode
00328    * \return string message associated with result subcode
00329    */
00330   static std::string getSubcodeString(industrial::shared_types::shared_int code);
00331   std::string getSubcodeString() const { return getSubcodeString(this->subcode_); }
00332 
00333 
00339   void copyFrom(MotionReply &src);
00340 
00346   bool operator==(MotionReply &rhs);
00347 
00348   // Overrides - SimpleSerialize
00349   bool load(industrial::byte_array::ByteArray *buffer);
00350   bool unload(industrial::byte_array::ByteArray *buffer);
00351   unsigned int byteLength()
00352   {
00353     return 5*sizeof(industrial::shared_types::shared_int) +
00354            MAX_DATA_CNT*sizeof(industrial::shared_types::shared_real);
00355   }
00356 
00357 private:
00358 
00363   industrial::shared_types::shared_int robot_id_;
00364 
00368   industrial::shared_types::shared_int sequence_;
00369 
00373   industrial::shared_types::shared_int command_;
00374 
00378   industrial::shared_types::shared_int result_;
00379 
00383   industrial::shared_types::shared_int subcode_;
00384 
00388   static const size_t MAX_DATA_CNT = 10;
00389 
00394   industrial::shared_types::shared_real data_[MAX_DATA_CNT];
00395 
00396 };
00397 
00398 }
00399 }
00400 }
00401 
00402 #endif /* MOTOMAN_MOTION_REPLY_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


fs100
Author(s): Jeremy Zoss (Southwest Research Institute)
autogenerated on Mon May 27 2013 19:43:15