Skip to content

Commit b62c3f3

Browse files
authored
137 feature fix seyond timestamp (#138)
* fix: Using system time when PTP is unavailable * chore: disable gpsbin_folder
1 parent 7c1112b commit b62c3f3

File tree

4 files changed

+27
-8
lines changed

4 files changed

+27
-8
lines changed

modules/drivers/gnss/conf/gnss_conf.pb.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ tf {
4848
# If given, the driver will send velocity info into novatel one time per second
4949
wheel_parameters: "SETWHEELPARAMETERS 100 1 1\r\n"
5050

51-
gpsbin_folder: "/apollo/data/gpsbin"
51+
#gpsbin_folder: "/apollo/data/gpsbin"
5252

5353
#########################################################################
5454
# notice: only for debug, won't configure device through driver online!!!

modules/drivers/lidar/seyond/BUILD

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ cc_library(
3333
"src/seyond_driver.h",
3434
],
3535
copts = SEYOND_COPTS + ["-std=c++17"],
36-
# linkopts = [
37-
# "-linnoclientsdk",
38-
# ],
3936
deps = [
37+
"//cyber",
4038
"//modules/common_msgs/sensor_msgs:pointcloud_cc_proto",
4139
"//modules/drivers/lidar/common:lidar_common",
4240
"//modules/drivers/lidar/seyond/proto:seyond_cc_proto",

modules/drivers/lidar/seyond/src/seyond_driver.cpp

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*****************************************************************************/
16+
1617
#include "modules/drivers/lidar/seyond/src/seyond_driver.h"
1718

19+
#include "cyber/time/time.h"
20+
1821
static const uint32_t KBUF_SIZE = 1024 * 1024 * 10;
1922
static const double us_in_second_c = 1000000.0;
2023
static const double ten_us_in_second_c = 100000.0;
@@ -244,12 +247,28 @@ int32_t SeyondDriver::data_callback_(const InnoDataPacket *pkt) {
244247
is_next_frame = true;
245248
}
246249

250+
uint64_t lidar_raw_ns = static_cast<uint64_t>(pkt->common.ts_start_us) * 1000;
251+
if (!param_.raw_packets_mode) {
252+
if (lidar_raw_ns < 1577836800000000000ULL) {
253+
if (ts_offset_ns_ == 0) {
254+
ts_offset_ns_ =
255+
apollo::cyber::Time::Now().ToNanosecond() - lidar_raw_ns;
256+
}
257+
} else {
258+
ts_offset_ns_ = 0;
259+
}
260+
} else {
261+
// There should be no software offset during playback of
262+
// the recorded package.
263+
ts_offset_ns_ = 0;
264+
}
265+
247266
packet_publish_cb_(pkt, is_next_frame);
248267

249268
if (is_next_frame) {
250-
point_cloud_ptr_->mutable_header()->set_lidar_timestamp(
251-
(static_cast<uint64_t>(pkt->common.ts_start_us)) * 1000);
252-
point_cloud_ptr_->set_measurement_time(pkt->common.ts_start_us * 1e-6);
269+
uint64_t corrected_ns = lidar_raw_ns + ts_offset_ns_;
270+
point_cloud_ptr_->mutable_header()->set_lidar_timestamp(corrected_ns);
271+
point_cloud_ptr_->set_measurement_time(corrected_ns * 1e-9);
253272
point_cloud_ptr_->set_height(1);
254273
point_cloud_ptr_->set_width(frame_points_width_);
255274
// data publish
@@ -324,7 +343,8 @@ void SeyondDriver::convert_and_parse_(const InnoDataPacket *pkt) {
324343

325344
int32_t SeyondDriver::process_data_packet_(const InnoDataPacket *pkt) {
326345
// calculate the point timestamp
327-
current_ts_start_ = pkt->common.ts_start_us / us_in_second_c;
346+
current_ts_start_ = (static_cast<double>(pkt->common.ts_start_us) * 1e-6) +
347+
(static_cast<double>(ts_offset_ns_) * 1e-9);
328348
// adapt different data structures form different lidar
329349
if (CHECK_EN_XYZ_POINTCLOUD_DATA(pkt->type)) {
330350
const InnoEnXyzPoint *pt = reinterpret_cast<const InnoEnXyzPoint *>(

modules/drivers/lidar/seyond/src/seyond_driver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ class SeyondDriver {
160160
uint32_t packets_width_{0};
161161
int64_t current_frame_id_{-1};
162162
double current_ts_start_;
163+
uint64_t ts_offset_ns_ = 0;
163164
uint64_t frame_points_width_;
164165
std::vector<uint8_t> convert_buffer_;
165166
static bool inno_logs_setted_;

0 commit comments

Comments
 (0)