trlog2 loses the quadrant for valid SO(2) and SE(2) rotations
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 72/100
Hướng nghiên cứu
Lỗi nằm ở trlog2 trong spatialmath/base/transforms2d.py, nơi cả hai nhánh đều lấy góc bằng atan(sin/cos) và làm mất góc phần tư. Hãy bắt đầu từ đó và kiểm tra xem atan2 áp dụng cho cùng các phần tử sin và cos có sửa được trường hợp 120° và 180° hay không. Chạy đoạn mã tái hiện trong issue, so sánh trlog2, SO2.log, SE2.log và Twist2(SE2).exp với logarit chính xác. Hoàn thành khi cả năm phép khứ hồi đều đạt ở 120° và 180°, và kiểm tra đối chứng 30° vẫn đạt.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
trlog2 returns logarithms that don't exponentiate to valid 120° and 180° inputs. SO2.log(), SE2.log() and Twist2(SE2(...)).exp() inherit this.
Version: spatialmath-python 1.1.18, 2de780137049040a665225b59d65d95ec93a9e13, Python 3.12.3, SymPy 1.14.0, mpmath 1.3.0, Linux x86_64, NumPy 1.26.4 / SciPy 1.15.3 and NumPy 2.5.4 / SciPy 1.18.1.
In an empty directory, use Python 3.12 and Bash:
git clone https://github.com/rai-opensource/spatialmath-python.git spatialmath-python
git -C spatialmath-python checkout --detach 2de780137049040a665225b59d65d95ec93a9e13
python3.12 -m venv .venv
.venv/bin/python -m pip install -e ./spatialmath-python numpy==1.26.4 scipy==1.15.3 sympy==1.14.0 mpmath==1.3.0
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 .venv/bin/python - <<'PY'
"""Exact SO(2)/SE(2) log references, including a common 120-degree pose."""
import numpy as np
import sympy as sp
from scipy.linalg import expm
from spatialmath import SO2, SE2, Twist2
from spatialmath.base import trlog2
def numeric(m):
return np.array(sp.Matrix(m).evalf(60).tolist(), dtype=float)
failures = []
for degrees in (30, 120, 180):
theta = sp.pi * degrees / 180
c, s = sp.cos(theta), sp.sin(theta)
R = sp.Matrix([[c, -s], [s, c]])
T = sp.eye(3)
T[:2, :2], T[:2, 2] = R, sp.Matrix([1, 2])
# exp([v,theta]) translates by V(theta)*v.
V = sp.Matrix([[s, -(1-c)], [1-c, s]]) / theta
v = V.inv() * sp.Matrix([1, 2])
logR = sp.Matrix([[0, -theta], [theta, 0]])
logT = sp.Matrix([[0, -theta, v[0]], [theta, 0, v[1]], [0, 0, 0]])
np.testing.assert_allclose(expm(numeric(logT)), numeric(T), atol=1e-14)
for name, actual, expected in (
('trlog2(SO2)', trlog2(numeric(R)), numeric(logR)),
('SO2.log', SO2(numeric(R)).log(), numeric(logR)),
('trlog2(SE2)', trlog2(numeric(T)), numeric(logT)),
('SE2.log', SE2(numeric(T)).log(), numeric(logT)),
('Twist2(SE2).exp', Twist2(SE2(numeric(T))).exp().A, numeric(T)),
):
error = np.max(np.abs(actual - expected))
print(f'{degrees:3d} deg {name:17s} max error {error:.12g}')
# Any real logarithm branch is acceptable if its exponential is the
# specified input. This also accepts either sign at the half-turn.
target = numeric(R) if name in ('trlog2(SO2)', 'SO2.log') else numeric(T)
recovered = actual if name == 'Twist2(SE2).exp' else expm(actual)
if not np.allclose(recovered, target, atol=1e-12, rtol=0):
failures.append((degrees, name))
print('log rotation =', trlog2(numeric(R), twist=True))
assert not failures, f'Confirmed deviations: {failures}'
PY
The trlog2 contract defines SO(2)/SE(2) matrix logarithms, so exp(log(T)) should recover T. Inputs meet documented forms with default checks enabled and no documented angle bound.
At 120°, trlog2(R, twist=True) returns -pi/3 instead of 2*pi/3, and at 180°, zero. Both angles fail all five round trips. The 30° control passes.
Both branches lose the quadrant through atan(sin/cos). atan2 with the same sine and cosine entries would preserve it.
We tested singleton matrices at 30°, ±120° and 180°, without sequences or robot workflows.
The reproducer is provided under CC0-1.0. Happy to send a PR.
— ChipLab
- Ngôn ngữ chính
- Python
- Star
- 648
- Fork
- 108
- Merge trung bình
- 9 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 9
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của rai-opensource/spatialmath-python
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
rai-opensource/spatialmath-python#235 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
rai-opensource/spatialmath-python#32 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
rai-opensource/spatialmath-python#268 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
expand_dims(None) raises TypeError although None is its documented defaultCó thể đã có người làm @Doribelove đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 52/100
rai-opensource/spatialmath-python#261 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
rai-opensource/spatialmath-python#257 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của rai-opensource/spatialmath-python
Issue tương tự
-
comp/tools P2 type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
NousResearch/hermes-agent#142908 · 1 bình luận ·
-
[oblt-aw][autodoc] Fix malformed headings in new Buildkite docs pagesCó thể đã có người làm @github-actions đã nhận hôm nay. Đang mởdocumentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: fileUploadMatrix.test.ts URL case does a real DNS lookup and fails offlineCó thể đã có người làm @r2jaff đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
ComposioHQ/composio#5054 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
pytorch/tensordict#3286 ·
Maintainer thường phản hồi trong vòng 1 ngày