motoman_motion_reply.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2013, 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 MOTOMAN_DRIVER_SIMPLE_MESSAGE_MOTOMAN_MOTION_REPLY_H
33 #define MOTOMAN_DRIVER_SIMPLE_MESSAGE_MOTOMAN_MOTION_REPLY_H
34 
35 #include <string>
36 #ifdef ROS
40 #endif
41 
42 #ifdef MOTOPLUS
43 #include "simple_serialize.h" // NOLINT(build/include)
44 #include "shared_types.h" // NOLINT(build/include)
45 #include "log_wrapper.h" // NOLINT(build/include)
46 #endif
47 
48 namespace motoman
49 {
50 namespace simple_message
51 {
52 namespace motion_reply
53 {
54 
59 {
61 {
62  SUCCESS = 0,
63  TRUE = 0,
64  BUSY = 1,
65  FAILURE = 2,
66  FALSE = 2,
67  INVALID = 3,
68  ALARM = 4,
69  NOT_READY = 5,
71 };
72 } // namespace MotionReplyResults
74 
75 /*
76  * \brief Enumeration of Motion reply subcodes
77  */
78 namespace MotionReplySubcodes
79 {
80 namespace Invalid
81 {
83 {
84  UNSPECIFIED = 3000,
91  DATA = 3010,
97 };
98 } // namespace Invalid
99 
100 namespace NotReady
101 {
103 {
104  UNSPECIFIED = 5000,
115 };
116 } // namespace NotReady
117 } // namespace MotionReplySubcodes
118 
142 {
143 public:
150  MotionReply(void);
155  ~MotionReply(void);
156 
161  void init();
162 
167  void init(industrial::shared_types::shared_int robot_id,
170  MotionReplyResult result,
173 
180  {
181  this->robot_id_ = robot_id;
182  }
183 
190  {
191  return this->robot_id_;
192  }
193 
200  {
201  this->sequence_ = sequence;
202  }
203 
210  {
211  return this->sequence_;
212  }
213 
220  {
221  this->command_ = command;
222  }
223 
230  {
231  return this->command_;
232  }
233 
240  {
241  this->result_ = result;
242  }
243 
250  {
251  return this->result_;
252  }
253 
260  {
261  this->subcode_ = subcode;
262  }
263 
270  {
271  return this->subcode_;
272  }
273 
277  void clearData()
278  {
279  for (size_t i = 0; i < MAX_DATA_CNT; ++i)
280  this->data_[i] = 0.0;
281  }
282 
290  {
291  if (idx < MAX_DATA_CNT)
292  this->data_[idx] = val;
293  else
294  LOG_ERROR("MotionReply data index out-of-range (%d >= %d)",
295  static_cast<int>(idx), static_cast<int>(MAX_DATA_CNT));
296  }
297 
305  {
306  if (idx < MAX_DATA_CNT)
307  {
308  return this->data_[idx];
309  }
310  else
311  {
312  LOG_ERROR("MotionReply data index out-of-range (%d >= %d)",
313  static_cast<int>(idx), static_cast<int>(MAX_DATA_CNT));
314 
315  return 0;
316  }
317  }
318 
319  /*
320  * \brief Returns a string interpretation of a result code
321  * \param code result code
322  * \return string message associated with result code
323  */
324  static std::string getResultString(industrial::shared_types::shared_int code);
325  std::string getResultString() const
326  {
327  return getResultString(this->result_);
328  }
329 
330  /*
331  * \brief Returns a string interpretation of a result subcode
332  * \param code result subcode
333  * \return string message associated with result subcode
334  */
335  static std::string getSubcodeString(industrial::shared_types::shared_int code);
336  std::string getSubcodeString() const
337  {
338  return getSubcodeString(this->subcode_);
339  }
340 
341 
347  void copyFrom(MotionReply &src);
348 
354  bool operator==(MotionReply &rhs);
355 
356  // Overrides - SimpleSerialize
357  bool load(industrial::byte_array::ByteArray *buffer);
358  bool unload(industrial::byte_array::ByteArray *buffer);
359  unsigned int byteLength()
360  {
361  return 5 * sizeof(industrial::shared_types::shared_int) +
362  MAX_DATA_CNT * sizeof(industrial::shared_types::shared_real);
363  }
364 
365 private:
371 
376 
381 
386 
391 
395  static const size_t MAX_DATA_CNT = 10;
396 
402 };
403 } // namespace motion_reply
404 } // namespace simple_message
405 } // namespace motoman
406 
407 #endif // MOTOMAN_DRIVER_SIMPLE_MESSAGE_MOTOMAN_MOTION_REPLY_H
industrial::shared_types::shared_int command_
Motion-control command (from corresponding MotionCtrl command)
industrial::shared_types::shared_int robot_id_
Robot/group ID. 0 = 1st robot.
industrial::shared_types::shared_real getData(size_t idx) const
Returns reply data.
industrial::shared_types::shared_int getSubcode() const
Returns motion-control result sub-code.
SmCommandType command
int sequence
void setResult(industrial::shared_types::shared_int result)
Sets motion-control result code.
void setRobotID(industrial::shared_types::shared_int robot_id)
Sets robot_id.
int subcode
#define LOG_ERROR(format,...)
float data[ROS_MAX_JOINT]
void setSequence(industrial::shared_types::shared_int sequence)
Sets motion-control reply&#39;s sequence number.
industrial::shared_types::shared_int getResult() const
Returns motion-control result code.
industrial::shared_types::shared_int sequence_
Message-tracking number (from corresponding MotionCtrl command)
void setData(size_t idx, industrial::shared_types::shared_real val)
Sets reply data.
industrial::shared_types::shared_int getSequence() const
Returns motion-control reply&#39;s sequence number.
void setCommand(industrial::shared_types::shared_int command)
Sets motion-control command (for reference)
SmResultType result
Class encapsulated motion control reply data. These messages are sent by the FS100 controller in resp...
industrial::shared_types::shared_int result_
Command result.
void setSubcode(industrial::shared_types::shared_int subcode)
Sets motion-control result sub-code.
industrial::shared_types::shared_int subcode_
Command result sub-code (more detailed status)
industrial::shared_types::shared_int getRobotID() const
Returns target robot/group # for this reply.
bool operator==(const Rotation &a, const Rotation &b)
industrial::shared_types::shared_int getCommand() const
Returns motion-control command.


motoman_driver
Author(s): Jeremy Zoss (Southwest Research Institute), Ted Miller (MotoROS) (Yaskawa Motoman), Eric Marcil (MotoROS) (Yaskawa Motoman)
autogenerated on Sat May 8 2021 02:27:43