urg_stamped.h
Go to the documentation of this file.
1 /*
2  * Copyright 2018-2021 The urg_stamped Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef URG_STAMPED_URG_STAMPED_H
18 #define URG_STAMPED_URG_STAMPED_H
19 
20 #include <ros/ros.h>
21 #include <sensor_msgs/LaserScan.h>
22 
23 #include <boost/bind/bind.hpp>
24 #include <boost/format.hpp>
25 #include <boost/thread.hpp>
26 
27 #include <algorithm>
28 #include <list>
29 #include <map>
30 #include <random>
31 #include <string>
32 #include <vector>
33 
34 #include <scip2/scip2.h>
35 #include <scip2/walltime.h>
36 
41 #include <urg_stamped/ros_logger.h>
42 
43 namespace urg_stamped
44 {
46 {
47 protected:
54 
55  sensor_msgs::LaserScan msg_base_;
56  uint32_t step_min_;
57  uint32_t step_max_;
58 
61 
64 
65  enum class DelayEstimState
66  {
67  IDLE,
70  ESTIMATING,
71  EXITING,
72  };
74  boost::posix_time::ptime time_tm_request;
75  std::list<ros::Duration> communication_delays_;
76  std::list<ros::Time> device_time_origins_;
78  size_t tm_iter_num_;
82 
83  boost::posix_time::ptime time_ii_request;
84  std::vector<ros::Duration> on_scan_communication_delays_;
85 
88 
90 
91  std::default_random_engine random_engine_;
92  std::uniform_real_distribution<double> sync_interval_;
94 
100 
102  {
104  : abnormal_error(0)
105  , error(0)
106  {
107  }
109  int error;
110  };
113 
114  void cbM(
115  const boost::posix_time::ptime& time_read,
116  const std::string& echo_back,
117  const std::string& status,
118  const scip2::ScanData& scan,
119  const bool has_intensity);
120  void cbTMSend(const boost::posix_time::ptime& time_send);
121  void cbTM(
122  const boost::posix_time::ptime& time_read,
123  const std::string& echo_back,
124  const std::string& status,
125  const scip2::Timestamp& time_device);
126  void cbPP(
127  const boost::posix_time::ptime& time_read,
128  const std::string& echo_back,
129  const std::string& status,
130  const std::map<std::string, std::string>& params);
131  void cbVV(
132  const boost::posix_time::ptime& time_read,
133  const std::string& echo_back,
134  const std::string& status,
135  const std::map<std::string, std::string>& params);
136  void cbIISend(const boost::posix_time::ptime& time_send);
137  void cbII(
138  const boost::posix_time::ptime& time_read,
139  const std::string& echo_back,
140  const std::string& status,
141  const std::map<std::string, std::string>& params);
142  void cbQT(
143  const boost::posix_time::ptime& time_read,
144  const std::string& echo_back,
145  const std::string& status);
146  void cbRB(
147  const boost::posix_time::ptime& time_read,
148  const std::string& echo_back,
149  const std::string& status);
150  void cbRS(
151  const boost::posix_time::ptime& time_read,
152  const std::string& echo_back,
153  const std::string& status);
154  void cbConnect();
155 
156  void timeSync(const ros::TimerEvent& event = ros::TimerEvent());
157  void delayEstimation(const ros::TimerEvent& event = ros::TimerEvent());
158  void retryTM(const ros::TimerEvent& event = ros::TimerEvent());
159 
160  void errorCountIncrement(const std::string& status);
161 
163  const boost::posix_time::ptime& time_response,
164  const uint64_t& device_timestamp);
165 
166  void softReset();
167  void hardReset();
168 
169 public:
170  UrgStampedNode();
171  void spin();
172 };
173 } // namespace urg_stamped
174 
175 #endif // URG_STAMPED_URG_STAMPED_H
void cbTM(const boost::posix_time::ptime &time_read, const std::string &echo_back, const std::string &status, const scip2::Timestamp &time_device)
std::shared_ptr< Connection > Ptr
Definition: connection.h:66
scip2::Protocol::Ptr scip_
Definition: urg_stamped.h:60
scip2::Walltime< 24 > walltime_
Definition: urg_stamped.h:89
void cbM(const boost::posix_time::ptime &time_read, const std::string &echo_back, const std::string &status, const scip2::ScanData &scan, const bool has_intensity)
Definition: urg_stamped.cpp:45
bool detectDeviceTimeJump(const boost::posix_time::ptime &time_response, const uint64_t &device_timestamp)
void cbQT(const boost::posix_time::ptime &time_read, const std::string &echo_back, const std::string &status)
sensor_msgs::LaserScan msg_base_
Definition: urg_stamped.h:55
void cbTMSend(const boost::posix_time::ptime &time_send)
void cbRS(const boost::posix_time::ptime &time_read, const std::string &echo_back, const std::string &status)
void cbPP(const boost::posix_time::ptime &time_read, const std::string &echo_back, const std::string &status, const std::map< std::string, std::string > &params)
DelayEstimState delay_estim_state_
Definition: urg_stamped.h:73
void cbRB(const boost::posix_time::ptime &time_read, const std::string &echo_back, const std::string &status)
void cbVV(const boost::posix_time::ptime &time_read, const std::string &echo_back, const std::string &status, const std::map< std::string, std::string > &params)
std::uniform_real_distribution< double > sync_interval_
Definition: urg_stamped.h:92
ResponseErrorCount error_count_
Definition: urg_stamped.h:111
void retryTM(const ros::TimerEvent &event=ros::TimerEvent())
std::vector< ros::Duration > on_scan_communication_delays_
Definition: urg_stamped.h:84
std::default_random_engine random_engine_
Definition: urg_stamped.h:91
std::list< ros::Duration > communication_delays_
Definition: urg_stamped.h:75
double communication_delay_filter_alpha_
Definition: urg_stamped.h:81
std::list< ros::Time > device_time_origins_
Definition: urg_stamped.h:76
boost::posix_time::ptime time_ii_request
Definition: urg_stamped.h:83
FirstOrderHPF< double > timestamp_hpf_
Definition: urg_stamped.h:97
boost::posix_time::ptime time_tm_request
Definition: urg_stamped.h:74
ros::Duration estimated_communication_delay_
Definition: urg_stamped.h:77
std::shared_ptr< Protocol > Ptr
Definition: protocol.h:67
void timeSync(const ros::TimerEvent &event=ros::TimerEvent())
void delayEstimation(const ros::TimerEvent &event=ros::TimerEvent())
device_time_origin::DriftedTime device_time_origin_
Definition: urg_stamped.h:86
void cbII(const boost::posix_time::ptime &time_read, const std::string &echo_back, const std::string &status, const std::map< std::string, std::string > &params)
FirstOrderLPF< double > timestamp_lpf_
Definition: urg_stamped.h:96
void cbIISend(const boost::posix_time::ptime &time_send)
TimestampMovingAverage timestamp_moving_average_
Definition: urg_stamped.h:99
ros::Publisher pub_scan_
Definition: urg_stamped.h:50
TimestampOutlierRemover timestamp_outlier_removal_
Definition: urg_stamped.h:98
std::ostream & error()
Definition: logger.cpp:105
void errorCountIncrement(const std::string &status)
scip2::Connection::Ptr device_
Definition: urg_stamped.h:59


urg_stamped
Author(s): Atsushi Watanabe
autogenerated on Tue May 11 2021 02:14:05