40 std::unique_ptr<HandEyeCalibClient>
client;
49 std::string
getHost(
const std::string& device_name,
const std::string& interface)
55 std::vector<rcdiscover::DeviceInfo> infos;
62 std::vector<std::vector<std::string>> devices;
63 std::vector<std::string> filtered_info = {
"",
"" };
64 for (
const auto& info : infos)
66 if (!interface.empty() &&
interface != info.getIfaceName())
72 std::string user_defined_name = info.getUserName();
73 if (user_defined_name.empty())
75 user_defined_name = info.getModelName();
79 if (device_name.empty())
81 if (info.getModelName().find(
"rc_visard") != std::string::npos)
83 filtered_info[0] = user_defined_name;
84 filtered_info[1] =
ip2string(info.getIP());
85 devices.push_back(filtered_info);
88 else if ((device_name == info.getSerialNumber()) || (device_name == user_defined_name))
90 filtered_info[0] = user_defined_name;
91 filtered_info[1] =
ip2string(info.getIP());
92 devices.push_back(filtered_info);
95 std::sort(devices.begin(), devices.end());
96 auto unique_devices_it = std::unique(devices.begin(), devices.end());
97 devices.erase(unique_devices_it, devices.end());
104 else if (devices.size() > 1)
106 ROS_FATAL_STREAM(
"Found " << devices.size() <<
" devices with the name '" << device_name
107 <<
"'. Please specify a unique device name.");
111 ROS_INFO_STREAM(
"Using device '" << device_name <<
"' with name '" << devices[0][0] <<
"' and IP address " 113 return devices[0][1];
116 int main(
int argc,
char** argv)
118 std::string name =
"rc_hand_eye_calibration_client";
128 if (!host.empty() && !device.empty())
130 ROS_WARN(
"Both parameters: 'device' and 'host' are set. Using 'device' to start the client.");
133 if (!device.empty() || host.empty())
135 std::size_t delim_pos = 0;
136 delim_pos = device.find(
':');
137 std::string interface;
138 if (delim_pos != std::string::npos)
140 interface = device.substr(0, delim_pos);
141 device = device.substr(delim_pos + 1);
144 host =
getHost(device, interface);
157 catch (
const std::exception& ex)
159 ROS_FATAL(
"Client could not be created due to an error: %s", ex.what());
163 ROS_INFO_STREAM(
"Hand eye calibration node started for host: " << host);
int main(int argc, char **argv)
std::string ip2string(const uint32_t ip)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ROSCPP_DECL void spin(Spinner &spinner)
std::string getHost(const std::string &device_name, const std::string &interface)
std::unique_ptr< HandEyeCalibClient > client
#define ROS_FATAL_STREAM(args)
bool getResponse(std::vector< DeviceInfo > &info, int timeout_per_socket=1000)
#define ROS_INFO_STREAM(args)
bool getParam(const std::string &key, std::string &s) const
ROSCPP_DECL void shutdown()