Skip to content

Conversation

@Nicogene
Copy link
Member

It fixes #141

@Nicogene Nicogene self-assigned this Jul 15, 2025
Copy link
Contributor

@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.

Summary of Changes

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!

This pull request introduces a new unit testing framework for creo2urdf generated models, specifically targeting URDF consistency and correctness. It aims to improve the quality and reliability of exported robot models by validating key kinematic and sensor properties, addressing issue #141.

Highlights

  • New Model Validation Test: A new C++ executable (creo2urdf-model-test) has been added to perform comprehensive validation of URDF models, checking aspects like joint axis directions, base link configuration, sole frame placement, and force/torque sensor properties.
  • CMake Integration for Testing: The build system has been updated to enable testing via CTest when the BUILD_TESTING option is enabled, and a new tests subdirectory has been introduced to house the test suite.
  • Detailed URDF Property Checks: The new test includes specific checks for various robot model characteristics, such as the expected directions of numerous joint axes (e.g., torso, hip, shoulder, finger joints), the identity transform of the base_link relative to root_link, the parallel and symmetric placement of l_sole and r_sole frames, and the correct orientation and coherence of force/torque sensors.
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.

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.

@Nicogene Nicogene marked this pull request as draft July 15, 2025 14:09
Copy link
Contributor

@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

This pull request introduces a unit test for creo2urdf, which is a valuable addition for ensuring model quality. The changes correctly set up the testing infrastructure with CMake and provide a comprehensive test suite for the URDF models.

My review focuses on improving the new test code. I've identified a few critical correctness issues due to copy-paste errors, as well as several opportunities to enhance maintainability, readability, and efficiency. Addressing these points will make the new test suite more robust and easier to extend in the future.

Comment on lines 144 to 147
if (rootLinkIdx == iDynTree::FRAME_INVALID_INDEX)
{
std::cerr << "ergocub-model-test error: impossible to find base_link in model" << std::endl;
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

There's a copy-paste error in this conditional. You're checking rootLinkIdx for validity, but the error message refers to base_link. You should be checking base_linkIdx.

Suggested change
if (rootLinkIdx == iDynTree::FRAME_INVALID_INDEX)
{
std::cerr << "ergocub-model-test error: impossible to find base_link in model" << std::endl;
return false;
if (base_linkIdx == iDynTree::FRAME_INVALID_INDEX)
{
std::cerr << "ergocub-model-test error: impossible to find base_link in model" << std::endl;
return false;
}

Comment on lines 179 to 182
if (rootLinkIdx == iDynTree::FRAME_INVALID_INDEX)
{
std::cerr << "ergocub-model-test error: impossible to find frame l_sole in model" << std::endl;
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

There's a copy-paste error in this conditional. You're checking rootLinkIdx for validity, but you probably meant to check l_sole.

Suggested change
if (rootLinkIdx == iDynTree::FRAME_INVALID_INDEX)
{
std::cerr << "ergocub-model-test error: impossible to find frame l_sole in model" << std::endl;
return false;
if (l_sole == iDynTree::FRAME_INVALID_INDEX)
{
std::cerr << "ergocub-model-test error: impossible to find frame l_sole in model" << std::endl;
return false;
}

Comment on lines 187 to 190
if (rootLinkIdx == iDynTree::FRAME_INVALID_INDEX)
{
std::cerr << "ergocub-model-test error: impossible to find frame r_sole in model" << std::endl;
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

Similar to the check for l_sole, there's a copy-paste error here. You're checking rootLinkIdx for validity, but you should be checking r_sole.

Suggested change
if (rootLinkIdx == iDynTree::FRAME_INVALID_INDEX)
{
std::cerr << "ergocub-model-test error: impossible to find frame r_sole in model" << std::endl;
return false;
if (r_sole == iDynTree::FRAME_INVALID_INDEX)
{
std::cerr << "ergocub-model-test error: impossible to find frame r_sole in model" << std::endl;
return false;
}

/**
* All the iCub have a odd and not null number of F/T sensors.
*/
bool checkFTSensorsAreOddAndNotNull(iDynTree::ModelLoader& mdlLoader)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This function checkFTSensorsAreOddAndNotNull appears to be unused. The main function calls checkFTSensorsAreEvenAndNotNull instead. If this function is not needed, it should be removed to reduce code clutter.

}


bool Model_isFrameNameUsed(const iDynTree::Model& model, const std::string frameName)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This function Model_isFrameNameUsed seems to be a reimplementation of iDynTree::Model::isFrameNameUsed and is not called anywhere in the file. It appears to be dead code and should be removed.




const std::string modelPath = __argc > 1 ? __argv[1] : "model.urdf";
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The use of __argc and __argv is a Microsoft-specific extension. For better portability, it's recommended to use the standard argc and argv which are passed as arguments to main.

Suggested change
const std::string modelPath = __argc > 1 ? __argv[1] : "model.urdf";
const std::string modelPath = argc > 1 ? argv[1] : "model.urdf";

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.

Ad unit test in the CI

2 participants