Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

ETS/ETS2: one joint-index resolver; the all-or-none, unique guarantee breaks under concatenation and insert

Đang mở
#803 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
10/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
robotics

Hướng nghiên cứu

Start with the duplicated joint-index logic in ETS.__init__, ETS2.__init__ and ETS2.jacob, then BaseRobot.__init__ and Gripper.__init__. Reproduce the concatenation case from the issue (ETS([ET.Rz()]) * ETS([ET.Rx()]) giving duplicate jindex values) and check the insert path. Done means one shared resolver that enforces all-or-none, unique and contiguous indices, with the proposed regression tests passing. The design choices (lazy versus eager resolution, read-only ET.jindex) need maintainer agreement first.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

tech-debt

Summary

The rule "an ETS has either all or none of its joint indices set, and they are unique and contiguous" is implemented four times and enforced in only one place, the constructor. Incremental construction and later mutation can break it.

Found while reviewing #792, which fixed one symptom (np.all([...jindex]) treats index 0 as missing, so a permuted or sparse mapping was silently overwritten with 0..n-1).

Where the logic lives today

Place What it does
ETS.__init__ counts joints with a jindex; all-but-last sequential auto-fills the last, mixture raises ValueError, none assigns 0..n-1
ETS2.__init__ the same ~25 lines, copy-pasted
ETS2.jacob re-checks "all set?" and renumbers (the check #792 fixes)
BaseRobot.__init__ re-derives none/all across the links, via _auto_jindex, then assigns in DFS order
Gripper.__init__ the same again with a slightly different filter

The guarantee does not hold under incremental construction

On main:

a, b = ET.Rz(), ET.Rx()
e = ETS([a]) * ETS([b])       # each piece was auto-assigned jindex 0
[j.jindex for j in e.joints()]   # -> [0, 0], n = 2: all set, but not unique
  • Concatenating two auto-indexed ETS gives duplicate indices with no error, because the constructor only checks "all or none", not unique and contiguous.
  • ETS.insert appends to _data with no re-check at all and does not reset _auto_jindex.
  • ET.jindex has a public setter, so indices can be changed after construction, outside the owning ETS (Link.jindex, BaseRobot, Gripper, DHRobot and ETS2.jacob all do).

Proposal

  1. One helper (a function, or a method on the common base BaseETS) that takes the joints and does the whole job: all-or-none check, uniqueness and contiguity, auto-fill, and returns whether the indices were auto-assigned. ETS and ETS2 constructors call it.
  2. Re-run it from every mutator (insert, append, __setitem__, __imul__) or resolve it lazily on first use, since jindices is already a cached property.
  3. Make ET.jindex read-only once the ET belongs to an ETS (the ET is already deep-copied into the ETS, so ownership is clear). Mutation then goes through one sanctioned ETS method that keeps the _auto_jindex flag and the cached jindices consistent. Link.jindex, BaseRobot, Gripper and DHRobot use that method.
  4. BaseRobot and Gripper share a small classifier (none / all / mixed) instead of each re-writing all([... is None ...]), and their DFS assignment becomes one base-class method.
  5. The unreachable renumbering block in ETS2.jacob is deleted.

Regression tests: concatenation of two auto-indexed ETS, insert of a joint, permuted explicit indices surviving jacob, and a mixture still raising.

Fits the ets group of the typing pass (problems 61 to 65).

Related

  • #792 (the symptom fix, independent of this)
Ngôn ngữ chính
C++
Star
3.5k
Fork
639
Merge trung bình
1 ngày 14 giờ
Pull request đã merge (30 ngày)
96

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của petercorke/robotics-toolbox-python

Tất cả issue của petercorke/robotics-toolbox-python

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.