تجربة: 500 مشوار
3 م، ولفة 90°، و 2 م، والعجلة بتتزحلق حتة صغيرة عشوائية.
- odometry بس: 95% جوه 19.5 سم.
- المعادلات اتنبأت بـ 8.6 و 6.5 سم، والتجارب قالت 8.0 و 6.3.
- الاتجاه من الـ gyro: 4.8 سم (أصغر 4 مرات).
الشرح بالتفصيل
الزحلقة في المحاكي: كل عجلة على كل حتة مسافة d بتغلط بانحراف معياري 0.002 × √d (2 مم على كل متر جذر). ونشغّل المشوار 500 مرة بـ seeds مختلفة، والـ odometry بالقوس (الفصل 2):
from diffbot import Bot, wheels, DT, BASE
from odo import Odo
SLIP = 0.002
def plan(t): # 3 م لقدام، لفة 90° شمال (R = 30 سم)، و 2 م لقدام
if t < 7.5: return 0.4, 0.0
if t < 7.5 + np.pi / 2 * 0.3 / 0.4: return 0.4, 0.4 / 0.3
return 0.4, 0.0
def run(seed, gyro=False):
b = Bot(slip=SLIP, seed=seed); o = Odo("arc"); g = np.random.default_rng(1000 + seed)
bias = np.radians(g.normal(0, 0.05)) # الـ bias اللي فضل بعد معايرة الجزء 5: حوالي 0.05°/ث
th_g = th_prev = 0.0
for k in range(int(T / DT)):
ticks = b.step(*wheels(*plan(k * DT)))
o.update(ticks)
if gyro: # الاتجاه من الـ gyro: سرعة اللف الحقيقية + bias + ضوضاء
rate = (b.th - th_prev) / DT + bias + np.radians(g.normal(0, 0.1)); th_prev = b.th
th_g += rate * DT; o.th = th_g
return b.x, b.y, o.x, o.y
for gyro in (False, True):
R = np.array([run(s, gyro) for s in range(500)]); err = R[:, 2:] - R[:, :2]
print(f"{'odometry + gyro' if gyro else 'odometry only '}: 500 runs, true end ≈ ({R[:, 0].mean():.2f}, {R[:, 1].mean():.2f}) m, error std along-x {100 * err[:, 0].std():5.1f} cm "
f"along-y {100 * err[:, 1].std():5.1f} cm, 95% of runs within {100 * np.percentile(np.hypot(*err.T), 95):5.1f} cm")
وقبل ما نجرّب: نقدر نحسب حجم السحابة بالمعادلات؟ في كل خطوة، الـ covariance بتاع (x, y, θ) بيتنقل للخطوة الجاية بالـ Jacobian، ونزوّد عليه غلط العجل الجديد:
def predict(): # Σ ← F Σ Fᵀ + G Q Gᵀ (Wang 1988؛ Chong و Kleeman 1997)
S = np.zeros((3, 3)); th = 0.0
for k in range(int(T / DT)):
v, w = plan(k * DT); dl, dr = np.array(wheels(v, w)) * DT
d, dth = (dl + dr) / 2, (dr - dl) / BASE; a = th + dth / 2
F = np.array([[1, 0, -d * np.sin(a)], [0, 1, d * np.cos(a)], [0, 0, 1]]) # الغلط القديم بيتنقل
G = np.array([[np.cos(a) / 2 + d * np.sin(a) / (2 * BASE), np.cos(a) / 2 - d * np.sin(a) / (2 * BASE)],
[np.sin(a) / 2 - d * np.cos(a) / (2 * BASE), np.sin(a) / 2 + d * np.cos(a) / (2 * BASE)],
[-1 / BASE, 1 / BASE]]) # غلط العجل الجديد بيدخل
Q = np.diag([SLIP ** 2 * abs(dl), SLIP ** 2 * abs(dr)])
S = F @ S @ F.T + G @ Q @ G.T; th += dth
return S
odometry only : 500 runs, true end ≈ (3.28, 2.28) m, error std along-x 8.0 cm along-y 6.3 cm, 95% of runs within 19.5 cm odometry + gyro: 500 runs, true end ≈ (3.28, 2.28) m, error std along-x 2.2 cm along-y 1.3 cm, 95% of runs within 4.8 cm Jacobian prediction (no gyro): std along-x 8.6 cm along-y 6.5 cm, heading 2.53°
المعادلات قالت 8.6 و 6.5 سم، و500 تجربة قالت 8.0 و 6.3. يعني تقدر تعرف حجم غلطك من غير ما تجرّب، وده اللي هيخلّي الروبوت في الجزء 13 يعرف يثق في الـ odometry قد إيه مقارنة بحساس تاني.
وشكل السحابة الحمرا مش دايرة: ممطوطة بالعرض في اتجاه مايل. ده الغلط اللي جاي من الاتجاه: الـ 2.5° غلط في الاتجاه، على 5 متر، بيعمل سحابة طويلة على جنب المشوار. والـ gyro بيقيس سرعة اللف مباشرة من غير ما يعتمد على العجل، فالغلط في الاتجاه بقى صغير جدًا، والسحابة صغرت 4 مرات (19.5 → 4.8 سم). وده اللي الروبوتات المكنسة بتعمله: العجل للمسافة، والـ gyro للاتجاه.

