From 7a5e09b179a6f49a32e441a35ecc75791e7b0b53 Mon Sep 17 00:00:00 2001 From: Peter Corke Date: Sun, 5 Jul 2026 16:15:31 +1000 Subject: [PATCH] fix(mobile): guard VehicleDriverBase against workspace=None, fix RandomPath docstring example expand_dims(None) raises TypeError despite None being its own advertised default (spatialmath-python bug, tracked in that repo's tech-debt.md), so VehicleDriverBase.__init__ crashed whenever workspace was left unset. Separately, VehicleBase.control's runblock example passed RandomPath(10) positionally, landing in dthresh instead of workspace via **kwargs. Co-Authored-By: Claude Sonnet 5 --- src/roboticstoolbox/mobile/Vehicle.py | 2 +- src/roboticstoolbox/mobile/drivers.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/roboticstoolbox/mobile/Vehicle.py b/src/roboticstoolbox/mobile/Vehicle.py index 4626ba94a..b9a8ef3b8 100644 --- a/src/roboticstoolbox/mobile/Vehicle.py +++ b/src/roboticstoolbox/mobile/Vehicle.py @@ -371,7 +371,7 @@ def control(self): >>> from roboticstoolbox import Bicycle, RandomPath >>> bike = Bicycle() - >>> bike.control = RandomPath(10) + >>> bike.control = RandomPath(workspace=10) >>> print(bike) :seealso: :meth:`run` :meth:`eval_control` :obj:`scipy.interpolate.interp1d` :class:`~roboticstoolbox.mobile.drivers.VehicleDriverBase` diff --git a/src/roboticstoolbox/mobile/drivers.py b/src/roboticstoolbox/mobile/drivers.py index 706694e1c..c4251d612 100644 --- a/src/roboticstoolbox/mobile/drivers.py +++ b/src/roboticstoolbox/mobile/drivers.py @@ -58,7 +58,13 @@ def __init__( [A, B, C, D] A:B C:D ============== ======= ======= """ - if hasattr(workspace, "workspace"): + if workspace is None: + # spatialmath.base.expand_dims(None) raises TypeError despite + # None being its own advertised default (see tech-debt.md in + # the spatialmath-python repo) — treat "no workspace" as None + # rather than relying on that default. + self._workspace = None + elif hasattr(workspace, "workspace"): # workspace can be defined by an object with a workspace attribute self._workspace = base.expand_dims(workspace.workspace) else: