Repository navigation
refactor: ♻️ Use the shared rot_mat_22 helper for 2D rotations - #156
Conversation
Replace the hand-written rotation matrices in XYArray.homogeneous_transformation() and InformedRrtStarPathPlanner.sample_informed() with rot_mat_22, add the translation in XYArray with plain broadcasting, and add a docstring to rot_mat_22. Behavior is unchanged. Closes ShisatoYano#125
|
Thanks a lot for picking this up, @Tektrix, and for posting the plan on the issue first! The diff is small and easy to review: A couple of requests before merging:
Thanks again! |
…etector Replace the remaining hand-written rotation matrices pointed out in review: BinaryOccupancyGrid.add_object() now uses rot_mat_22(yaw), and LShapeFittingDetector._rotate_points() uses rot_mat_22(angle_rad).T, the inverse rotation it built by hand. Behavior is unchanged.
|
Thanks for the review and for checking it so thoroughly! I've replaced the rotation in |
|
Thanks for the update, @Tektrix! Both points are addressed, and the comment on One last thing: #160 was just merged and touched the same import lines in After that, I'll approve the CI run and merge. Thanks! |
|
Hi @Tektrix, just a friendly ping on this one. The code itself is ready to go: I re-ran the full suite on top of the latest The only thing left is the conflict in sys.path.append(abs_dir_path + relative_path + "mapping/grid")
sys.path.append(abs_dir_path + relative_path + "common")
from save_gif import is_save_gif_enabled
from matrix_lib import rot_mat_22Thanks! 🤖 Generated with Claude Code |
…otation-helper # Conflicts: # src/components/plan/informed_rrt_star/informed_rrt_star_path_planner.py
|
Merged the latest |
|
Thanks @Tektrix! The conflict is resolved exactly as suggested: I checked the new head (448f4fb) locally:
Nothing else is needed from your side. Thanks again for the cleanup! 🤖 Generated with Claude Code |
Closes #125.
Overview
XYArray.homogeneous_transformation()now usesrot_mat_22instead of a hand-written rotation matrix, and adds the translation with plain broadcasting (+ np.array([[x], [y]])) instead ofnp.ones(shape) * [[x], [y]].InformedRrtStarPathPlanner.sample_informed()now usesrot_mat_22(theta)for its rotation matrix.BinaryOccupancyGrid.add_object()now usesrot_mat_22(yaw).LShapeFittingDetector._rotate_points()now usesrot_mat_22(angle_rad).T, since it rotates by-angle_rad.rot_mat_22gets a docstring in the same style ashom_mat_33.All files load
matrix_libwith the samesys.path.append(...)pattern the existing code uses. The remaining-sinmatches insrc/componentsare not rotation matrices: the lateral error incubic_spline_course.py, the line coefficients passed toRectangle, and thedyterms inrobust_least_squares_detector.py. Behavior is unchanged.How I confirmed it works
rot_mat_22builds the same matrix as the code it replaces (and its transpose is the inverse rotation_rotate_points()built by hand), and broadcasting a 2x1 column gives the same result as multiplying it withnp.onesfirst.test_xy_array.py(includingtest_homogeneous_transformation),test_matrix_lib.py,test_informed_rrt_star_path_planning.py, the path planning smoke tests that build aBinaryOccupancyGrid, andtest_point_cloud_rectangle_fitting.py/test_point_cloud_robustLS_rectangle_fitting.py, which run in GitHub Actions on this PR.