fanuc_robot_state_node.cpp
Go to the documentation of this file.
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/robot_state_interface.h>
00042 #include <industrial_utils/param_utils.h>
00043 
00044 #include <stdexcept>
00045 
00046 
00047 using industrial_robot_client::robot_state_interface::RobotStateInterface;
00048 using industrial_robot_client::joint_relay_handler::JointRelayHandler;
00049 using industrial_utils::param::getJointNames;
00050 
00051 
00052 class Fanuc_JointRelayHandler : public JointRelayHandler
00053 {
00054   int J23_factor_;
00055 
00056 
00057 public:
00058   Fanuc_JointRelayHandler() : JointRelayHandler(), J23_factor_(0)
00059   {
00060     if (!ros::param::has("J23_factor"))
00061     {
00062       ROS_FATAL("Joint 2-3 linkage factor parameter not supplied.");
00063       throw std::runtime_error("Cannot find required parameter 'J23_factor' on parameter server.");
00064     }
00065 
00066     ros::param::get("J23_factor", this->J23_factor_);
00067   }
00068 
00069 
00070   virtual ~Fanuc_JointRelayHandler() {}
00071 
00072 
00073   bool transform(const std::vector<double>& pos_in, std::vector<double>* pos_out)
00074   {
00075     // compensate for J2-J3 coupling in Fanuc manipulator, if required
00076     fanuc::utils::linkage_transform(pos_in, pos_out, J23_factor_);
00077     return true;
00078   }
00079 };
00080 
00081 
00082 int main(int argc, char** argv)
00083 {
00084   // initialize node
00085   ros::init(argc, argv, "state_interface");
00086 
00087   // launch the default Robot State Interface connection/handlers
00088   RobotStateInterface rsi;
00089   rsi.init();
00090 
00091   // replace the generic JointRelayHandler with our Fanuc specific one as
00092   // we need to correct the reported joint angles
00093   Fanuc_JointRelayHandler jointHandler;
00094   std::vector<std::string> joint_names = rsi.get_joint_names();
00095   jointHandler.init(rsi.get_connection(), joint_names);
00096   rsi.add_handler(&jointHandler);
00097 
00098   // run the node
00099   rsi.run();
00100 
00101   return 0;
00102 }


fanuc_driver
Author(s): G.A. vd. Hoorn (TU Delft Robotics Institute)
autogenerated on Wed Aug 26 2015 11:33:42