fanuc_robot_state_node.cpp
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2013-2015, TU Delft Robotics Institute
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of the TU Delft Robotics Institute nor the names
18  * of its contributors may be used to endorse or promote products
19  * derived from this software without specific prior written
20  * permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *
35  *
36  * Author: G.A. vd. Hoorn - TU Delft Robotics Institute
37  */
38 
40 
43 
44 #include <stdexcept>
45 
46 
50 
51 
53 {
55 
56 
57 public:
59  {
60  if (!ros::param::has("J23_factor"))
61  {
62  ROS_FATAL("Joint 2-3 linkage factor parameter not supplied.");
63  throw std::runtime_error("Cannot find required parameter 'J23_factor' on parameter server.");
64  }
65 
66  ros::param::get("J23_factor", this->J23_factor_);
67  }
68 
69 
71 
72 
73  bool transform(const std::vector<double>& pos_in, std::vector<double>* pos_out)
74  {
75  // compensate for J2-J3 coupling in Fanuc manipulator, if required
76  fanuc::utils::linkage_transform(pos_in, pos_out, J23_factor_);
77  return true;
78  }
79 };
80 
81 
82 int main(int argc, char** argv)
83 {
84  // initialize node
85  ros::init(argc, argv, "state_interface");
86 
87  // launch the default Robot State Interface connection/handlers
89  rsi.init();
90 
91  // replace the generic JointRelayHandler with our Fanuc specific one as
92  // we need to correct the reported joint angles
93  Fanuc_JointRelayHandler jointHandler;
94  std::vector<std::string> joint_names = rsi.get_joint_names();
95  jointHandler.init(rsi.get_connection(), joint_names);
96  rsi.add_handler(&jointHandler);
97 
98  // run the node
99  rsi.run();
100 
101  return 0;
102 }
#define ROS_FATAL(...)
bool init(std::string default_ip="", int default_port=StandardSocketPorts::STATE)
bool init(industrial::smpl_msg_connection::SmplMsgConnection *connection, std::vector< std::string > &joint_names)
bool getJointNames(const std::string joint_list_param, const std::string urdf_param, std::vector< std::string > &joint_names)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void linkage_transform(const std::vector< double > &joints_in, std::vector< double > *joints_out, double J23_factor=0)
Corrects for parallel linkage coupling between joints.
Definition: fanuc_utils.cpp:60
bool transform(const std::vector< double > &pos_in, std::vector< double > *pos_out)
ROSCPP_DECL bool get(const std::string &key, std::string &s)
void add_handler(MessageHandler *handler, bool allow_replace=true)
ROSCPP_DECL bool has(const std::string &key)
int main(int argc, char **argv)


fanuc_driver
Author(s): G.A. vd. Hoorn (TU Delft Robotics Institute)
autogenerated on Sun Apr 4 2021 02:20:24