From e3e016ace4ae3cdf669390cd0c50887b97eca3f6 Mon Sep 17 00:00:00 2001 From: ob-yalian Date: Fri, 3 Apr 2026 16:09:54 +0800 Subject: [PATCH] fix: update CMakeLists.txt to include ip_config_tool and remove LLA parameters from ip_config_tool --- orbbec_camera/CMakeLists.txt | 2 +- orbbec_camera/tools/ip_config_tool.cpp | 71 ++++++-------------------- 2 files changed, 16 insertions(+), 57 deletions(-) diff --git a/orbbec_camera/CMakeLists.txt b/orbbec_camera/CMakeLists.txt index 29079dcf..a4b6ba75 100644 --- a/orbbec_camera/CMakeLists.txt +++ b/orbbec_camera/CMakeLists.txt @@ -254,7 +254,7 @@ if(DEFINED ENV{BUILDING_PACKAGE}) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/scripts/99-obsensor-libusb.rules DESTINATION /etc/udev/rules.d) endif() -install(TARGETS list_devices_node list_depth_work_mode_node list_camera_profile_mode_node firmware_update_tool topic_statistics_node service_benchmark_node ob_benchmark_node 435le_example_node set_device_ip image_sync_example_node DESTINATION lib/${PROJECT_NAME}/ +install(TARGETS list_devices_node list_depth_work_mode_node list_camera_profile_mode_node firmware_update_tool topic_statistics_node service_benchmark_node ob_benchmark_node 435le_example_node ip_config_tool set_device_ip image_sync_example_node DESTINATION lib/${PROJECT_NAME}/ ) if(BUILD_TESTING) diff --git a/orbbec_camera/tools/ip_config_tool.cpp b/orbbec_camera/tools/ip_config_tool.cpp index eaab8b06..3da708b9 100644 --- a/orbbec_camera/tools/ip_config_tool.cpp +++ b/orbbec_camera/tools/ip_config_tool.cpp @@ -26,17 +26,6 @@ bool parseIpString(const std::string &ip_str, uint8_t ip[4]) { return i == 4; } -bool isParamProvided(int argc, char **argv, const std::string &key) { - const std::string pattern = key + ":="; - for (int i = 1; i < argc; ++i) { - const std::string arg(argv[i]); - if (arg.find(pattern) != std::string::npos) { - return true; - } - } - return false; -} - void printHelp() { std::cout << "Usage:\n" @@ -45,10 +34,6 @@ void printHelp() { << "Parameters:\n" << " -p old_ip:= Current device IP (default: 192.168.1.10)\n" << " -p port:= Device port (default: 8090)\n" - << " -p enable_lla:= Set LLA switch directly (true: enable, false: disable, " - "default: false)\n" - << " Note: LLA is applied only when this parameter is " - "explicitly provided.\n" << " -p enable_set_ip:= Enable set-ip operation (default: false)\n" << " -p dhcp:= DHCP flag for set-ip/force-ip config (default: false)\n" << " -p new_ip:= Static IP for set-ip/force-ip (default: 192.168.1.200)\n" @@ -59,12 +44,6 @@ void printHelp() { "54:14:FD:06:07:DA)\n\n" << "Examples:\n" << "\n" - << " [LLA]\n" - << " enable: ros2 run orbbec_camera ip_config_tool --ros-args -p old_ip:=192.168.1.10 -p " - "enable_lla:=true\n" - << " disable: ros2 run orbbec_camera ip_config_tool --ros-args -p old_ip:=192.168.1.10 -p " - "enable_lla:=false\n" - << "\n" << " [Set IP]\n" << " DHCP: ros2 run orbbec_camera ip_config_tool --ros-args \\\n" << " -p old_ip:=192.168.1.10 -p enable_set_ip:=true -p dhcp:=true\n" @@ -95,9 +74,6 @@ int main(int argc, char **argv) { std::string device_ip_str = node->declare_parameter("old_ip", "192.168.1.10"); int port = node->declare_parameter("port", 8090); - bool enable_lla = node->declare_parameter("enable_lla", false); - bool do_lla = isParamProvided(argc, argv, "enable_lla"); - bool enable_set_ip = node->declare_parameter("enable_set_ip", false); bool dhcp = node->declare_parameter("dhcp", false); std::string new_ip_str = node->declare_parameter("new_ip", "192.168.1.200"); @@ -107,9 +83,9 @@ int main(int argc, char **argv) { bool enable_force_ip = node->declare_parameter("enable_force_ip", false); std::string force_ip_mac = node->declare_parameter("force_ip_mac", ""); - if (!do_lla && !enable_set_ip && !enable_force_ip) { + if (!enable_set_ip && !enable_force_ip) { RCLCPP_ERROR(logger, - "No operation enabled. Please enable at least one of: enable_lla, enable_set_ip, " + "No operation enabled. Please enable at least one of: enable_set_ip, " "enable_force_ip."); rclcpp::shutdown(); return 1; @@ -140,41 +116,24 @@ int main(int argc, char **argv) { ob::Context::setLoggerSeverity(OBLogSeverity::OB_LOG_SEVERITY_OFF); auto context = std::make_shared(); - if (do_lla || enable_set_ip) { + if (enable_set_ip) { RCLCPP_INFO(logger, "Connecting to device %s:%d ...", device_ip_str.c_str(), port); auto device = context->createNetDevice(device_ip_str.c_str(), port); - if (do_lla) { - if (device->isPropertySupported(OB_PROP_DEVICE_NETWORK_LLA_BOOL, - OB_PERMISSION_READ_WRITE)) { - device->setBoolProperty(OB_PROP_DEVICE_NETWORK_LLA_BOOL, enable_lla); - RCLCPP_INFO(logger, "LLA set successfully. target=%s", - enable_lla ? "enabled" : "disabled"); - } else { - RCLCPP_WARN(logger, "LLA property is not supported on this device."); - } - } else { - RCLCPP_INFO(logger, "LLA operation skipped (enable_lla not explicitly provided)."); - } + RCLCPP_INFO(logger, "Applying set-ip configuration..."); + device->setStructuredData(OB_STRUCT_DEVICE_IP_ADDR_CONFIG, + reinterpret_cast(&ip_config), sizeof(ip_config)); - if (enable_set_ip) { - RCLCPP_INFO(logger, "Applying set-ip configuration..."); - device->setStructuredData(OB_STRUCT_DEVICE_IP_ADDR_CONFIG, - reinterpret_cast(&ip_config), sizeof(ip_config)); - - RCLCPP_INFO(logger, "Set-ip configuration applied successfully."); - if (dhcp) { - RCLCPP_INFO(logger, "Set-ip target mode: DHCP."); - } else { - RCLCPP_INFO(logger, "Set-ip target static IP: %d.%d.%d.%d", ip_config.address[0], - ip_config.address[1], ip_config.address[2], ip_config.address[3]); - RCLCPP_INFO(logger, "Set-ip target mask: %d.%d.%d.%d", ip_config.mask[0], - ip_config.mask[1], ip_config.mask[2], ip_config.mask[3]); - RCLCPP_INFO(logger, "Set-ip target gateway: %d.%d.%d.%d", ip_config.gateway[0], - ip_config.gateway[1], ip_config.gateway[2], ip_config.gateway[3]); - } + RCLCPP_INFO(logger, "Set-ip configuration applied successfully."); + if (dhcp) { + RCLCPP_INFO(logger, "Set-ip target mode: DHCP."); } else { - RCLCPP_INFO(logger, "Set-ip operation skipped (enable_set_ip=false)."); + RCLCPP_INFO(logger, "Set-ip target static IP: %d.%d.%d.%d", ip_config.address[0], + ip_config.address[1], ip_config.address[2], ip_config.address[3]); + RCLCPP_INFO(logger, "Set-ip target mask: %d.%d.%d.%d", ip_config.mask[0], + ip_config.mask[1], ip_config.mask[2], ip_config.mask[3]); + RCLCPP_INFO(logger, "Set-ip target gateway: %d.%d.%d.%d", ip_config.gateway[0], + ip_config.gateway[1], ip_config.gateway[2], ip_config.gateway[3]); } }