update
This commit is contained in:
@@ -291,13 +291,28 @@ void ZlacMotorDriver::telemetryLoop() {
|
||||
auto rpdo = master_->RpdoMapped(node_id_);
|
||||
cached_left_pos_raw_ = static_cast<int32_t>(rpdo[0x6064][1]);
|
||||
cached_right_pos_raw_ = static_cast<int32_t>(rpdo[0x6064][2]);
|
||||
// PDO: ca hai banh den trong CUNG mot khung CAN -> khong lech.
|
||||
cached_pos_skew_sec_ = 0.0;
|
||||
pos_ok = true;
|
||||
} catch (...) {
|
||||
// [vslam] DO do lech thay vi bo qua no.
|
||||
//
|
||||
// Hai lan doc la hai giao dich tuan tu, nen banh phai duoc lay mau
|
||||
// SAU banh trai mot khoang. Moc thoi gian hieu dung cua moi lan doc
|
||||
// nam o GIUA giao dich, nen:
|
||||
// lech = (t2 - t0) / 2
|
||||
// Ben goi dung so nay de ngoai suy banh trai toi thoi diem cua banh
|
||||
// phai; khong bu thi cong thuc vi sai bien khoang lech do thanh quay
|
||||
// gia.
|
||||
const auto t0 = std::chrono::steady_clock::now();
|
||||
auto lp = sdo_read_sync<int32_t>(*master_, node_id_, 0x6064, 1);
|
||||
auto rp = sdo_read_sync<int32_t>(*master_, node_id_, 0x6064, 2);
|
||||
const auto t2 = std::chrono::steady_clock::now();
|
||||
if (lp.has_value() && rp.has_value()) {
|
||||
cached_left_pos_raw_ = lp.value();
|
||||
cached_right_pos_raw_ = rp.value();
|
||||
cached_pos_skew_sec_ =
|
||||
std::chrono::duration<double>(t2 - t0).count() / 2.0;
|
||||
pos_ok = true;
|
||||
}
|
||||
}
|
||||
@@ -318,10 +333,13 @@ 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) {
|
||||
bool ZlacMotorDriver::getPositionCounts(int32_t& out_left, int32_t& out_right,
|
||||
double* out_skew_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();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user