38 #include <diagnostic_msgs/AddDiagnostics.h>
39 #include <diagnostic_msgs/DiagnosticStatus.h>
40 #include <urg_node/Status.h>
131 if (
urg_->getAR00Status(status))
133 urg_node::Status
msg;
143 if (
urg_->getDL00Status(report))
151 ROS_WARN(
"Failed to get detection report.");
160 ROS_WARN(
"Failed to retrieve status");
162 urg_node::Status
msg;
172 ROS_INFO(
"Got update lidar status callback");
174 res.message =
"Laser not ready";
178 res.message =
"Status retrieved";
183 res.message =
"Failed to update status";
194 ROS_ERROR(
"Reconfigure failed, not ready");
200 urg_->setAngleLimitsAndCluster(config.angle_min, config.angle_max, config.cluster);
201 urg_->setSkip(config.skip);
206 ROS_INFO(
"Stopped data due to reconfigure.");
209 urg_->setAngleLimitsAndCluster(config.angle_min, config.angle_max, config.cluster);
210 urg_->setSkip(config.skip);
215 ROS_INFO(
"Streaming data after reconfigure.");
217 catch (std::runtime_error& e)
228 freq_min_ = 1.0 / (
urg_->getScanPeriod() * (config.skip + 1));
230 std::string frame_id =
tf::resolve(config.tf_prefix, config.frame_id);
231 urg_->setFrameId(frame_id);
232 urg_->setUserLatency(config.time_offset);
245 urg_node::URGConfig
min, max;
247 srv_->getConfigMax(max);
249 min.angle_min =
urg_->getAngleMinLimit();
250 min.angle_max =
min.angle_min;
251 max.angle_max =
urg_->getAngleMaxLimit();
252 max.angle_min = max.angle_max;
255 srv_->setConfigMax(max);
269 ROS_INFO(
"Starting calibration. This will take a few seconds.");
270 ROS_WARN(
"Time calibration is still experimental.");
272 ROS_INFO(
"Calibration finished. Latency is: %.4f.", latency.
toSec());
274 catch (std::runtime_error& e)
276 ROS_FATAL(
"Could not calibrate time offset: %s", e.what());
286 std::string node_prefix =
"";
288 std::string node_path;
289 std::string node_id = node_name;
292 if (node_namespace ==
"/")
299 size_t pos = node_id.find(
"/");
300 while (pos != std::string::npos)
302 node_id.replace(pos, 1,
"_");
303 pos = node_id.find(
"/");
308 pos = node_path.find(
"_");
309 while (pos != std::string::npos)
311 node_path.replace(pos, 1,
" ");
312 pos = node_path.find(
"_");
319 ros::param::set(node_prefix +
"analyzers/hokuyo/type",
"diagnostic_aggregator/AnalyzerGroup");
323 std::string analyzerPath = node_prefix +
"analyzers/hokuyo/analyzers/" + node_id;
327 ros::param::set(analyzerPath +
"/type",
"diagnostic_aggregator/GenericAnalyzer");
333 if (
bond_ ==
nullptr)
337 else if (!
bond_->isBroken())
341 bond_->setConnectTimeout(120);
344 diagnostic_msgs::AddDiagnostics srv;
345 srv.request.load_namespace = node_namespace;
361 boost::this_thread::sleep_for(boost::chrono::milliseconds(10));
370 stat.
summary(diagnostic_msgs::DiagnosticStatus::ERROR,
375 if (!
urg_->getIPAddress().empty())
377 stat.
add(
"IP Address",
urg_->getIPAddress());
378 stat.
add(
"IP Port",
urg_->getIPPort());
382 stat.
add(
"Serial Port",
urg_->getSerialPort());
383 stat.
add(
"Serial Baud",
urg_->getSerialBaud());
386 if (!
urg_->isStarted())
388 stat.
summary(diagnostic_msgs::DiagnosticStatus::ERROR,
395 stat.
summary(diagnostic_msgs::DiagnosticStatus::ERROR,
400 stat.
summaryf(diagnostic_msgs::DiagnosticStatus::ERROR,
401 "Lidar reporting error code: %X",
406 stat.
summary(diagnostic_msgs::DiagnosticStatus::ERROR,
407 "Lidar locked out.");
411 stat.
summary(diagnostic_msgs::DiagnosticStatus::OK,
421 stat.
add(
"Computed Latency",
urg_->getComputedLatency());
422 stat.
add(
"User Time Offset",
urg_->getUserTimeOffset());
452 std::stringstream ss;
453 ss <<
"Connected to";
466 ss <<
" device with";
469 ss <<
" intensity and";
471 ss <<
" ID: " <<
urg_->getDeviceID();
489 catch (std::runtime_error& e)
495 catch (std::exception& e)
513 boost::this_thread::sleep(boost::posix_time::milliseconds(500));
539 srv_.reset(
new dynamic_reconfigure::Server<urg_node::URGConfig>(
pnh_));
563 catch (std::runtime_error& e)
586 const sensor_msgs::MultiEchoLaserScanPtr
msg(
new sensor_msgs::MultiEchoLaserScan());
601 const sensor_msgs::LaserScanPtr
msg(
new sensor_msgs::LaserScan());
623 boost::this_thread::sleep_for(boost::chrono::milliseconds(10));