ami-iit / rod

The ultimate Python tool for RObot Descriptions processing.
https://pypi.org/project/rod/
BSD 3-Clause "New" or "Revised" License
13 stars 3 forks source link

Improve model handling speed #31

Closed flferretti closed 1 month ago

flferretti commented 2 months ago

This pull request includes several code improvements and bug fixes. Here is a summary of the changes:

Benchmarks:

%timeit _ = rod.Sdf.load(sdf=urdf_path, is_urdf=True)
< 683 ms ± 24.4 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
> 434 ms ± 11.9 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
%timeit sdf.model.switch_frame_convention(frame_convention=rod.FrameConvention.Urdf)
< 511 ms ± 8.95 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
> 44 ms ± 178 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
%timeit _ = UrdfExporter.sdf_to_urdf_string(
    sdf=sdf, pretty=True, gazebo_preserve_fixed_joints=True
)
< 549 ms ± 5.71 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
> 73.1 ms ± 432 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)

C.C. @diegoferigo

diegoferigo commented 1 month ago

@flferretti there are many conflicts after #34 and #35. Do you want to port the changes over the future main? Otherwise I can take care of it since I was the one that introduced all the conflicts.

flferretti commented 1 month ago

@flferretti there are many conflicts after #34 and #35. Do you want to port the changes over the future main? Otherwise I can take care of it since I was the one that introduced all the conflicts.

I can handle that, thank you!

flferretti commented 1 month ago

Ready for review @diegoferigo, I also fixed a minor typo here https://github.com/ami-iit/rod/blob/11d276868a6720439d8ce9db9d64f209500a1b79/src/rod/utils/frame_convention.py#L297