robot_state_interface.cpp
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2011, Southwest Research 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 are met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  * * Neither the name of the Southwest Research Institute, nor the names
16  * of its contributors may be used to endorse or promote products derived
17  * from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
34 
38 
40 {
41 namespace robot_state_interface
42 {
43 
45 {
46  this->connection_ = NULL;
49 }
50 
51 bool RobotStateInterface::init(std::string default_ip, int default_port)
52 {
53  std::string ip;
54  int port;
55 
56  // override IP/port with ROS params, if available
57  ros::param::param<std::string>("robot_ip_address", ip, default_ip);
58  ros::param::param<int>("~port", port, default_port);
59 
60  // check for valid parameter values
61  if (ip.empty())
62  {
63  ROS_ERROR("No valid robot IP address found. Please set ROS 'robot_ip_address' param");
64  return false;
65  }
66  if (port <= 0)
67  {
68  ROS_ERROR("No valid robot IP port found. Please set ROS '~port' param");
69  return false;
70  }
71 
72  char* ip_addr = strdup(ip.c_str()); // connection.init() requires "char*", not "const char*"
73  ROS_INFO("Robot state connecting to IP address: '%s:%d'", ip_addr, port);
74  default_tcp_connection_.init(ip_addr, port);
75  free(ip_addr);
76 
78 }
79 
81 {
82  std::vector<std::string> joint_names;
83  if (!getJointNames("controller_joint_names", "robot_description", joint_names))
84  {
85  ROS_ERROR("Failed to initialize joint_names. Aborting");
86  return false;
87  }
88 
89  return init(connection, joint_names);
90 }
91 
92 bool RobotStateInterface::init(SmplMsgConnection* connection, std::vector<std::string>& joint_names)
93 {
94  this->joint_names_ = joint_names;
95  this->connection_ = connection;
97 
98  // initialize message-manager
100  return false;
101 
102  // initialize default handlers
104  return false;
106 
108  return false;
110 
111  return true;
112 }
113 
115 {
116  manager_.spin();
117 }
118 
119 } // robot_state_interface
120 } // industrial_robot_client
bool init(std::string default_ip="", int default_port=StandardSocketPorts::STATE)
Initialize robot connection using default method.
bool init(industrial::smpl_msg_connection::SmplMsgConnection *connection, std::vector< std::string > &joint_names)
Class initializer.
bool init(char *buff, int port_num)
bool getJointNames(const std::string joint_list_param, const std::string urdf_param, std::vector< std::string > &joint_names)
bool init(industrial::smpl_msg_connection::SmplMsgConnection *connection)
Class initializer.
#define ROS_INFO(...)
void add_handler(MessageHandler *handler, bool allow_replace=true)
Add a new handler.
bool init(industrial::smpl_msg_connection::SmplMsgConnection *connection)
#define ROS_ERROR(...)
void run()
Begin processing messages and publishing topics.


industrial_robot_client
Author(s): Jeremy Zoss
autogenerated on Sat Sep 21 2019 03:30:13