Skip to content

fix: correct ASSERT_EQ to ASSERT_NE in admittance controller load test#2264

Merged
christophfroehlich merged 5 commits into
ros-controls:masterfrom
SouriRishik:fix/admittance-controller-load-test
May 1, 2026
Merged

fix: correct ASSERT_EQ to ASSERT_NE in admittance controller load test#2264
christophfroehlich merged 5 commits into
ros-controls:masterfrom
SouriRishik:fix/admittance-controller-load-test

Conversation

@SouriRishik
Copy link
Copy Markdown
Contributor

@SouriRishik SouriRishik commented Mar 30, 2026

Fixes #1258

Problem

The test_load_controller test in admittance_controller was using ASSERT_EQ to check against nullptr, which means the test was asserting that the controller fails to load. Since the controller loads successfully with the params file provided, the test was always passing, even though it was checking the wrong condition.

Fix

Changed ASSERT_EQ to ASSERT_NE so the test correctly asserts that the controller loaded successfully (i.e. the result is not nullptr).

Note: range_sensor_broadcaster already has the correct ASSERT_NE in its load test and does not need changes.

Is this user-facing behavior change?

no

Did you use Generative AI?

no

@thedevmystic
Copy link
Copy Markdown
Contributor

Looks good, but if previous ASSERT_EQ() was passing so now this ASSERT_NE() would certainly fail, won't it?

@SouriRishik
Copy link
Copy Markdown
Contributor Author

Looks good, but if previous ASSERT_EQ() was passing so now this ASSERT_NE() would certainly fail, won't it?

Good question. The previous ASSERT_EQ(..., nullptr) was the bug because it was asserting that the controller fails to load, which is the wrong condition. Since the controller does load successfully with the params file provided, the result is a valid pointer and not nullptr. ASSERT_NE(..., nullptr) correctly verifies that the controller loaded successfully. The CI will confirm this.

Copy link
Copy Markdown
Member

@saikishor saikishor left a comment

Choose a reason for hiding this comment

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

That's weird. How come the tests were passing till now? 🤔

@thedevmystic
Copy link
Copy Markdown
Contributor

thedevmystic commented Mar 31, 2026

That's weird. How come the tests were passing till now?

I think the controller must be failing to load (returning nullptr). It's the only way to pass this. That means the there is also a bug.

@SouriRishik
Copy link
Copy Markdown
Contributor Author

If the previous ASSERT_EQ(..., nullptr) was passing, that suggests load_controller() might actually be returning nullptr, meaning the controller isn't loading successfully.

I'll verify the actual return value and investigate whether this is due to a configuration/plugin issue or something in the test setup itself, rather than just the assertion.

I'll update the PR once I confirm the behavior.

@SouriRishik SouriRishik requested a review from saikishor March 31, 2026 16:38
@SouriRishik
Copy link
Copy Markdown
Contributor Author

Verified that load_controller() returns nullptr, so the controller is not loading in this setup.

Reverted the assertion and added an invalid controller test to ensure failure cases are properly covered.

@thedevmystic
Copy link
Copy Markdown
Contributor

thedevmystic commented Mar 31, 2026

The ASSERT_NE() in first test is correct as per of logic. So, reverting is not right as it is a bug.

@SouriRishik
Copy link
Copy Markdown
Contributor Author

okay I'll change that again but what exactly do i follow up, I added additional test function for an invalid controller configuration to explicitly verify failure cases, so both success and failure paths are covered. What do you think of that?

@thedevmystic
Copy link
Copy Markdown
Contributor

thedevmystic commented Mar 31, 2026

From what I see, we have a bug somewhere. Since ASSERT_EQ(cm.load_controller("load_admittance_controller"), nullptr); was passing, ASSERT_NE() will fail. But the catch is ASSERT_NE() is logically correct.

Let's see what maintainers has to say :)

Comment thread admittance_controller/test/test_load_admittance_controller.cpp Outdated
Comment thread admittance_controller/test/test_load_admittance_controller.cpp
Comment thread admittance_controller/test/test_load_admittance_controller.cpp Outdated
@SouriRishik SouriRishik force-pushed the fix/admittance-controller-load-test branch from 46c6bb5 to c36ae15 Compare April 16, 2026 08:05
@SouriRishik SouriRishik force-pushed the fix/admittance-controller-load-test branch from c36ae15 to 8fd5432 Compare April 16, 2026 08:07
Copy link
Copy Markdown
Contributor

@kamal2730 kamal2730 left a comment

Choose a reason for hiding this comment

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

Add missing parameters and test locally by running:

colcon test --packages-select admittance_controller --event-handlers console_direct+

Comment thread admittance_controller/test/test_params.yaml
@SouriRishik
Copy link
Copy Markdown
Contributor Author

Hello @christophfroehlich, I have made the required changes. Could you please review?

Copy link
Copy Markdown
Contributor

@kamal2730 kamal2730 left a comment

Choose a reason for hiding this comment

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

LGTM!

@christophfroehlich christophfroehlich added backport-jazzy Triggers PR backport to ROS 2 jazzy. backport-kilted Triggers PR backport to ROS 2 kilted. labels May 1, 2026
@christophfroehlich christophfroehlich merged commit b822e35 into ros-controls:master May 1, 2026
14 of 18 checks passed
@christophfroehlich christophfroehlich added the backport-humble Triggers PR backport to ROS 2 humble. label May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-humble Triggers PR backport to ROS 2 humble. backport-jazzy Triggers PR backport to ROS 2 jazzy. backport-kilted Triggers PR backport to ROS 2 kilted.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_load_controller tests always succeed Fix admittance_controller load test

5 participants