robot_status.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  * Copyright (c) 2011, 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 ROBOT_STATUS_H
00033 #define ROBOT_STATUS_H
00034 
00035 #ifdef ROS
00036 #include "simple_message/simple_message.h"
00037 #include "simple_message/simple_serialize.h"
00038 #include "simple_message/shared_types.h"
00039 
00040 #endif
00041 
00042 #ifdef MOTOPLUS
00043 #include "simple_message.h"
00044 #include "simple_serialize.h"
00045 #include "shared_types.h"
00046 
00047 #endif
00048 
00049 namespace industrial
00050 {
00051 namespace robot_status
00052 {
00053 
00058 namespace RobotModes
00059 {
00060 enum RobotMode
00061 {
00062   UNKNOWN = -1,
00063 
00064   MANUAL = 1, AUTO = 2,
00065 };
00066 
00067 #ifdef ROS
00068 int toROSMsgEnum(RobotModes::RobotMode mode);
00069 #endif
00070 
00071 }
00072 typedef RobotModes::RobotMode RobotMode;
00073 
00080 namespace TriStates
00081 {
00082 
00083 enum TriState
00084 {
00085   TS_UNKNOWN = -1,
00086   // These values must all be the same
00087   TS_TRUE = 1,   TS_ON = 1,  TS_ENABLED = 1,  TS_HIGH = 1,
00088   // These values must all be the same
00089   TS_FALSE = 0,   TS_OFF = 0,  TS_DISABLED = 0,  TS_LOW = 0
00090 };
00091 
00092 #ifdef ROS
00093 int toROSMsgEnum(TriStates::TriState state);
00094 #endif
00095 
00096 }
00097 typedef TriStates::TriState TriState;
00098 
00120 class RobotStatus : public industrial::simple_serialize::SimpleSerialize
00121 {
00122 public:
00129 RobotStatus(void);
00134 ~RobotStatus(void);
00135 
00140 void init();
00141 
00146 void init(TriState drivesPowered, TriState eStopped, industrial::shared_types::shared_int errorCode, TriState inError,
00147           TriState inMotion, RobotMode mode, TriState motionPossible);
00148 
00149 TriState getDrivesPowered()
00150 {
00151   return TriState(drives_powered_);
00152 }
00153 
00154 TriState getEStopped()
00155 {
00156   return TriState(e_stopped_);
00157 }
00158 
00159 industrial::shared_types::shared_int getErrorCode() const
00160 {
00161   return error_code_;
00162 }
00163 
00164 TriState getInError()
00165 {
00166   return TriState(in_error_);
00167 }
00168 
00169 TriState getInMotion()
00170 {
00171   return TriState(in_motion_);
00172 }
00173 
00174 RobotMode getMode()
00175 {
00176   return RobotMode(mode_);
00177 }
00178 
00179 TriState getMotionPossible()
00180 {
00181   return TriState(motion_possible_);
00182 }
00183 
00184 void setDrivesPowered(TriState drivesPowered)
00185 {
00186   this->drives_powered_ = drivesPowered;
00187 }
00188 
00189 void setEStopped(TriState eStopped)
00190 {
00191   this->e_stopped_ = eStopped;
00192 }
00193 
00194 void setErrorCode(industrial::shared_types::shared_int errorCode)
00195 {
00196   this->error_code_ = errorCode;
00197 }
00198 
00199 void setInError(TriState inError)
00200 {
00201   this->in_error_ = inError;
00202 }
00203 
00204 void setInMotion(TriState inMotion)
00205 {
00206   this->in_motion_ = inMotion;
00207 }
00208 
00209 void setMode(RobotMode mode)
00210 {
00211   this->mode_ = mode;
00212 }
00213 
00214 void setMotionPossible(TriState motionPossible)
00215 {
00216   this->motion_possible_ = motionPossible;
00217 }
00218 
00224 void copyFrom(RobotStatus &src);
00225 
00231 bool operator==(RobotStatus &rhs);
00232 
00233 // Overrides - SimpleSerialize
00234 bool load(industrial::byte_array::ByteArray *buffer);
00235 bool unload(industrial::byte_array::ByteArray *buffer);
00236 unsigned int byteLength()
00237 {
00238   return 7 * sizeof(industrial::shared_types::shared_int);
00239 }
00240 
00241 private:
00242 
00246 industrial::shared_types::shared_int mode_;
00247 
00251 industrial::shared_types::shared_int e_stopped_;
00252 
00256 industrial::shared_types::shared_int drives_powered_;
00257 
00261 industrial::shared_types::shared_int motion_possible_;
00262 
00266 industrial::shared_types::shared_int in_motion_;
00267 
00271 industrial::shared_types::shared_int in_error_;
00272 
00276 industrial::shared_types::shared_int error_code_;
00277 
00278 };
00279 
00280 }
00281 }
00282 
00283 #endif /* JOINT_TRAJ_PT_H */


simple_message
Author(s): Shaun Edwards
autogenerated on Mon Oct 6 2014 00:54:18