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 #ifndef FLATHEADERS
00036 #include "simple_message/simple_message.h"
00037 #include "simple_message/simple_serialize.h"
00038 #include "simple_message/shared_types.h"
00039 #else
00040 #include "simple_message.h"
00041 #include "simple_serialize.h"
00042 #include "shared_types.h"
00043 #endif
00044 
00045 namespace industrial
00046 {
00047 namespace robot_status
00048 {
00049 
00054 namespace RobotModes
00055 {
00056 enum RobotMode
00057 {
00058   UNKNOWN = -1,
00059 
00060   MANUAL = 1, AUTO = 2,
00061 };
00062 
00063 #ifdef ROS
00064 int toROSMsgEnum(RobotModes::RobotMode mode);
00065 #endif
00066 
00067 }
00068 typedef RobotModes::RobotMode RobotMode;
00069 
00076 namespace TriStates
00077 {
00078 
00079 enum TriState
00080 {
00081   TS_UNKNOWN = -1,
00082   // These values must all be the same
00083   TS_TRUE = 1,   TS_ON = 1,  TS_ENABLED = 1,  TS_HIGH = 1,
00084   // These values must all be the same
00085   TS_FALSE = 0,   TS_OFF = 0,  TS_DISABLED = 0,  TS_LOW = 0
00086 };
00087 
00088 #ifdef ROS
00089 int toROSMsgEnum(TriStates::TriState state);
00090 #endif
00091 
00092 }
00093 typedef TriStates::TriState TriState;
00094 
00116 class RobotStatus : public industrial::simple_serialize::SimpleSerialize
00117 {
00118 public:
00125 RobotStatus(void);
00130 ~RobotStatus(void);
00131 
00136 void init();
00137 
00142 void init(TriState drivesPowered, TriState eStopped, industrial::shared_types::shared_int errorCode, TriState inError,
00143           TriState inMotion, RobotMode mode, TriState motionPossible);
00144 
00145 TriState getDrivesPowered()
00146 {
00147   return TriState(drives_powered_);
00148 }
00149 
00150 TriState getEStopped()
00151 {
00152   return TriState(e_stopped_);
00153 }
00154 
00155 industrial::shared_types::shared_int getErrorCode() const
00156 {
00157   return error_code_;
00158 }
00159 
00160 TriState getInError()
00161 {
00162   return TriState(in_error_);
00163 }
00164 
00165 TriState getInMotion()
00166 {
00167   return TriState(in_motion_);
00168 }
00169 
00170 RobotMode getMode()
00171 {
00172   return RobotMode(mode_);
00173 }
00174 
00175 TriState getMotionPossible()
00176 {
00177   return TriState(motion_possible_);
00178 }
00179 
00180 void setDrivesPowered(TriState drivesPowered)
00181 {
00182   this->drives_powered_ = drivesPowered;
00183 }
00184 
00185 void setEStopped(TriState eStopped)
00186 {
00187   this->e_stopped_ = eStopped;
00188 }
00189 
00190 void setErrorCode(industrial::shared_types::shared_int errorCode)
00191 {
00192   this->error_code_ = errorCode;
00193 }
00194 
00195 void setInError(TriState inError)
00196 {
00197   this->in_error_ = inError;
00198 }
00199 
00200 void setInMotion(TriState inMotion)
00201 {
00202   this->in_motion_ = inMotion;
00203 }
00204 
00205 void setMode(RobotMode mode)
00206 {
00207   this->mode_ = mode;
00208 }
00209 
00210 void setMotionPossible(TriState motionPossible)
00211 {
00212   this->motion_possible_ = motionPossible;
00213 }
00214 
00220 void copyFrom(RobotStatus &src);
00221 
00227 bool operator==(RobotStatus &rhs);
00228 
00229 // Overrides - SimpleSerialize
00230 bool load(industrial::byte_array::ByteArray *buffer);
00231 bool unload(industrial::byte_array::ByteArray *buffer);
00232 unsigned int byteLength()
00233 {
00234   return 7 * sizeof(industrial::shared_types::shared_int);
00235 }
00236 
00237 private:
00238 
00242 industrial::shared_types::shared_int mode_;
00243 
00247 industrial::shared_types::shared_int e_stopped_;
00248 
00252 industrial::shared_types::shared_int drives_powered_;
00253 
00257 industrial::shared_types::shared_int motion_possible_;
00258 
00262 industrial::shared_types::shared_int in_motion_;
00263 
00267 industrial::shared_types::shared_int in_error_;
00268 
00272 industrial::shared_types::shared_int error_code_;
00273 
00274 };
00275 
00276 }
00277 }
00278 
00279 #endif /* JOINT_TRAJ_PT_H */


simple_message
Author(s): Shaun Edwards
autogenerated on Fri Aug 28 2015 11:11:56