-
Notifications
You must be signed in to change notification settings - Fork 404
Migrate urdf
modules to Typescript
#907
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate urdf
modules to Typescript
#907
Conversation
1567f32
to
e5824be
Compare
19b3e78
to
8d84634
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GitHub is being GitHub here and the commit where you used git mv
to ensure history continuity is not being represented in the PR diff. We might need to break that into its own PR (knowing it will probably break the build).
8d84634
to
7e1189c
Compare
Yeah, unfortunately it looks like if I squash-merge this it will lose the history :( |
Created at #910 |
…n generation for PR Signed-off-by: Drew Hoener <[email protected]>
…references. Signed-off-by: Drew Hoener <[email protected]>
Add enum of Urdf Attributes to remove magic strings when getting attributes from xml Signed-off-by: Drew Hoener <[email protected]>
Signed-off-by: Drew Hoener <[email protected]>
…ng warning. Signed-off-by: Drew Hoener <[email protected]>
…xtract origin parsing logic to UrdfUtils. Signed-off-by: Drew Hoener <[email protected]>
Signed-off-by: Drew Hoener <[email protected]>
Signed-off-by: Drew Hoener <[email protected]>
Signed-off-by: Drew Hoener <[email protected]>
…d isElement check in UrdfUtils Signed-off-by: Drew Hoener <[email protected]>
…since ES6 provides it Signed-off-by: Drew Hoener <[email protected]>
…ith for-of, and improve type safety Signed-off-by: Drew Hoener <[email protected]>
7e1189c
to
71a85c5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for putting the effort in to doing this incrementally so I can scan it more easily!
this.a = parseFloat(rgba[3]); | ||
const rgba: Optional<string[]> = xml.getAttribute(UrdfAttrs.Rgba)?.split(' '); | ||
if (!rgba || rgba.length !== 4) { | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactoring JS into TS always uncovers extremely odd control flow like this.. early return from a constructor, lol 🤦🏻
export enum UrdfAttrs { | ||
Name = 'name', | ||
Type = 'type', | ||
Parent = 'parent', | ||
Link = 'link', | ||
Child = 'child', | ||
Limit = 'limit', | ||
Upper = 'upper', | ||
Lower = 'lower', | ||
Origin = 'origin', | ||
Xyz = 'xyz', | ||
Rpy = 'rpy', | ||
Size = 'size', | ||
Rgba = 'rgba', | ||
Length = 'length', | ||
Radius = 'radius', | ||
Visuals = 'visual', | ||
Texture = 'texture', | ||
Filename = 'filename', | ||
Color = 'color', | ||
Geometry = 'geometry', | ||
Material = 'material', | ||
Scale = 'scale', | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This smells odd to me - I don't feel like we should need this enum to keep track of the magic strings (because each string would only be used once), but I understand you're just refactoring the code in-place here.
The URDF stuff could probably use a refactor soon. I've been using https://github.com/gkjohnson/urdf-loaders for years because I found the URDF implementation here roslibjs and in ros3djs too janky.
Not in the scope of this PR anyhow!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(also honestly maybe roslibjs and ros3djs should be merged into one package now that most of the world uses bundlers in their javascript apps and can tree-shake out unnecessary dependencies)
Yeah of course! Glad I finally have the time to get it done, I've been wanting to for a while. I feel like it's needed a bit of modernization. Thanks for being so responsive with my wave of PRs lol |
Yeah, I kept meaning to come back and do this refactor myself after I added Vite and tsc but never had time and at least in my application the JSDoc-generated types have been "fine" in the meantime |
Public API Changes
None
Description
Overview
This PR migrates the classes in the
urdf
module to Typescript. This PR is slightly more involved as there's a lot of interdependency between the URDF elements, but other than that it's still largely trivial.Contents
UrdfUtils.ts
Going to leave converting tests for another PR, but they all pass in my docker container
Depends on #906
GitHub doesn't have "dependent PRs" so all previous commits are included here. Might not be worth reviewing until dependencies are merged