Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef MOTOMAN_DRIVER_INDUSTRIAL_ROBOT_CLIENT_JOINT_TRAJECTORY_STREAMER_H
00033 #define MOTOMAN_DRIVER_INDUSTRIAL_ROBOT_CLIENT_JOINT_TRAJECTORY_STREAMER_H
00034
00035 #include <boost/thread/thread.hpp>
00036 #include "motoman_driver/industrial_robot_client/joint_trajectory_interface.h"
00037 #include <map>
00038 #include <vector>
00039 #include <string>
00040
00041 namespace industrial_robot_client
00042 {
00043 namespace joint_trajectory_streamer
00044 {
00045
00046 using industrial_robot_client::joint_trajectory_interface::JointTrajectoryInterface;
00047 using industrial::simple_message::SimpleMessage;
00048 using industrial::smpl_msg_connection::SmplMsgConnection;
00049
00050 namespace TransferStates
00051 {
00052 enum TransferState
00053 {
00054 IDLE = 0, STREAMING = 1
00055 };
00056 }
00057 typedef TransferStates::TransferState TransferState;
00058
00063
00069 class JointTrajectoryStreamer : public JointTrajectoryInterface
00070 {
00071 public:
00072
00073 using JointTrajectoryInterface::init;
00074
00080 JointTrajectoryStreamer(int min_buffer_size = 1) : min_buffer_size_(min_buffer_size) {};
00081
00094 virtual bool init(SmplMsgConnection* connection, const std::map<int, RobotGroup> &robot_groups,
00095 const std::map<std::string, double> &velocity_limits = std::map<std::string, double>());
00096
00097
00110 virtual bool init(SmplMsgConnection* connection, const std::vector<std::string> &joint_names,
00111 const std::map<std::string, double> &velocity_limits = std::map<std::string, double>());
00112
00113 ~JointTrajectoryStreamer();
00114
00115 virtual void jointTrajectoryCB(const trajectory_msgs::JointTrajectoryConstPtr &msg);
00116
00117 virtual void jointTrajectoryCB(const motoman_msgs::DynamicJointTrajectoryConstPtr &msg);
00118
00119 virtual bool trajectory_to_msgs(const trajectory_msgs::JointTrajectoryConstPtr &traj, std::vector<SimpleMessage>* msgs);
00120
00121 virtual bool trajectory_to_msgs(const motoman_msgs::DynamicJointTrajectoryConstPtr &traj, std::vector<SimpleMessage>* msgs);
00122
00123 virtual void streamingThread();
00124
00125 bool send_to_robot(const std::vector<SimpleMessage>& messages);
00126
00127 protected:
00128 void trajectoryStop();
00129
00130 boost::thread* streaming_thread_;
00131 boost::mutex mutex_;
00132 int current_point_;
00133 std::vector<SimpleMessage> current_traj_;
00134 TransferState state_;
00135 ros::Time streaming_start_;
00136 int min_buffer_size_;
00137 };
00138
00139 }
00140 }
00141
00142 #endif