From 872e3e18dfcfd9ddd30575bf3ce9d9a7bb165aa3 Mon Sep 17 00:00:00 2001 From: Gonzalo Casas Date: Wed, 24 Apr 2019 11:44:40 +0200 Subject: [PATCH 1/3] Add configurable reverse ip address (#299) --- launch/ur10_bringup.launch | 2 ++ launch/ur10_bringup_compatible.launch | 2 ++ launch/ur10_bringup_joint_limited.launch | 2 ++ launch/ur10_ros_control.launch | 2 ++ launch/ur3_bringup.launch | 2 ++ launch/ur3_bringup_joint_limited.launch | 2 ++ launch/ur3_ros_control.launch | 2 ++ launch/ur5_bringup.launch | 2 ++ launch/ur5_bringup_compatible.launch | 2 ++ launch/ur5_bringup_joint_limited.launch | 2 ++ launch/ur5_ros_control.launch | 2 ++ launch/ur_common.launch | 2 ++ src/ros_main.cpp | 8 ++++++-- 13 files changed, 30 insertions(+), 2 deletions(-) diff --git a/launch/ur10_bringup.launch b/launch/ur10_bringup.launch index 942a462d5..040131944 100644 --- a/launch/ur10_bringup.launch +++ b/launch/ur10_bringup.launch @@ -10,6 +10,7 @@ + @@ -34,6 +35,7 @@ + diff --git a/launch/ur10_bringup_compatible.launch b/launch/ur10_bringup_compatible.launch index 749c693e6..172d90760 100644 --- a/launch/ur10_bringup_compatible.launch +++ b/launch/ur10_bringup_compatible.launch @@ -10,6 +10,7 @@ + @@ -35,6 +36,7 @@ + diff --git a/launch/ur10_bringup_joint_limited.launch b/launch/ur10_bringup_joint_limited.launch index 85ff2166b..3065ac908 100644 --- a/launch/ur10_bringup_joint_limited.launch +++ b/launch/ur10_bringup_joint_limited.launch @@ -10,6 +10,7 @@ + @@ -28,6 +29,7 @@ + diff --git a/launch/ur10_ros_control.launch b/launch/ur10_ros_control.launch index 471bfd676..38c29e4e7 100644 --- a/launch/ur10_ros_control.launch +++ b/launch/ur10_ros_control.launch @@ -7,6 +7,7 @@ + @@ -27,6 +28,7 @@ + diff --git a/launch/ur3_bringup.launch b/launch/ur3_bringup.launch index 0c37dc9c6..a2182b439 100644 --- a/launch/ur3_bringup.launch +++ b/launch/ur3_bringup.launch @@ -10,6 +10,7 @@ + @@ -34,6 +35,7 @@ + diff --git a/launch/ur3_bringup_joint_limited.launch b/launch/ur3_bringup_joint_limited.launch index df0955597..475f8e5d6 100644 --- a/launch/ur3_bringup_joint_limited.launch +++ b/launch/ur3_bringup_joint_limited.launch @@ -10,6 +10,7 @@ + @@ -28,6 +29,7 @@ + diff --git a/launch/ur3_ros_control.launch b/launch/ur3_ros_control.launch index d778b808f..0e9b14d35 100644 --- a/launch/ur3_ros_control.launch +++ b/launch/ur3_ros_control.launch @@ -7,6 +7,7 @@ + @@ -27,6 +28,7 @@ + diff --git a/launch/ur5_bringup.launch b/launch/ur5_bringup.launch index 780d9bc0c..fb421dc0a 100644 --- a/launch/ur5_bringup.launch +++ b/launch/ur5_bringup.launch @@ -10,6 +10,7 @@ + @@ -34,6 +35,7 @@ + diff --git a/launch/ur5_bringup_compatible.launch b/launch/ur5_bringup_compatible.launch index 069c2a6f5..8657e9a79 100644 --- a/launch/ur5_bringup_compatible.launch +++ b/launch/ur5_bringup_compatible.launch @@ -10,6 +10,7 @@ + @@ -35,6 +36,7 @@ + diff --git a/launch/ur5_bringup_joint_limited.launch b/launch/ur5_bringup_joint_limited.launch index 1975d3b63..571640de9 100644 --- a/launch/ur5_bringup_joint_limited.launch +++ b/launch/ur5_bringup_joint_limited.launch @@ -10,6 +10,7 @@ + @@ -28,6 +29,7 @@ + diff --git a/launch/ur5_ros_control.launch b/launch/ur5_ros_control.launch index d1118e6ae..d65eaa34e 100644 --- a/launch/ur5_ros_control.launch +++ b/launch/ur5_ros_control.launch @@ -7,6 +7,7 @@ + @@ -27,6 +28,7 @@ + diff --git a/launch/ur_common.launch b/launch/ur_common.launch index 726f7a1c6..7d53a3a2c 100644 --- a/launch/ur_common.launch +++ b/launch/ur_common.launch @@ -9,6 +9,7 @@ + @@ -39,6 +40,7 @@ + diff --git a/src/ros_main.cpp b/src/ros_main.cpp index 7ea7fcf7e..8b3a9a649 100644 --- a/src/ros_main.cpp +++ b/src/ros_main.cpp @@ -44,6 +44,7 @@ #include "ur_modern_driver/ur/state.h" static const std::string IP_ADDR_ARG("~robot_ip_address"); +static const std::string REVERSE_IP_ADDR_ARG("~reverse_ip_address"); static const std::string REVERSE_PORT_ARG("~reverse_port"); static const std::string ROS_CONTROL_ARG("~use_ros_control"); static const std::string LOW_BANDWIDTH_TRAJECTORY_FOLLOWER("~use_lowbandwidth_trajectory_follower"); @@ -69,11 +70,12 @@ struct ProgArgs std::string base_frame; std::string tool_frame; std::string tcp_link; + std::string reverse_ip_address; + int32_t reverse_port; std::vector joint_names; double max_acceleration; double max_velocity; double max_vel_change; - int32_t reverse_port; bool use_ros_control; bool use_lowbandwidth_trajectory_follower; bool shutdown_on_disconnect; @@ -114,6 +116,7 @@ bool parse_args(ProgArgs &args) LOG_ERROR("robot_ip_address parameter must be set!"); return false; } + ros::param::param(REVERSE_IP_ADDR_ARG, args.reverse_ip_address, std::string()); ros::param::param(REVERSE_PORT_ARG, args.reverse_port, int32_t(50001)); ros::param::param(MAX_VEL_CHANGE_ARG, args.max_vel_change, 15.0); // rad/s ros::param::param(MAX_VEL_CHANGE_ARG, args.max_velocity, 10.0); @@ -148,7 +151,8 @@ int main(int argc, char **argv) std::transform(args.joint_names.begin(), args.joint_names.end(), args.joint_names.begin(), [&args](std::string name) { return args.prefix + name; }); - std::string local_ip(getLocalIPAccessibleFromHost(args.host)); + std::string local_ip(args.reverse_ip_address.empty() ? getLocalIPAccessibleFromHost(args.host) : + args.reverse_ip_address); URFactory factory(args.host); vector services; From 972747d415f9e6a51c0ec6f19f4bb5bd6b8633a9 Mon Sep 17 00:00:00 2001 From: Gonzalo Casas Date: Thu, 25 Apr 2019 08:40:39 +0200 Subject: [PATCH 2/3] Apply review suggestions --- launch/ur10_bringup.launch | 6 +++--- launch/ur10_bringup_compatible.launch | 6 +++--- launch/ur10_bringup_joint_limited.launch | 6 +++--- launch/ur10_ros_control.launch | 6 +++--- launch/ur3_bringup.launch | 6 +++--- launch/ur3_bringup_joint_limited.launch | 6 +++--- launch/ur3_ros_control.launch | 6 +++--- launch/ur5_bringup.launch | 6 +++--- launch/ur5_bringup_compatible.launch | 6 +++--- launch/ur5_bringup_joint_limited.launch | 6 +++--- launch/ur5_ros_control.launch | 6 +++--- launch/ur_common.launch | 6 +++--- src/ros_main.cpp | 8 ++++++-- 13 files changed, 42 insertions(+), 38 deletions(-) diff --git a/launch/ur10_bringup.launch b/launch/ur10_bringup.launch index 040131944..6b5960d30 100644 --- a/launch/ur10_bringup.launch +++ b/launch/ur10_bringup.launch @@ -9,8 +9,8 @@ - - + + @@ -35,7 +35,7 @@ - + diff --git a/launch/ur10_bringup_compatible.launch b/launch/ur10_bringup_compatible.launch index 172d90760..6a4f3b842 100644 --- a/launch/ur10_bringup_compatible.launch +++ b/launch/ur10_bringup_compatible.launch @@ -9,8 +9,8 @@ - - + + @@ -36,7 +36,7 @@ - + diff --git a/launch/ur10_bringup_joint_limited.launch b/launch/ur10_bringup_joint_limited.launch index 3065ac908..a99f0fc18 100644 --- a/launch/ur10_bringup_joint_limited.launch +++ b/launch/ur10_bringup_joint_limited.launch @@ -9,8 +9,8 @@ - - + + @@ -29,7 +29,7 @@ - + diff --git a/launch/ur10_ros_control.launch b/launch/ur10_ros_control.launch index 38c29e4e7..20bdef883 100644 --- a/launch/ur10_ros_control.launch +++ b/launch/ur10_ros_control.launch @@ -6,8 +6,8 @@ - - + + @@ -28,7 +28,7 @@ - + diff --git a/launch/ur3_bringup.launch b/launch/ur3_bringup.launch index a2182b439..106a1bd0d 100644 --- a/launch/ur3_bringup.launch +++ b/launch/ur3_bringup.launch @@ -9,8 +9,8 @@ - - + + @@ -35,7 +35,7 @@ - + diff --git a/launch/ur3_bringup_joint_limited.launch b/launch/ur3_bringup_joint_limited.launch index 475f8e5d6..e0c734ef4 100644 --- a/launch/ur3_bringup_joint_limited.launch +++ b/launch/ur3_bringup_joint_limited.launch @@ -9,8 +9,8 @@ - - + + @@ -29,7 +29,7 @@ - + diff --git a/launch/ur3_ros_control.launch b/launch/ur3_ros_control.launch index 0e9b14d35..25b2d5beb 100644 --- a/launch/ur3_ros_control.launch +++ b/launch/ur3_ros_control.launch @@ -6,8 +6,8 @@ - - + + @@ -28,7 +28,7 @@ - + diff --git a/launch/ur5_bringup.launch b/launch/ur5_bringup.launch index fb421dc0a..e568fce2f 100644 --- a/launch/ur5_bringup.launch +++ b/launch/ur5_bringup.launch @@ -9,8 +9,8 @@ - - + + @@ -35,7 +35,7 @@ - + diff --git a/launch/ur5_bringup_compatible.launch b/launch/ur5_bringup_compatible.launch index 8657e9a79..197e95797 100644 --- a/launch/ur5_bringup_compatible.launch +++ b/launch/ur5_bringup_compatible.launch @@ -9,8 +9,8 @@ - - + + @@ -36,7 +36,7 @@ - + diff --git a/launch/ur5_bringup_joint_limited.launch b/launch/ur5_bringup_joint_limited.launch index 571640de9..5c32b6c3f 100644 --- a/launch/ur5_bringup_joint_limited.launch +++ b/launch/ur5_bringup_joint_limited.launch @@ -9,8 +9,8 @@ - - + + @@ -29,7 +29,7 @@ - + diff --git a/launch/ur5_ros_control.launch b/launch/ur5_ros_control.launch index d65eaa34e..f154441f2 100644 --- a/launch/ur5_ros_control.launch +++ b/launch/ur5_ros_control.launch @@ -6,8 +6,8 @@ - - + + @@ -28,7 +28,7 @@ - + diff --git a/launch/ur_common.launch b/launch/ur_common.launch index 7d53a3a2c..2e639c080 100644 --- a/launch/ur_common.launch +++ b/launch/ur_common.launch @@ -8,8 +8,8 @@ --> - - + + @@ -40,7 +40,7 @@ - + diff --git a/src/ros_main.cpp b/src/ros_main.cpp index 8b3a9a649..1fd57b51c 100644 --- a/src/ros_main.cpp +++ b/src/ros_main.cpp @@ -151,8 +151,12 @@ int main(int argc, char **argv) std::transform(args.joint_names.begin(), args.joint_names.end(), args.joint_names.begin(), [&args](std::string name) { return args.prefix + name; }); - std::string local_ip(args.reverse_ip_address.empty() ? getLocalIPAccessibleFromHost(args.host) : - args.reverse_ip_address); + std::string local_ip(args.reverse_ip_address); + + if (local_ip.empty()) + { + local_ip = getLocalIPAccessibleFromHost(args.host); + } URFactory factory(args.host); vector services; From ef88f76bc291e0390a099191733c7e9410d60d2f Mon Sep 17 00:00:00 2001 From: "G.A. vd. Hoorn" Date: Sun, 5 May 2019 15:11:56 +0200 Subject: [PATCH 3/3] Add explanation about reverse IP priority Co-Authored-By: gonzalocasas --- src/ros_main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ros_main.cpp b/src/ros_main.cpp index 1fd57b51c..cc49acfe5 100644 --- a/src/ros_main.cpp +++ b/src/ros_main.cpp @@ -153,6 +153,7 @@ int main(int argc, char **argv) std::string local_ip(args.reverse_ip_address); + // if no reverse IP address has been configured, try to detect one if (local_ip.empty()) { local_ip = getLocalIPAccessibleFromHost(args.host);