Update gdt calculation in tfCallback
This commit is contained in:
parent
678a29efc7
commit
d17ab6bc99
|
@ -46,20 +46,23 @@ namespace v2x
|
|||
}
|
||||
|
||||
void V2XApp::tfCallback(const tf2_msgs::msg::TFMessage::ConstSharedPtr msg) {
|
||||
if (tf_interval_ == 4) {
|
||||
// RCLCPP_INFO(node_->get_logger(), "V2XApp: tf msg received");
|
||||
tf_received_ = true;
|
||||
|
||||
double x = msg->transforms[0].transform.translation.x;
|
||||
double y = msg->transforms[0].transform.translation.y;
|
||||
double z = msg->transforms[0].transform.translation.z;
|
||||
int gdt_timestamp_sec = msg->transforms[0].header.stamp.sec; // seconds
|
||||
int gdt_timestamp_nsec = msg->transforms[0].header.stamp.nanosec; // nanoseconds
|
||||
long long gdt_timestamp = gdt_timestamp_sec * 1e9 + gdt_timestamp_nsec; // nanoseconds
|
||||
long long gdt_timestamp_msec = gdt_timestamp / 1000000;
|
||||
long long gdt_timestamp_msec_etsi_epoch = gdt_timestamp_msec - 1072915200000;
|
||||
int gdt = gdt_timestamp_msec_etsi_epoch % 65536; // milliseconds
|
||||
RCLCPP_INFO(node_->get_logger(), "gdt %d, gdt_timestamp %ld, gdt_timestamp_etsi %ld", gdt, gdt_timestamp_msec, gdt_timestamp_msec_etsi_epoch);
|
||||
|
||||
long long timestamp_sec = msg->transforms[0].header.stamp.sec; // seconds
|
||||
long long timestamp_nsec = msg->transforms[0].header.stamp.nanosec; // nanoseconds
|
||||
timestamp_sec -= 1072915200; // convert to etsi-epoch
|
||||
long long timestamp_msec = timestamp_sec * 1000 + timestamp_nsec / 1000000;
|
||||
// long long gdt_timestamp = gdt_timestamp_sec * 1e9 + gdt_timestamp_nsec; // nanoseconds
|
||||
// long long gdt_timestamp_msec = gdt_timestamp / 1000000;
|
||||
// long long gdt_timestamp_msec_etsi_epoch = gdt_timestamp_msec - 1072915200000;
|
||||
// int gdt = gdt_timestamp_msec_etsi_epoch % 65536; // milliseconds
|
||||
int gdt = timestamp_msec % 65536;
|
||||
RCLCPP_INFO(node_->get_logger(), "[tfCallback] %d,%lld,%lld,%lld", gdt, timestamp_msec, timestamp_sec, timestamp_nsec);
|
||||
|
||||
double rot_x = msg->transforms[0].transform.rotation.x;
|
||||
double rot_y = msg->transforms[0].transform.rotation.y;
|
||||
|
@ -93,11 +96,8 @@ namespace v2x
|
|||
cp->updateMGRS(&x, &y);
|
||||
cp->updateRP(&lat, &lon, &z);
|
||||
cp->updateHeading(&yaw);
|
||||
cp->updateGenerationDeltaTime(&gdt, &gdt_timestamp);
|
||||
cp->updateGenerationDeltaTime(&gdt, ×tamp_msec);
|
||||
}
|
||||
tf_interval_ = 0;
|
||||
}
|
||||
tf_interval_ += 1;
|
||||
}
|
||||
|
||||
void V2XApp::start() {
|
||||
|
|
Loading…
Reference in New Issue