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

[Humble Backport] tf_prefix param: fix slashes and add to IMU Broadcaster #1102

Closed
wants to merge 9 commits into from

Conversation

rafal-gorecki
Copy link
Contributor

Hello,
I encountered one error related to the tf_prefix parameter. Namely, the current code works in such a way that the use of namespace does not remove the first slash. It's not typical for a tf frame to start with / so I fixed it. Additionally, I don't think it's intuitive to add a slesh every time we use tf_prefix, if only because someone might want to give a prefix that doesn't end with a slesh, although I could be wrong about that.

Additionally, I encountered one error with the option

    validation: {
      not_empty<>: null
    }

it doesn't work well with namespaces and I don't know how to fix it yet. However, I see that it is not used in all packages, so I commented it temporarily.

Copy link
Contributor

mergify bot commented Apr 20, 2024

@rafal-gorecki, all pull requests must be targeted towards the master development branch.
Once merged into master, it is possible to backport to humble, but it must be in master
to have these changes reflected into new distributions.

@christophfroehlich
Copy link
Contributor

Is this a possible duplicate of #1060?

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.

It seems to be a duplication of #1060, but I like the fact that you have added some tests to the cases. However, I'm not entirely convinced in some places. I've left some comments here to discuss.

else
{
tf_prefix = tf_prefix + "/";
tf_prefix.erase(0, 1);
Copy link
Member

Choose a reason for hiding this comment

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

Why do you always want to erase the first character? If the prefix is parsed without '/' then it removes the wrong character right?

I see that you did that when you are using node namespace, however, I think you need to correct the users tf_prefix as well, if he adds a '/' as well. Try to do same logic as done in #1060

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense

diff_drive_controller/test/test_diff_drive_controller.cpp Outdated Show resolved Hide resolved
Comment on lines 8 to 11
# FIXME: Currently does not work with namespace
# validation: {
# not_empty<>: null
# }
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain a bit more in what situation it doesn't work.

Copy link
Contributor Author

@rafal-gorecki rafal-gorecki Apr 22, 2024

Choose a reason for hiding this comment

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

Yes sure:

I don't know exactly what's going on. However, when this is checked it then gets an error:

    [ERROR] [1713772814.609746661] [test_namespace.test_imu_sensor_broadcaster]: Exception thrown during init stage with message: Invalid value set during initialization for parameter 'sensor_name': Parameter 'sensor_name' cannot be empty

The problem is probably that:

  1. Adding a namespace causes the frame_id parameter to be searched for, which is no longer there (because it is ~/frame_id)
  2. Something else with ControllerInterface

Copy link
Member

Choose a reason for hiding this comment

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

I think you have misinterpreted it. This information is need to get the proper state interfaces within the controller. Please look into the following code

imu_sensor_ = std::make_unique<semantic_components::IMUSensor>(
semantic_components::IMUSensor(params_.sensor_name));

Comment on lines 46 to 49
tf_frame_prefix_enable: {
type: bool,
default_value: true,
description: "Enables or disables appending tf_prefix to tf frame id's.",
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand the need for this new parameter. Can you explain me why it is needed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I followed the example of diff_drive. I think you can get rid of it.

sensor_msgs::msg::Imu imu_msg;
subscribe_and_get_message(imu_msg, test_namespace);

EXPECT_EQ(imu_msg.header.frame_id, frame_prefix + frame_id_);
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't there be a slash in between?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A matter for discussion, but in my opinion the prefix can be arbitrary and the user does not necessarily have to want it to end slash

Copy link
Member

Choose a reason for hiding this comment

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

ok if you want it to be prefixed without a '/' at the end, why don't you parse it directly already appending it to the frame_id? This frame_id is only used for the published message. I don't see a point of adding a tf_prefix, if it is not namespaced.

realtime_publisher_->msg_.header.frame_id = params_.frame_id;

What do you think about this?

@rafal-gorecki rafal-gorecki changed the base branch from humble to master April 22, 2024 07:41
@rafal-gorecki rafal-gorecki changed the base branch from master to humble April 22, 2024 07:41
@rafal-gorecki
Copy link
Contributor Author

rafal-gorecki commented Apr 22, 2024

Dear @saikishor ,
I would like to ask for verification, I hope I added all the suggestions and managed to fix the error with the parameters that occurred with the namepatch. Should I rebase this PR and target it to master?

@rafal-gorecki rafal-gorecki requested a review from saikishor April 22, 2024 09:54
@saikishor
Copy link
Member

Dear @saikishor , I would like to ask for verification, I hope I added all the suggestions and managed to fix the error with the parameters that occurred with the namepatch. Should I rebase this PR and target it to master?

Yes, please rebase and target it to the master :)

@rafal-gorecki
Copy link
Contributor Author

rafal-gorecki commented Apr 22, 2024

The easiest way for me to do it was this way, a continuation #1104

@rafal-gorecki rafal-gorecki reopened this Apr 26, 2024
@github-actions github-actions bot requested review from aprotyas and erickisos April 26, 2024 09:29
@github-actions github-actions bot requested a review from VX792 April 26, 2024 09:29
@rafal-gorecki rafal-gorecki changed the title tf_prefix param: fix slashes and add to IMU Broadcaster Backport to Humble tf_prefix param: fix slashes and add to IMU Broadcaster Apr 26, 2024
@rafal-gorecki rafal-gorecki changed the title Backport to Humble tf_prefix param: fix slashes and add to IMU Broadcaster [Humble Backport] tf_prefix param: fix slashes and add to IMU Broadcaster Apr 26, 2024
henrygerardmoore pushed a commit to henrygerardmoore/ros2_controllers that referenced this pull request Jul 19, 2024
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.

3 participants