00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2013-2015, TU Delft Robotics 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 00009 * are met: 00010 * 00011 * * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * * Redistributions in binary form must reproduce the above 00014 * copyright notice, this list of conditions and the following 00015 * disclaimer in the documentation and/or other materials provided 00016 * with the distribution. 00017 * * Neither the name of the TU Delft Robotics Institute nor the names 00018 * of its contributors may be used to endorse or promote products 00019 * derived from this software without specific prior written 00020 * permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00023 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00024 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00025 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00026 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00027 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00028 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00029 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00030 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00031 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00032 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00033 * POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 * 00036 * Author: G.A. vd. Hoorn - TU Delft Robotics Institute 00037 */ 00038 00039 #include <fanuc_driver/fanuc_utils.h> 00040 00041 #include <industrial_robot_client/joint_trajectory_streamer.h> 00042 00043 #include <stdexcept> 00044 00045 00046 using industrial_robot_client::joint_trajectory_streamer::JointTrajectoryStreamer; 00047 00048 00049 class Fanuc_JointTrajectoryStreamer : public JointTrajectoryStreamer 00050 { 00051 int J23_factor_; 00052 00053 00054 public: 00055 Fanuc_JointTrajectoryStreamer() : JointTrajectoryStreamer(), J23_factor_(0) 00056 { 00057 if (!ros::param::has("J23_factor")) 00058 { 00059 ROS_FATAL("Joint 2-3 linkage factor parameter not supplied."); 00060 throw std::runtime_error("Cannot find required parameter 'J23_factor' on parameter server."); 00061 } 00062 00063 ros::param::get("J23_factor", this->J23_factor_); 00064 } 00065 00066 00067 virtual ~Fanuc_JointTrajectoryStreamer() {} 00068 00069 00070 bool transform(const trajectory_msgs::JointTrajectoryPoint& pt_in, 00071 trajectory_msgs::JointTrajectoryPoint* pt_out) 00072 { 00073 // sending points back to the Fanuc, so invert factor 00074 fanuc::utils::linkage_transform(pt_in, pt_out, -J23_factor_); 00075 00076 return true; 00077 } 00078 }; 00079 00080 00081 int main(int argc, char** argv) 00082 { 00083 // initialize node 00084 ros::init(argc, argv, "motion_interface"); 00085 00086 // launch the default JointTrajectoryStreamer connection/handlers 00087 Fanuc_JointTrajectoryStreamer motionInterface; 00088 00089 motionInterface.init(); 00090 motionInterface.run(); 00091 00092 return 0; 00093 }