motoman_motion_ctrl.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_CTRL_H
33 #define MOTOMAN_DRIVER_SIMPLE_MESSAGE_MOTOMAN_MOTION_CTRL_H
34 
35 #ifdef ROS
39 #endif
40 
41 #ifdef MOTOPLUS
42 #include "simple_serialize.h" // NOLINT(build/include)
43 #include "shared_types.h" // NOLINT(build/include)
44 #include "log_wrapper.h" // NOLINT(build/include)
45 #endif
46 
47 namespace motoman
48 {
49 namespace simple_message
50 {
51 namespace motion_ctrl
52 {
57 {
59 {
60  UNDEFINED = 0,
61  CHECK_MOTION_READY = 200101, // check if controller is ready to receive ROS motion cmds
62  CHECK_QUEUE_CNT = 200102, // get number of motion increments in queue
63  STOP_MOTION = 200111, // stop robot motion immediately
64  START_TRAJ_MODE = 200121, // prepare controller to receive ROS motion cmds
65  STOP_TRAJ_MODE = 200122, // return motion control to INFORM
66 };
67 } // namespace MotionControlCmds
69 
92 {
93 public:
100  MotionCtrl(void);
105  ~MotionCtrl(void);
106 
111  void init();
112 
117  void init(industrial::shared_types::shared_int robot_id,
119  MotionControlCmd command,
121 
128  {
129  this->robot_id_ = robot_id;
130  }
131 
138  {
139  return this->robot_id_;
140  }
141 
148  {
149  this->sequence_ = sequence;
150  }
151 
158  {
159  return this->sequence_;
160  }
161 
167  void setCommand(MotionControlCmd command)
168  {
169  this->command_ = command;
170  }
171 
177  MotionControlCmd getCommand()
178  {
179  return (MotionControlCmd)this->command_;
180  }
181 
185  void clearData()
186  {
187  for (size_t i = 0; i < MAX_DATA_CNT; ++i)
188  this->data_[i] = 0.0;
189  }
190 
198  {
199  if (idx < MAX_DATA_CNT)
200  this->data_[idx] = val;
201  else
202  LOG_ERROR("MotionCtrl data index out-of-range (%d >= %d)",
203  static_cast<int>(idx), static_cast<int>(MAX_DATA_CNT));
204  }
205 
213  {
214  if (idx < MAX_DATA_CNT)
215  {
216  return this->data_[idx];
217  }
218  else
219  {
220  LOG_ERROR("MotionCtrl data index out-of-range (%d >= %d)",
221  static_cast<int>(idx), static_cast<int>(MAX_DATA_CNT));
222 
223  return 0;
224  }
225  }
226 
232  void copyFrom(MotionCtrl &src);
233 
239  bool operator==(MotionCtrl &rhs);
240 
241  // Overrides - SimpleSerialize
242  bool load(industrial::byte_array::ByteArray *buffer);
243  bool unload(industrial::byte_array::ByteArray *buffer);
244  unsigned int byteLength()
245  {
246  return 3 * sizeof(industrial::shared_types::shared_int) +
247  MAX_DATA_CNT * sizeof(industrial::shared_types::shared_real);
248  }
249 
250 private:
256 
261 
266 
270  static const size_t MAX_DATA_CNT = 10;
271 
277 };
278 } // namespace motion_ctrl
279 } // namespace simple_message
280 } // namespace motoman
281 
282 #endif // MOTOMAN_DRIVER_SIMPLE_MESSAGE_MOTOMAN_MOTION_CTRL_H
industrial::shared_types::shared_int command_
Motion-control command.
void setCommand(MotionControlCmd command)
Sets motion control command.
void setSequence(industrial::shared_types::shared_int sequence)
Sets control command&#39;s sequence number.
industrial::shared_types::shared_int getRobotID()
Returns target robot/group # for this command.
SmCommandType command
int sequence
#define LOG_ERROR(format,...)
industrial::shared_types::shared_real getData(size_t idx)
Returns command data.
void setData(size_t idx, industrial::shared_types::shared_real val)
Sets command data.
MotionControlCmd getCommand()
Returns motion control command.
float data[ROS_MAX_JOINT]
industrial::shared_types::shared_int sequence_
Message-tracking number that will be echoed back in reply message.
Enumeration of motion control command codes.
void setRobotID(industrial::shared_types::shared_int robot_id)
Sets robot_id.
industrial::shared_types::shared_int robot_id_
Robot/group ID. 0 = 1st robot.
bool operator==(const Rotation &a, const Rotation &b)
industrial::shared_types::shared_int getSequence()
Returns control command&#39;s sequence number.
Class encapsulated motion control data. These control messages are required to download command-traje...


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