Skip to content

fix roboticstoolbox optionality claim for visualize_trajectory.py - #1

Open
Kajko25 wants to merge 2 commits into
AxisAIOrg:mainfrom
Kajko25:fix-rtb-optional-claim
Open

fix roboticstoolbox optionality claim for visualize_trajectory.py#1
Kajko25 wants to merge 2 commits into
AxisAIOrg:mainfrom
Kajko25:fix-rtb-optional-claim

Conversation

@Kajko25

@Kajko25 Kajko25 commented Jul 27, 2026

Copy link
Copy Markdown

The README currently promises:

If roboticstoolbox is not installed, all tools still work; they will automatically fall back to joint‑space visualizations only.

That holds for smooth_resampled_traj.py, which imports it defensively and gates the FK path on _RTB_AVAILABLE:

try:
    import roboticstoolbox as rtb
    _RTB_AVAILABLE = True
except Exception:
    _RTB_AVAILABLE = False

visualize_trajectory.py imports it unguarded at module level (line 11), so without the package it raises ModuleNotFoundError before any of its code runs — it does not fall back, it fails to load.

I deliberately did not add a try/except there. That script is 138 lines with a single plotting function that consumes forward-kinematics positions; end-effector space is the whole point of it, so there is no joint-space path to fall back to. Faking one would mean writing a feature rather than fixing a defect. The accurate fix is to scope the README claim to the tools that actually implement the fallback, and to say plainly on the tool's own section that it requires the package.

Also removed a dead exception handler in compute_fk:

try: panda = rtb.models.DH.Panda()
except: panda = rtb.models.DH.Panda()

The handler re-runs the exact call that just failed, so it cannot recover anything; the bare except additionally swallows KeyboardInterrupt and SystemExit. Replaced with the plain call.

Disclosure on how this was verified: I read the code rather than executing it — I had no environment to install the dependencies into, so there is no traceback attached. The conclusion rests on Python's import semantics for an unguarded top-level import and on the contrast with the sibling file's guarded import. If you would rather visualize_trajectory.py degrade gracefully instead of documenting the requirement, that is a different and larger change and I am happy to look at it separately.

Two files, +4/−4. visualize_trajectory.py still compiles.

@faisalnugroho

Copy link
Copy Markdown

Confirmed the claim in the PR body against the code: visualize_trajectory.py imports roboticstoolbox unconditionally at module top, so the README's "all tools still work without it" is indeed wrong for this script — the process crashes on import rather than falling back. The diff correctly (a) scopes the fallback claim to smooth_resampled_traj.py + metrics tools and (b) removes the try/except in compute_fk that caught and immediately re-called the same failing expression (except: panda = rtb.models.DH.Panda() was a no-op guard). LGTM from a code-accuracy standpoint; leaving merge decision to the maintainer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants