fsrobo_r_joint_trajectory_streamer.h
Go to the documentation of this file.
1 /*********************************************************************
2 * FSRobo-R Package BSDL
3 * ---------
4 * Copyright (C) 2019 FUJISOFT. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without modification,
7 * are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation and/or
12 * other materials provided with the distribution.
13 * 3. Neither the name of the copyright holder nor the names of its contributors
14 * may be used to endorse or promote products derived from this software without
15 * specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *********************************************************************/
28 
29 #ifndef FSROBO_R_DRIVER_JOINT_TRAJECTORY_STREAMER_H
30 #define FSROBO_R_DRIVER_JOINT_TRAJECTORY_STREAMER_H
31 
32 #include <map>
33 #include <string>
34 #include <vector>
35 #include <boost/thread/thread.hpp>
43 #include "fsrobo_r_msgs/ExecuteRobotProgram.h"
45 
47 
48 namespace fsrobo_r_driver
49 {
50 namespace joint_trajectory_streamer
51 {
56 
57 namespace TransferStates
58 {
60 {
61  IDLE = 0, STREAMING =1 //,STARTING, //, STOPPING
62 };
63 }
64 
66 
68 {
69 public:
70  // since this class defines a different init(), this helps find the base-class init()
72 
78  FSRoboRJointTrajectoryStreamer(int min_buffer_size = 1) : min_buffer_size_(min_buffer_size) { default_vel_ratio_ = 0.01; };
79 
81 
94  virtual bool init(SmplMsgConnection *connection, const std::vector<std::string> &joint_names,
95  const std::map<std::string, double> &velocity_limits = std::map<std::string, double>());
96 
97  virtual void jointTrajectoryCB(const trajectory_msgs::JointTrajectoryConstPtr &msg);
98 
99  virtual bool trajectory_to_msgs(const trajectory_msgs::JointTrajectoryConstPtr &traj, std::vector<JointTrajPtMessage> *msgs);
100 
101  void streamingThread();
102 
103  bool send_to_robot(const std::vector<JointTrajPtMessage> &messages);
104 
105 protected:
106  void trajectoryStop();
107 
108  boost::thread *streaming_thread_;
109  boost::mutex mutex_;
111  std::vector<JointTrajPtMessage> current_traj_;
112  TransferState state_;
115 
118 
119  bool executeRobotProgramCB(fsrobo_r_msgs::ExecuteRobotProgram::Request &req, fsrobo_r_msgs::ExecuteRobotProgram::Response &res);
120 };
121 
122 } // namespace joint_trajectory_streamer
123 } // namespace fsrobo_r_driver
124 
125 #endif
Wrapper class to exeute program on robot controller.
virtual bool init(std::string default_ip="", int default_port=StandardSocketPorts::MOTION)


fsrobo_r_driver
Author(s): F-ROSROBO
autogenerated on Sun Feb 9 2020 03:58:29