robot_status.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2011, Southwest Research Institute
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  * * Neither the name of the Southwest Research Institute, nor the names
16  * of its contributors may be used to endorse or promote products derived
17  * from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef ROBOT_STATUS_H
33 #define ROBOT_STATUS_H
34 
35 #ifndef FLATHEADERS
39 #else
40 #include "simple_message.h"
41 #include "simple_serialize.h"
42 #include "shared_types.h"
43 #endif
44 
45 namespace industrial
46 {
47 namespace robot_status
48 {
49 
54 namespace RobotModes
55 {
57 {
58  UNKNOWN = -1,
59 
60  MANUAL = 1, AUTO = 2,
61 };
62 
63 // remove ROS after Melodic (bw compat for #262)
64 #if defined(SIMPLE_MESSAGE_USE_ROS) || defined(ROS)
65 int toROSMsgEnum(RobotModes::RobotMode mode);
66 #endif
67 
68 }
70 
77 namespace TriStates
78 {
79 
81 {
82  TS_UNKNOWN = -1,
83  // These values must all be the same
84  TS_TRUE = 1, TS_ON = 1, TS_ENABLED = 1, TS_HIGH = 1,
85  // These values must all be the same
86  TS_FALSE = 0, TS_OFF = 0, TS_DISABLED = 0, TS_LOW = 0
87 };
88 
89 // remove ROS after Melodic (bw compat for #262)
90 #if defined(SIMPLE_MESSAGE_USE_ROS) || defined(ROS)
91 int toROSMsgEnum(TriStates::TriState state);
92 #endif
93 
94 }
96 
119 {
120 public:
127 RobotStatus(void);
132 ~RobotStatus(void);
133 
138 void init();
139 
144 void init(TriState drivesPowered, TriState eStopped, industrial::shared_types::shared_int errorCode, TriState inError,
145  TriState inMotion, RobotMode mode, TriState motionPossible);
146 
148 {
149  return TriState(drives_powered_);
150 }
151 
153 {
154  return TriState(e_stopped_);
155 }
156 
158 {
159  return error_code_;
160 }
161 
163 {
164  return TriState(in_error_);
165 }
166 
168 {
169  return TriState(in_motion_);
170 }
171 
173 {
174  return RobotMode(mode_);
175 }
176 
178 {
179  return TriState(motion_possible_);
180 }
181 
182 void setDrivesPowered(TriState drivesPowered)
183 {
184  this->drives_powered_ = drivesPowered;
185 }
186 
187 void setEStopped(TriState eStopped)
188 {
189  this->e_stopped_ = eStopped;
190 }
191 
193 {
194  this->error_code_ = errorCode;
195 }
196 
197 void setInError(TriState inError)
198 {
199  this->in_error_ = inError;
200 }
201 
202 void setInMotion(TriState inMotion)
203 {
204  this->in_motion_ = inMotion;
205 }
206 
207 void setMode(RobotMode mode)
208 {
209  this->mode_ = mode;
210 }
211 
212 void setMotionPossible(TriState motionPossible)
213 {
214  this->motion_possible_ = motionPossible;
215 }
216 
222 void copyFrom(RobotStatus &src);
223 
229 bool operator==(RobotStatus &rhs);
230 
231 // Overrides - SimpleSerialize
234 unsigned int byteLength()
235 {
236  return 7 * sizeof(industrial::shared_types::shared_int);
237 }
238 
239 private:
240 
245 
250 
255 
260 
265 
270 
275 
276 };
277 
278 }
279 }
280 
281 #endif /* JOINT_TRAJ_PT_H */
industrial::robot_status::TriStates::TS_FALSE
@ TS_FALSE
Definition: robot_status.h:86
industrial::robot_status::RobotStatus::e_stopped_
industrial::shared_types::shared_int e_stopped_
E-stop state (see TriStates::TriState)
Definition: robot_status.h:249
industrial::robot_status::TriStates::TriState
TriState
Definition: robot_status.h:80
industrial::robot_status::RobotStatus::mode_
industrial::shared_types::shared_int mode_
Operating mode (see RobotModes::RobotMode)
Definition: robot_status.h:244
industrial::robot_status::RobotStatus::getEStopped
TriState getEStopped()
Definition: robot_status.h:152
industrial::robot_status::RobotStatus::error_code_
industrial::shared_types::shared_int error_code_
error code (non-zero is error)
Definition: robot_status.h:274
industrial::robot_status::TriStates::TS_TRUE
@ TS_TRUE
Definition: robot_status.h:84
industrial::robot_status::RobotModes::UNKNOWN
@ UNKNOWN
Definition: robot_status.h:58
industrial::robot_status::RobotStatus::copyFrom
void copyFrom(RobotStatus &src)
Copies the passed in value.
Definition: robot_status.cpp:142
industrial::robot_status::RobotStatus::byteLength
unsigned int byteLength()
Virtual method returns the object size when packed into a ByteArray.
Definition: robot_status.h:234
industrial::robot_status::RobotStatus::getMode
RobotMode getMode()
Definition: robot_status.h:172
industrial::robot_status::RobotStatus::unload
bool unload(industrial::byte_array::ByteArray *buffer)
Virtual method for unloading an object from a ByteArray.
Definition: robot_status.cpp:183
industrial::robot_status::TriStates::TS_LOW
@ TS_LOW
Definition: robot_status.h:86
industrial::robot_status::RobotStatus::load
bool load(industrial::byte_array::ByteArray *buffer)
Virtual method for loading an object into a ByteArray.
Definition: robot_status.cpp:160
industrial::robot_status::RobotStatus::getInError
TriState getInError()
Definition: robot_status.h:162
industrial::robot_status::RobotStatus::getErrorCode
industrial::shared_types::shared_int getErrorCode() const
Definition: robot_status.h:157
industrial
Definition: byte_array.h:45
simple_message.h
industrial::robot_status::RobotStatus::~RobotStatus
~RobotStatus(void)
Destructor.
Definition: robot_status.cpp:119
industrial::robot_status::RobotMode
RobotModes::RobotMode RobotMode
Definition: robot_status.h:69
industrial::robot_status::RobotStatus::in_motion_
industrial::shared_types::shared_int in_motion_
in motion state (see TriStates::TriState)
Definition: robot_status.h:264
industrial::robot_status::RobotStatus::setDrivesPowered
void setDrivesPowered(TriState drivesPowered)
Definition: robot_status.h:182
industrial::robot_status::RobotStatus::setEStopped
void setEStopped(TriState eStopped)
Definition: robot_status.h:187
industrial::robot_status::RobotStatus::setMotionPossible
void setMotionPossible(TriState motionPossible)
Definition: robot_status.h:212
industrial::robot_status::RobotStatus::motion_possible_
industrial::shared_types::shared_int motion_possible_
motion possible state (see TriStates::TriState)
Definition: robot_status.h:259
industrial::robot_status::TriStates::TS_UNKNOWN
@ TS_UNKNOWN
Definition: robot_status.h:82
industrial::robot_status::TriStates::TS_HIGH
@ TS_HIGH
Definition: robot_status.h:84
industrial::robot_status::RobotStatus::setMode
void setMode(RobotMode mode)
Definition: robot_status.h:207
industrial::robot_status::RobotModes::MANUAL
@ MANUAL
Definition: robot_status.h:60
industrial::byte_array::ByteArray
The byte array wraps a dynamic array of bytes (i.e. char).
Definition: byte_array.h:80
industrial::robot_status::RobotStatus::drives_powered_
industrial::shared_types::shared_int drives_powered_
Drive power state (see TriStates::TriState)
Definition: robot_status.h:254
industrial::robot_status::RobotStatus::setInError
void setInError(TriState inError)
Definition: robot_status.h:197
industrial::robot_status::RobotModes::AUTO
@ AUTO
Definition: robot_status.h:60
industrial::robot_status::RobotStatus
Class encapsulated robot status data. The robot status data is meant to mirror the industrial_msgs/Ro...
Definition: robot_status.h:118
industrial::robot_status::RobotStatus::operator==
bool operator==(RobotStatus &rhs)
== operator implementation
Definition: robot_status.cpp:153
shared_types.h
industrial::robot_status::RobotStatus::getMotionPossible
TriState getMotionPossible()
Definition: robot_status.h:177
industrial::robot_status::TriStates::TS_ENABLED
@ TS_ENABLED
Definition: robot_status.h:84
industrial::simple_serialize::SimpleSerialize
Interface for loading and unloading a class to/from a ByteArray.
Definition: simple_serialize.h:52
industrial::shared_types::shared_int
int shared_int
Definition: shared_types.h:62
industrial::robot_status::RobotStatus::setErrorCode
void setErrorCode(industrial::shared_types::shared_int errorCode)
Definition: robot_status.h:192
industrial::robot_status::RobotStatus::setInMotion
void setInMotion(TriState inMotion)
Definition: robot_status.h:202
industrial::robot_status::TriStates::TS_DISABLED
@ TS_DISABLED
Definition: robot_status.h:86
industrial::robot_status::TriStates::TS_OFF
@ TS_OFF
Definition: robot_status.h:86
industrial::robot_status::RobotStatus::getDrivesPowered
TriState getDrivesPowered()
Definition: robot_status.h:147
industrial::robot_status::RobotStatus::getInMotion
TriState getInMotion()
Definition: robot_status.h:167
industrial::robot_status::TriState
TriStates::TriState TriState
Definition: robot_status.h:95
industrial::robot_status::RobotStatus::init
void init()
Initializes an empty robot status.
Definition: robot_status.cpp:124
industrial::robot_status::RobotModes::RobotMode
RobotMode
Definition: robot_status.h:56
industrial::robot_status::RobotStatus::RobotStatus
RobotStatus(void)
Default constructor.
Definition: robot_status.cpp:115
simple_serialize.h
industrial::robot_status::RobotStatus::in_error_
industrial::shared_types::shared_int in_error_
in error state (see TriStates::TriState)
Definition: robot_status.h:269
industrial::robot_status::TriStates::TS_ON
@ TS_ON
Definition: robot_status.h:84


simple_message
Author(s): Shaun Edwards
autogenerated on Wed Mar 2 2022 00:24:53