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_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  * \brief Enumeration of Motion reply subcodes
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 }  // namespace Invalid
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 }  // namespace NotReady
00117 }  // MotionReplySubcodes
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    * \brief Returns a string interpretation of a result code
00321    * \param code result code
00322    * \return string message associated with result code
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    * \brief Returns a string interpretation of a result subcode
00332    * \param code result subcode
00333    * \return string message associated with result subcode
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   // Overrides - SimpleSerialize
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 }  // namespace motion_reply
00404 }  // namespace simple_message
00405 }  // namespace motoman
00406 
00407 #endif  // MOTOMAN_DRIVER_SIMPLE_MESSAGE_MOTOMAN_MOTION_REPLY_H


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