joint_trajectory_streamer.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  * Copyright (c) 2013, Southwest Research Institute
00005  * All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions are met:
00009  *
00010  *       * Redistributions of source code must retain the above copyright
00011  *       notice, this list of conditions and the following disclaimer.
00012  *       * Redistributions in binary form must reproduce the above copyright
00013  *       notice, this list of conditions and the following disclaimer in the
00014  *       documentation and/or other materials provided with the distribution.
00015  *       * Neither the name of the Southwest Research Institute, nor the names
00016  *       of its contributors may be used to endorse or promote products derived
00017  *       from this software without specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00020  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00021  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00022  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00023  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00024  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00025  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00026  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00027  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00028  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00029  * POSSIBILITY OF SUCH DAMAGE.
00030  */
00031 
00032 #ifndef MOTOMAN_DRIVER_JOINT_TRAJECTORY_STREAMER_H
00033 #define MOTOMAN_DRIVER_JOINT_TRAJECTORY_STREAMER_H
00034 
00035 #include <map>
00036 #include <string>
00037 #include <vector>
00038 #include "motoman_driver/motion_ctrl.h"
00039 #include "motoman_driver/industrial_robot_client/joint_trajectory_streamer.h"
00040 #include "simple_message/joint_data.h"
00041 #include "simple_message/simple_message.h"
00042 #include "std_srvs/Trigger.h"
00043 
00044 namespace motoman
00045 {
00046 namespace joint_trajectory_streamer
00047 {
00048 
00049 using motoman::motion_ctrl::MotomanMotionCtrl;
00050 using industrial_robot_client::joint_trajectory_streamer::JointTrajectoryStreamer;
00051 using industrial::simple_message::SimpleMessage;
00052 using industrial::smpl_msg_connection::SmplMsgConnection;
00053 
00059 //* JointTrajectoryStreamer
00065 class MotomanJointTrajectoryStreamer : public JointTrajectoryStreamer
00066 {
00067 public:
00068   // since this class overrides some base-class methods,
00069   // these statements help find the base-class versions
00070   using JointTrajectoryStreamer::init;
00071   using JointTrajectoryInterface::is_valid;
00072 
00078   MotomanJointTrajectoryStreamer(int robot_id = -1) : JointTrajectoryStreamer(1),
00079     robot_id_(robot_id) {}
00080 
00081   ~MotomanJointTrajectoryStreamer();
00082 
00095   virtual bool init(SmplMsgConnection* connection, const std::vector<std::string> &joint_names,
00096                     const std::map<std::string, double> &velocity_limits = std::map<std::string, double>());
00097 
00110   virtual bool init(SmplMsgConnection* connection, const std::map<int, RobotGroup> &robot_groups,
00111                     const std::map<std::string, double> &velocity_limits = std::map<std::string, double>());
00112 
00122   virtual bool create_message(int seq, const trajectory_msgs::JointTrajectoryPoint &pt, SimpleMessage* msg);
00123 
00124   virtual bool create_message(int seq, const motoman_msgs::DynamicJointsGroup &pt, SimpleMessage* msg);
00125 
00126   virtual bool create_message_ex(int seq, const motoman_msgs::DynamicJointPoint &point, SimpleMessage* msg);
00127 
00128   virtual bool send_to_robot(const std::vector<SimpleMessage>& messages);
00129 
00130   virtual void streamingThread();
00131 
00132 protected:
00133 
00134   int robot_id_;
00135   MotomanMotionCtrl motion_ctrl_;
00136 
00137   std::map<int, MotomanMotionCtrl> motion_ctrl_map_;
00138 
00139   void trajectoryStop();
00140   bool is_valid(const trajectory_msgs::JointTrajectory &traj);
00141   bool is_valid(const motoman_msgs::DynamicJointTrajectory &traj);
00142 
00143   static bool VectorToJointData(const std::vector<double> &vec,
00144                                 industrial::joint_data::JointData &joints);
00145 
00150   ros::ServiceServer disabler_;
00151 
00156   ros::ServiceServer enabler_;
00157 
00163   bool disableRobotCB(std_srvs::Trigger::Request &req,
00164                       std_srvs::Trigger::Response &res);
00165 
00171   bool enableRobotCB(std_srvs::Trigger::Request &req,
00172                      std_srvs::Trigger::Response &res);
00173 
00174 
00175 };
00176 
00177 }  // namespace joint_trajectory_streamer
00178 }  // namespace motoman
00179 
00180 #endif  // MOTOMAN_DRIVER_JOINT_TRAJECTORY_STREAMER_H


motoman_driver
Author(s): Jeremy Zoss (Southwest Research Institute)
autogenerated on Sat Jun 8 2019 19:06:57