Skip to content

Commit

Permalink
Added support for IP address and port of the Lidar to be passed as an…
Browse files Browse the repository at this point in the history
… argument
  • Loading branch information
Aarush Gupta authored and Karsten1987 committed Jun 16, 2019
1 parent a7c90ec commit f367f49
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
14 changes: 14 additions & 0 deletions include/urg_node/urg_node_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
17 changes: 17 additions & 0 deletions src/urg_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ int main(int argc, char **argv)
userLatency = boost::lexical_cast<double>(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<int>(strIPPort);
}

// Support the optional laser frame id command line argument
std::string laserFrameId = "laser";
option = "--laser-frame-id";
Expand All @@ -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();
Expand Down
10 changes: 10 additions & 0 deletions src/urg_node_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f367f49

Please sign in to comment.