update
This commit is contained in:
@@ -316,7 +316,14 @@ void ZlacMotorDriver::telemetryLoop() {
|
||||
pos_ok = true;
|
||||
}
|
||||
}
|
||||
if (pos_ok) cached_pos_valid_ = true;
|
||||
if (pos_ok) {
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(cached_pos_time_mu_);
|
||||
cached_pos_time_ = std::chrono::steady_clock::now();
|
||||
}
|
||||
cached_pos_seq_.fetch_add(1);
|
||||
cached_pos_valid_ = true;
|
||||
}
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(20)); // 50 Hz telemetry poll
|
||||
}
|
||||
@@ -334,12 +341,20 @@ bool ZlacMotorDriver::getActualRPM(double& out_left_rpm, double& out_right_rpm)
|
||||
// [vslam] Xem PROVENANCE.md. 0x6064 la bo dem TUYET DOI trong driver motor:
|
||||
// lo mot mau thi mau sau van dung, khac han tich phan van toc.
|
||||
bool ZlacMotorDriver::getPositionCounts(int32_t& out_left, int32_t& out_right,
|
||||
double* out_skew_sec) {
|
||||
double* out_skew_sec,
|
||||
uint64_t* out_seq,
|
||||
double* out_age_sec) {
|
||||
if (!cached_pos_valid_.load()) return false;
|
||||
out_left = cached_left_pos_raw_.load();
|
||||
out_right = cached_right_pos_raw_.load();
|
||||
// Banh PHAI duoc lay mau muon hon banh TRAI bay nhieu giay. 0 khi di qua PDO.
|
||||
if (out_skew_sec) *out_skew_sec = cached_pos_skew_sec_.load();
|
||||
if (out_seq) *out_seq = cached_pos_seq_.load();
|
||||
if (out_age_sec) {
|
||||
std::lock_guard<std::mutex> lk(cached_pos_time_mu_);
|
||||
*out_age_sec = std::chrono::duration<double>(
|
||||
std::chrono::steady_clock::now() - cached_pos_time_).count();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user