NVlabs / NVlabs/ASPIRE

Duplicate get_oriented_bounding_box_from_3d_points in FrankaLiberoApi masks an undefined _get_obb

Open Beginner friendly
#19 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
191
Forks
12
Avg merge
3d 18h
Merged PRs (30d)
1

Description

Summary

FrankaLiberoApi defines get_oriented_bounding_box_from_3d_points twice. The first definition calls _get_obb, a name that is never imported into that module, so it would raise NameError if it were ever the live one. It is currently harmless only because a second definition later in the same class body overwrites it. Any reordering, or a cleanup that removes the second definition, turns this into a runtime error.

Where

cap/integrations/franka/libero.py

  • line 202 — first def get_oriented_bounding_box_from_3d_points(...)
  • line 219 — its body: return _get_obb(points)
  • line 459 — second def get_oriented_bounding_box_from_3d_points(...), a full open3d implementation

libero.py imports nothing from cap/integrations/franka/common.py. The two sibling modules that use the same delegation idiom do import it:

  • cap/integrations/franka/libero_reduced.py:28get_oriented_bounding_box_from_3d_points as _get_obb
  • cap/integrations/franka/control_reduced.py:27 — same

So line 202 reads as a copy of the sibling method without its accompanying import.

Reproduce

import inspect
from aspire.sim.cap.integrations.franka import libero as m

print(inspect.getsourcelines(m.FrankaLiberoApi.get_oriented_bounding_box_from_3d_points)[1])
print(hasattr(m, "_get_obb"))
print(inspect.getsource(m.FrankaLiberoApi).count("def get_oriented_bounding_box_from_3d_points"))
459
False
2

ruff check cap also flags both halves: F821 undefined name _get_obb at line 219, and F811 redefinition at line 459.

Suggested fix, and one trap in it

Deleting the dead line 202-219 method is the safe fix.

The tempting alternative — add the missing import and drop the second definition — changes behaviour. The two implementations are not equivalent: the in-class version at line 459 returns a quaternion_wxyz key that common.py::get_oriented_bounding_box_from_3d_points does not:

# libero.py:482
return {"center": obb.center, "extent": obb.extent, "R": obb.R,
        "quaternion_wxyz": vtf.SO3.from_matrix(obb.R).wxyz}

# common.py:340
return {"center": obb.center, "extent": obb.extent, "R": obb.R}

Since this method is part of the API surface injected into generated code, dropping that key would silently break any generated program that reads obb["quaternion_wxyz"]. Nothing in cap/ or .claude/ consumes it today, but the docstrings on both definitions document only center / extent / R, so the key is undocumented either way and worth reconciling.

Environment

Fresh clone at f4c8939, .venv-libero (Python 3.12).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in cap/integrations/franka/libero.py by inspecting both get_oriented_bounding_box_from_3d_points definitions and compare the live implementation with the sibling modules. Run ruff check cap and the supplied inspect snippet; done means the duplicate and undefined-name findings are gone while the live method still exposes quaternion_wxyz.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, robotics
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.