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

Refactored output parameter. #75

Conversation

lewie-donckers
Copy link
Contributor

Refactored the output parameter of Controller::findPositionOnPlan() to return value.

See:

Please note the following in Controller::update() where this function is used:

@@ -452,24 +451,29 @@ geometry_msgs::Twist Controller::update(
current_tf.rotation.x, current_tf.rotation.y, current_tf.rotation.z, current_tf.rotation.w);
current_with_carrot_.setRotation(cur_rot);

size_t path_pose_idx;
const auto current_tf_for_find_position = [&current_tf, track_base_link = config_.track_base_link,
Copy link
Member

Choose a reason for hiding this comment

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

These lambda functions don't really increase readability. But I get the point.

Although current_tf_for_find_position sounds like something that could be a simple request function on the class?

Copy link
Member

Choose a reason for hiding this comment

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

Actually, something is off here.

You're comment suggests a current_tf is requested. But there is also a variable current_tf. We should fix these names first.

Probably one tf points to base_link and the other to the tf that tries to follow the carrot. Right @cesar-lopez-mar ?

Copy link
Contributor Author

@lewie-donckers lewie-donckers Feb 22, 2022

Choose a reason for hiding this comment

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

Yes, if I move the lambda to a member function we could add some documentation (that was present in the original implementation).

current_tf is used if config_.track_base_link, else the following is used:

    // find position of current position with projected carrot
    geometry_msgs::Transform current_with_carrot_g;
    tf2::convert(current_with_carrot_, current_with_carrot_g);

Choose a reason for hiding this comment

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

These lambda functions don't really increase readability. But I get the point.

Although current_tf_for_find_position sounds like something that could be a simple request function on the class?

I agree that readability does not improve for all developers that might no be familiar with lambda functions (including myself). I would keep the comments of the original implementation in this function to help understanding the new code.

Choose a reason for hiding this comment

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

Actually, something is off here.

You're comment suggests a current_tf is requested. But there is also a variable current_tf. We should fix these names first.

Probably one tf points to base_link and the other to the tf that tries to follow the carrot. Right @cesar-lopez-mar ?

Indeed current_tf points to base_link, and the other one to the carrot.

Copy link
Member

Choose a reason for hiding this comment

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

Not the carrot. But the ControlPoint.

Copy link
Contributor

Choose a reason for hiding this comment

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

I opened #87 for this. Referencing here to put it on the list ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I'm confused as to what the conclusion of this discussion is/should be. I need some help.

Would replacing the lambda with a member function suffice? If so, I would like some help in naming and documenting that function.

Or, is there some underlying problem that needs to be fixed and which is preventing us from continuing with this PR?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, there is an underlying problem that the variable names are off. I propose we fix that first.

I hope a more clear solution direction will follow from that.

Copy link
Contributor

Choose a reason for hiding this comment

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

These variable names are really confusing indeed. current_tf also seems to imply that this is a tf2::Transform, but looking at this code, that cannot be the case (otherwise this wouldn't compile, as current_with_carrot_g is a geometry_msgs::Transform).

BTW, I like this refactor with the IILE

Base automatically changed from cleanup/unittest_fifo_array to main February 22, 2022 07:54
if (config_.track_base_link) {
// Find closes robot position to path and then project carrot on goal
Copy link

@cesar-lopez-mar cesar-lopez-mar Feb 22, 2022

Choose a reason for hiding this comment

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

I would preserve these kind of comments (after fixing the typo ;)), and move it to the new lambda function

@lewie-donckers
Copy link
Contributor Author

I closed this one in favor of a new PR train to fix #123 .

@lewie-donckers lewie-donckers deleted the cleanup/refactored-output-parameter-to-return-value branch March 16, 2022 08:20
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