fsrobo_r_robot_state_interface.cpp
Go to the documentation of this file.
1 /*********************************************************************
2 * FSRobo-R Package BSDL
3 * ---------
4 * Copyright (C) 2019 FUJISOFT. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without modification,
7 * are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation and/or
12 * other materials provided with the distribution.
13 * 3. Neither the name of the copyright holder nor the names of its contributors
14 * may be used to endorse or promote products derived from this software without
15 * specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *********************************************************************/
28 
31 
35 
36 namespace fsrobo_r_driver
37 {
38 namespace robot_state_interface
39 {
40 
42 {
43  this->connection_ = NULL;
48 }
49 
50 bool FSRoboRRobotStateInterface::init(std::string default_ip, int default_port)
51 {
52  std::string ip;
53  int port;
54 
55  // override IP/port with ROS params, if available
56  ros::param::param<std::string>("robot_ip_address", ip, default_ip);
57  ros::param::param<int>("~port", port, default_port);
58 
59  // check for valid parameter values
60  if (ip.empty())
61  {
62  ROS_ERROR("No valid robot IP address found. Please set ROS 'robot_ip_address' param");
63  return false;
64  }
65  if (port <= 0)
66  {
67  ROS_ERROR("No valid robot IP port found. Please set ROS '~port' param");
68  return false;
69  }
70 
71  char* ip_addr = strdup(ip.c_str()); // connection.init() requires "char*", not "const char*"
72  ROS_INFO("Robot state connecting to IP address: '%s:%d'", ip_addr, port);
73  default_tcp_connection_.init(ip_addr, port);
74  free(ip_addr);
75 
77 }
78 
80 {
81  std::vector<std::string> joint_names;
82  if (!getJointNames("controller_joint_names", "robot_description", joint_names))
83  {
84  ROS_ERROR("Failed to initialize joint_names. Aborting");
85  return false;
86  }
87 
88  return init(connection, joint_names);
89 }
90 
91 bool FSRoboRRobotStateInterface::init(SmplMsgConnection* connection, std::vector<std::string>& joint_names)
92 {
93  this->joint_names_ = joint_names;
94  this->connection_ = connection;
96 
97  // initialize message-manager
99  return false;
100 
101  // initialize default handlers
103  return false;
105 
107  return false;
109 
111  return false;
113 
115  return false;
117 
118  return true;
119 }
120 
122 {
123  manager_.spin();
124 }
125 
126 } // namespace robot_state_interface
127 } // namespace fsrobo_r_driver
bool init(industrial::smpl_msg_connection::SmplMsgConnection *connection, std::vector< std::string > &joint_names)
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.
bool init(industrial::smpl_msg_connection::SmplMsgConnection *connection)
Class initializer.
bool init(industrial::smpl_msg_connection::SmplMsgConnection *connection)
#define ROS_INFO(...)
void add_handler(MessageHandler *handler, bool allow_replace=true)
Add a new handler.
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)
#define ROS_ERROR(...)


fsrobo_r_driver
Author(s): F-ROSROBO
autogenerated on Sun Feb 9 2020 03:58:29