38 #include <diagnostic_msgs/AddDiagnostics.h> 39 #include <diagnostic_msgs/DiagnosticStatus.h> 40 #include <urg_node/Status.h> 87 if (publish_multiecho_)
131 if (
urg_->getAR00Status(status))
133 urg_node::Status
msg;
143 if (
urg_->getDL00Status(report))
145 msg.area_number = report.
area;
147 msg.angle = report.
angle;
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;
246 srv_->getConfigMin(min);
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;
254 srv_->setConfigMin(min);
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());
587 if (
urg_->grabScan(msg))
601 const sensor_msgs::LaserScanPtr
msg(
new sensor_msgs::LaserScan());
602 if (
urg_->grabScan(msg))
623 boost::this_thread::sleep_for(boost::chrono::milliseconds(10));
void calibrate_time_offset()
static LaserPublisher advertiseLaser(ros::NodeHandle &nh, uint32_t queue_size, bool latch=false)
ros::Publisher status_pub_
std::string product_name_
bool updateStatus()
Trigger an update of the lidar's status publish the latest known information about the lidar on latch...
std::string protocol_version_
boost::shared_ptr< urg_node::URGCWrapper > urg_
void summary(unsigned char lvl, const std::string s)
boost::shared_ptr< bond::Bond > bond_
bool call(const std::string &service_name, MReq &req, MRes &res)
double diagnostics_window_time_
ROSCPP_DECL const std::string & getName()
boost::shared_ptr< diagnostic_updater::HeaderlessTopicDiagnostic > laser_freq_
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
boost::thread diagnostics_thread_
boost::shared_ptr< diagnostic_updater::Updater > diagnostic_updater_
boost::thread scan_thread_
void update_reconfigure_limits()
boost::shared_ptr< diagnostic_updater::HeaderlessTopicDiagnostic > echoes_freq_
void summaryf(unsigned char lvl, const char *format,...)
std::string resolve(const std::string &prefix, const std::string &frame_name)
std::string firmware_version_
void publish(const sensor_msgs::MultiEchoLaserScan &msg) const
boost::mutex lidar_mutex_
ROSCPP_DECL void set(const std::string &key, const XmlRpc::XmlRpcValue &v)
std::string device_status_
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
void publish(const boost::shared_ptr< M > &message) const
ROSCPP_DECL const std::string & getNamespace()
volatile bool service_yield_
#define ROS_WARN_THROTTLE(period,...)
laser_proc::LaserPublisher echoes_pub_
#define ROS_ERROR_THROTTLE(period,...)
ROSCPP_DECL bool has(const std::string &key)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
bool statusCallback(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res)
std::string firmware_date_
boost::shared_ptr< dynamic_reconfigure::Server< urg_node::URGConfig > > srv_
Dynamic reconfigure server.
#define ROS_INFO_STREAM(args)
diagnostic_updater::FrequencyStatusParam FrequencyStatusParam
ROSCPP_DECL void shutdown()
ros::Publisher laser_pub_
void add(const std::string &key, const T &val)
double diagnostics_tolerance_
ros::ServiceServer status_service_
ROSCPP_DECL void spinOnce()
void populateDiagnosticsStatus(diagnostic_updater::DiagnosticStatusWrapper &stat)
void run()
Start's the nodes threads to run the lidar.
#define ROS_DEBUG_THROTTLE(period,...)
bool reconfigure_callback(urg_node::URGConfig &config, int level)
ROSCPP_DECL bool waitForService(const std::string &service_name, int32_t timeout)