industrial_robot_client/joint_trajectory_streamer.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_INDUSTRIAL_ROBOT_CLIENT_JOINT_TRAJECTORY_STREAMER_H
33 #define MOTOMAN_DRIVER_INDUSTRIAL_ROBOT_CLIENT_JOINT_TRAJECTORY_STREAMER_H
34 
35 #include <boost/thread/thread.hpp>
37 #include <map>
38 #include <vector>
39 #include <string>
40 
42 {
43 namespace joint_trajectory_streamer
44 {
45 
49 
50 namespace TransferStates
51 {
53 {
54  IDLE = 0, STREAMING = 1 // ,STARTING, //, STOPPING
55 };
56 }
58 
63 // * JointTrajectoryStreamer
70 {
71 public:
72  // since this class defines a different init(), this helps find the base-class init()
74 
80  explicit JointTrajectoryStreamer(int min_buffer_size = 1) : min_buffer_size_(min_buffer_size) {}
81 
94  virtual bool init(SmplMsgConnection* connection, const std::map<int, RobotGroup> &robot_groups,
95  const std::map<std::string, double> &velocity_limits = std::map<std::string, double>());
96 
97 
110  virtual bool init(SmplMsgConnection* connection, const std::vector<std::string> &joint_names,
111  const std::map<std::string, double> &velocity_limits = std::map<std::string, double>());
112 
114 
115  virtual void jointTrajectoryCB(const trajectory_msgs::JointTrajectoryConstPtr &msg);
116 
117  virtual void jointTrajectoryCB(const motoman_msgs::DynamicJointTrajectoryConstPtr &msg);
118 
119  virtual bool trajectory_to_msgs(const trajectory_msgs::JointTrajectoryConstPtr& traj,
120  std::vector<SimpleMessage>* msgs);
121 
122  virtual bool trajectory_to_msgs(const motoman_msgs::DynamicJointTrajectoryConstPtr& traj,
123  std::vector<SimpleMessage>* msgs);
124 
125  virtual void streamingThread();
126 
127  bool send_to_robot(const std::vector<SimpleMessage>& messages);
128 
129 protected:
130  void trajectoryStop();
131 
132  boost::thread* streaming_thread_;
133  boost::mutex mutex_;
134  int current_point_;
135  std::vector<SimpleMessage> current_traj_;
136  TransferState state_;
137  ros::Time streaming_start_;
138  int min_buffer_size_;
139 };
140 
141 } // namespace joint_trajectory_streamer
142 } // namespace industrial_robot_client
143 
144 #endif // MOTOMAN_DRIVER_INDUSTRIAL_ROBOT_CLIENT_JOINT_TRAJECTORY_STREAMER_H
Message handler that relays joint trajectories to the robot controller.
virtual bool init(std::string default_ip="", int default_port=StandardSocketPorts::MOTION)


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