diff --git a/include/urg_node/urg_node_driver.h b/include/urg_node/urg_node_driver.h index 874607e9..b5d36672 100644 --- a/include/urg_node/urg_node_driver.h +++ b/include/urg_node/urg_node_driver.h @@ -77,6 +77,20 @@ class UrgNode */ void setLaserFrameId(const std::string& laserFrameId); + /** + * @brief Set the IP Address + * Set the IP address used by the lidar + * @param ipAddr is the IP address + */ + void setIPAdddress(const std::string& ipAddr); + + /** + * @brief Set the IP port + * Set the IP port used by the lidar + * @param ipPort is the IP port + */ + void setIPPort(const int& ipPort); + /** * @brief Start's the nodes threads to run the lidar. */ diff --git a/src/urg_node.cpp b/src/urg_node.cpp index 76c39b91..9b137ba8 100644 --- a/src/urg_node.cpp +++ b/src/urg_node.cpp @@ -61,6 +61,21 @@ int main(int argc, char **argv) userLatency = boost::lexical_cast(strLatency); } + // Support the optional IP address command line argument + std::string ipAddress = ""; + option = "--ip-addr"; + if (rcutils_cli_option_exist(argv, argv + argc, option.c_str())) { + ipAddress = rcutils_cli_get_option(argv, argv + argc, option.c_str()); + } + + // Support the optional IP port command line argument + int ipPort = 0; + option = "--port"; + if (rcutils_cli_option_exist(argv, argv + argc, option.c_str())) { + std::string strIPPort = rcutils_cli_get_option(argv, argv + argc, option.c_str()); + ipPort = boost::lexical_cast(strIPPort); + } + // Support the optional laser frame id command line argument std::string laserFrameId = "laser"; option = "--laser-frame-id"; @@ -73,6 +88,8 @@ int main(int argc, char **argv) // Update settings urgNode.setSerialPort(serialPort); urgNode.setUserLatency(userLatency); + urgNode.setIPAdddress(ipAddress); + urgNode.setIPPort(ipPort); // Run the urg node urgNode.run(); diff --git a/src/urg_node_driver.cpp b/src/urg_node_driver.cpp index c81f6289..99d8f016 100644 --- a/src/urg_node_driver.cpp +++ b/src/urg_node_driver.cpp @@ -62,6 +62,16 @@ void UrgNode::setSerialPort(const std::string& port) serial_port_ = port; } +void UrgNode::setIPAdddress(const std::string& ipAddr) +{ + ip_address_ = ipAddr; +} + +void UrgNode::setIPPort(const int& ipPort) +{ + ip_port_ = ipPort; +} + void UrgNode::setUserLatency(const double& latency) { default_user_latency_ = latency;