Skip to content
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

URDFTools can take a Collection<InputStream> as the first parameters to allow for splitting the URDF up into multiple files #172

Merged
merged 24 commits into from
Apr 8, 2024

Conversation

PotatoPeeler3000
Copy link
Collaborator

Initial attempt at getting the URDF to be split up, it loads properly. There are errors all over the place still

@PotatoPeeler3000 PotatoPeeler3000 marked this pull request as draft March 12, 2024 19:19
@PotatoPeeler3000 PotatoPeeler3000 changed the title [WIP] URDFTools can take a Collection<InputStream> as the first parameters to allow for splitting the URDF up into multiple files URDFTools can take a Collection<InputStream> as the first parameters to allow for splitting the URDF up into multiple files Mar 22, 2024
@PotatoPeeler3000 PotatoPeeler3000 self-assigned this Mar 22, 2024
@PotatoPeeler3000 PotatoPeeler3000 added the enhancement New feature or request label Mar 22, 2024
Copy link
Collaborator Author

@PotatoPeeler3000 PotatoPeeler3000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gonna look into what should be done about the name, don't like that we ignore the rest of the names after getting the first one

@PotatoPeeler3000 PotatoPeeler3000 marked this pull request as ready for review March 22, 2024 15:56
@PotatoPeeler3000 PotatoPeeler3000 marked this pull request as draft March 25, 2024 20:39
if (!parserProperties.parseSensors)
urdfModel.getGazebos().removeIf(gazebo -> gazebo.getSensor() != null);
// If the model1 doesn't have any links that are in the model2, we define the model2 to be the parent
return mergeChildIntoParentModel(model2, model1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest inlining the mergeChildIntoParentModel method in here, as it now relies solving the parent-child relationship outside making it vulnerable to idiot bugs 😅
Above, I'd make 2 new local variables URDFModel parentModel and URDFModel childModel and resolve them, then after you should be able to inline the mergeChildIntoParentModel only once at the end of this method.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, that was able to happen, just had to set the parent or child model to the correct model and after that has been done, at the end collect all the joints from the parent and child.

PotatoPeeler3000 added 2 commits April 5, 2024 15:22
Copy link
Member

@SylvainBertrand SylvainBertrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main is keeping backward compatibility. The other comment about not instantiating the models is just subjective style.

}

URDFModel parentModel = new URDFModel();
URDFModel childModel = new URDFModel();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to instantiate new models, just needed more references, these could be initialized to null

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, yep true, should know that by now dang

@@ -209,66 +247,256 @@ public static URDFModel loadURDFModel(InputStream inputStream, Collection<String
* done.
* @return the model.
*/
public static URDFModel loadURDFModel(InputStream inputStream,
public static URDFModel loadURDFModel(Collection<InputStream> inputStreams,
Collection<String> resourceDirectories,
ClassLoader resourceClassLoader,
URDFParserProperties parserProperties) throws JAXBException
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add another factory for backward compatibility with the signature:
URDFModel loadURDFModel(InputStream inputStream, Collection<String> resourceDirectories, ClassLoader resourceClassLoader, URDFParserProperties parserProperties)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have this... lets see if I can link it....

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't link it but its on line 210

{
for (URDFJoint joint : model2.getJoints())
{
// Check if the model1 has any links that are referenced in model2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its possible for a link from Model1 to be contained inside either the parent or child joint in model2, depending on which it is, that makes it either the child or parent

{
for (URDFJoint joint : model1.getJoints())
{
// Check if the model2 has any links that are referenced in model1
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to check this for both models, if we get unlucky with the way the models are passed in and don't check both ways, the name may be wrong

if (!parserProperties.parseSensors)
urdfModel.getGazebos().removeIf(gazebo -> gazebo.getSensor() != null);
// If the model1 doesn't have any links that are in the model2, we define the model2 to be the parent
return mergeChildIntoParentModel(model2, model1);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, that was able to happen, just had to set the parent or child model to the correct model and after that has been done, at the end collect all the joints from the parent and child.

}

URDFModel parentModel = new URDFModel();
URDFModel childModel = new URDFModel();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, yep true, should know that by now dang

@@ -209,66 +247,256 @@ public static URDFModel loadURDFModel(InputStream inputStream, Collection<String
* done.
* @return the model.
*/
public static URDFModel loadURDFModel(InputStream inputStream,
public static URDFModel loadURDFModel(Collection<InputStream> inputStreams,
Collection<String> resourceDirectories,
ClassLoader resourceClassLoader,
URDFParserProperties parserProperties) throws JAXBException
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have this... lets see if I can link it....

* done.
* @return the model.
*/
public static URDFModel loadURDFModel(InputStream inputStream, Collection<String> resourceDirectories, ClassLoader resourceClassLoader, URDFParserProperties parserProperties) throws JAXBException
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what your looking for yes? @SylvainBertrand This is the factory you asked for, its just hidden in the mess haha

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah!

* done.
* @return the model.
*/
public static URDFModel loadURDFModel(InputStream inputStream, Collection<String> resourceDirectories, ClassLoader resourceClassLoader, URDFParserProperties parserProperties) throws JAXBException
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah!

@PotatoPeeler3000 PotatoPeeler3000 merged commit 61516ec into develop Apr 8, 2024
3 checks passed
@PotatoPeeler3000 PotatoPeeler3000 deleted the feature/combined-urdf branch April 8, 2024 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants