Skip to content

Manage links and joints via ID #123

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

Nicogene
Copy link
Member

@Nicogene Nicogene commented Apr 3, 2025

It fixes #104

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Hello @Nicogene, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request addresses issue #104 and focuses on managing links and joints using their IDs within the Creo2Urdf converter. The core change involves modifying the populateExportedFrameInfoMap and addMeshAndExport functions to accept a LinkInfo object instead of a pfcModel_ptr and a separate mesh transform string. This allows these functions to access all necessary information about a link (name, handle, transforms) through a single object, improving code organization and readability.

Highlights

  • Refactoring: The populateExportedFrameInfoMap and addMeshAndExport functions are refactored to accept a LinkInfo object instead of separate arguments.
  • Data Encapsulation: The LinkInfo struct is used to encapsulate all relevant information about a link, simplifying function signatures and improving code clarity.
  • Mesh Export: The mesh export functionality is updated to use the LinkInfo object to access the model handle and transform information.

Changelog

  • src/creo2urdf/include/creo2urdf/Creo2Urdf.h
    • Modified populateExportedFrameInfoMap to accept LinkInfo& instead of pfcModel_ptr.
    • Modified addMeshAndExport to accept LinkInfo& instead of pfcModel_ptr and const std::string& mesh_transform.
  • src/creo2urdf/src/Creo2Urdf.cpp
    • Removed commented-out debug print statement.
    • Modified processAsmItems to pass LinkInfo to populateExportedFrameInfoMap and addMeshAndExport.
    • Modified populateExportedFrameInfoMap to use LinkInfo to access link name and model handle.
    • Modified addMeshAndExport to use LinkInfo to access model handle and link frame name for mesh export.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


With IDs clear, links align,
Joints managed, a structure fine.
Code's design,
A clearer sign,
Of robots moving, truly divine.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request addresses issue #104 by managing links and joints via ID. The changes involve modifying the Creo2Urdf class to use LinkInfo objects instead of pfcModel_ptr for managing link information. This approach seems reasonable and should improve code clarity and maintainability. However, there are a few areas that could be improved, as detailed below.

Summary of Findings

  • Redundant link_info_map lookup: In populateExportedFrameInfoMap, the link_info is already available as an argument, but the code still performs a lookup in link_info_map. This is redundant and can be simplified.
  • Inconsistent parameter passing: The addMeshAndExport function was modified to accept LinkInfo instead of pfcModel_ptr and mesh_transform. However, the mesh_transform parameter was replaced with link_info.link_frame_name, which might not be the intended behavior if mesh_transform was meant to represent a different transform.

Merge Readiness

The pull request introduces significant changes that require careful review. While the overall approach seems sound, the identified issues should be addressed before merging. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging. Specifically, the redundant link_info_map lookup and the potentially incorrect parameter passing in addMeshAndExport should be investigated and corrected. It is recommended that this pull request not be merged until these issues are addressed.

Comment on lines 717 to 720
link_info.modelhdl->Export(mesh_file_name.c_str(), pfcExportInstructions::cast(pfcSTLBinaryExportInstructions().Create(link_info.link_frame_name.c_str())));
}
else if(meshFormat =="stl_ascii") {
component_handle->Export(mesh_file_name.c_str(), pfcExportInstructions::cast(pfcSTLASCIIExportInstructions().Create(mesh_transform.c_str())));
link_info.modelhdl->Export(mesh_file_name.c_str(), pfcExportInstructions::cast(pfcSTLASCIIExportInstructions().Create(link_info.link_frame_name.c_str())));

Choose a reason for hiding this comment

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

high

The original code used mesh_transform.c_str() here. Now it's using link_info.link_frame_name.c_str(). Are you sure this is the correct transform to pass? It seems like mesh_transform might have been intended to be different from link_info.link_frame_name. Please confirm that this change is intentional and correct.

Suggested change
link_info.modelhdl->Export(mesh_file_name.c_str(), pfcExportInstructions::cast(pfcSTLBinaryExportInstructions().Create(link_info.link_frame_name.c_str())));
}
else if(meshFormat =="stl_ascii") {
component_handle->Export(mesh_file_name.c_str(), pfcExportInstructions::cast(pfcSTLASCIIExportInstructions().Create(mesh_transform.c_str())));
link_info.modelhdl->Export(mesh_file_name.c_str(), pfcExportInstructions::cast(pfcSTLASCIIExportInstructions().Create(link_info.link_frame_name.c_str())));
link_info.modelhdl->Export(mesh_file_name.c_str(), pfcExportInstructions::cast(pfcSTLBinaryExportInstructions().Create(mesh_transform.c_str())));
}
else if(meshFormat =="stl_ascii") {
link_info.modelhdl->Export(mesh_file_name.c_str(), pfcExportInstructions::cast(pfcSTLASCIIExportInstructions().Create(mesh_transform.c_str())));

Copy link
Member Author

Choose a reason for hiding this comment

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

The name was misleading, it is actually a frame name

Comment on lines 573 to 575
bool ret{ false };
iDynTree::Transform csys_H_additionalFrame {iDynTree::Transform::Identity()};
iDynTree::Transform csys_H_linkFrame {iDynTree::Transform::Identity()};

Choose a reason for hiding this comment

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

medium

The link_info is already passed as an argument to this function. Accessing it again via link_info_map.at(link_name) is redundant and less efficient. Consider removing this line and using the passed-in link_info directly.

Suggested change
bool ret{ false };
iDynTree::Transform csys_H_additionalFrame {iDynTree::Transform::Identity()};
iDynTree::Transform csys_H_linkFrame {iDynTree::Transform::Identity()};
auto& exported_frame_info = exported_frame_info_map.at(csys_name);
bool ret{ false };

Copy link
Member Author

Choose a reason for hiding this comment

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

Isn't what I am doing?

@Nicogene Nicogene force-pushed the feat/allowlinksamename branch from 22bbc41 to 1d97696 Compare April 8, 2025 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add the possibility to handle assemblies that have parts with the same name
1 participant