Skip to content

Conversation

@kuralme
Copy link

@kuralme kuralme commented Nov 11, 2025

Added the tf prefix helper here instead of control_toolbox. Prefix enabler flag re-added and frame removed from input arguments.
Related PR

Comment on lines 108 to 111
if (!tf_prefix_enabled)
{
return std::string{};
}
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to have this arg here? Can't we condition it outside whoever is using this code?

Copy link
Member

Choose a reason for hiding this comment

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

IMHO, the helper methods shouldn't condition things, they do some standard operation and the users adapt to their usecases

Copy link
Contributor

Choose a reason for hiding this comment

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

this refers to my comment here: ros-controls/ros2_controllers#1997 (comment)
The current state feels a bit unconvenient. If !tf_prefix_enabled then it is just the given odom frame without adding something. How would you design this?

Copy link
Member

Choose a reason for hiding this comment

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

How about something like this

If the tf_prefix is empty, then return empty
If the tf_prefix is ~, then then the node namespace
If the tr_pedix is anything else, then return that

Obviously, trimming the /'s

What do you think about it?

Copy link
Author

@kuralme kuralme Nov 11, 2025

Choose a reason for hiding this comment

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

IMO, the previous version -helper without the prefix enable arg- was causing clutter when called with the ternary operator. It was still a one liner but looked more complicated then it is. I can remove it again regardless so it can comply the standard:

the helper methods shouldn't condition things

The decision is yours.

If the tf_prefix is empty, then return empty
If the tf_prefix is ~, then then the node namespace
If the tr_pedix is anything else, then return that

Not clear about this second one, do you mean i take node namespace if the user inputs the tilde character specifically or is it a result of some operation I am not aware?

Copy link
Member

@saikishor saikishor Nov 11, 2025

Choose a reason for hiding this comment

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

Yes, if the user inputs tilde, you replace that part with node namespace. Wouldn't that work?. This way you wouldn't need the parameter of tf_prefix_enable or not right?

For the conditioning part, the part you say complicated. I need to check that part of the code and get back to you.

Copy link
Author

@kuralme kuralme Nov 11, 2025

Choose a reason for hiding this comment

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

Previous one I tested here

Thanks for the reference. My question is do we really need tf_frame_prefix_enable parameter? If so, why?

Copy link
Author

@kuralme kuralme Nov 12, 2025

Choose a reason for hiding this comment

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

I am simply using it because we have it. But it makes sense to ignore it regardless and apply this

If the tf_prefix is empty, then return empty
If the tf_prefix is ~, then then the node namespace
If the tr_pedix is anything else, then return that

If the user does input a prefix name, an extra enable flag seems redundant imo.
How shall i proceed?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, the extra parameter flag seems to be superfluous.

@christophfroehlich christophfroehlich changed the title helper and test added Add tf prefix helper and test Nov 11, 2025
Copy link
Contributor

@christophfroehlich christophfroehlich left a comment

Choose a reason for hiding this comment

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

Thanks. Could you please update the diff_drive PR, so that we see the final usage?

{
if (prefix.empty())
{
return std::string{};
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return std::string{};
return "";

Won't this work?. Just a curious question

Copy link
Author

Choose a reason for hiding this comment

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

Its the same result but thats string literal and my return type is std::string so its an extra implicit conversion done by compiler. I can change anyway if you think looks simpler

Copy link
Member

Choose a reason for hiding this comment

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

please do, let the compiler to the job for us and we keep it more readable

return std::string{};
}

std::string nprefix = prefix == "~" ? node_ns : prefix;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
std::string nprefix = prefix == "~" ? node_ns : prefix;
std::string nprefix = prefix;
size_t pos = nprefix.find("~");
if (pos != std::string::npos) {
original.replace(pos, 1, node_ns);
}

Will something like this work?

Just thinking of cases, if users wants to add a prefix like ~/robot_base or something like that

Copy link
Member

Choose a reason for hiding this comment

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

We can also get back to this in future, if needed.

Just nitpicks.

Copy link
Author

@kuralme kuralme Nov 13, 2025

Choose a reason for hiding this comment

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

Makes sense, I'll add this.
Edit: just realized you have suggested it for future reference but I went ahead and added it. And tested it with diff drive controller. I can revert back to previous one if you prefer

@codecov
Copy link

codecov bot commented Nov 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.63%. Comparing base (23337e5) to head (09d868c).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2803      +/-   ##
==========================================
- Coverage   89.64%   89.63%   -0.02%     
==========================================
  Files         152      155       +3     
  Lines       17815    17834      +19     
  Branches     1455     1459       +4     
==========================================
+ Hits        15971    15985      +14     
- Misses       1260     1263       +3     
- Partials      584      586       +2     
Flag Coverage Δ
unittests 89.63% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...terface/include/controller_interface/tf_prefix.hpp 100.00% <100.00%> (ø)
...oller_interface/test/test_controller_tf_prefix.cpp 100.00% <100.00%> (ø)
...oller_interface/test/test_controller_tf_prefix.hpp 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

saikishor
saikishor previously approved these changes Nov 13, 2025
Copy link
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.

Approving as it serves the purpose.
Adding some nitpicks for future reference

@kuralme kuralme dismissed stale reviews from saikishor and christophfroehlich via cbd3730 November 13, 2025 15:07
interface_type_list.end();
}

/**
Copy link
Member

Choose a reason for hiding this comment

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

I know it's extreme nitpick but could this be moved to a new file instead please?
I wanted to rename this file already to be something like hardware_interface_helpers or similar

Copy link
Contributor

Choose a reason for hiding this comment

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

why is this helper related to hardware interface? don't we have a different helper file there already?

Copy link
Member

Choose a reason for hiding this comment

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

see that's why I haven't renamed it yet, because I couldn't come up with a better name :D

the initial point stands: could this function please go to a new file called tf_prefix.hpp please?

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.

4 participants