-
Notifications
You must be signed in to change notification settings - Fork 38
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
Refactored output parameter. #75
Conversation
@@ -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 = [¤t_tf, track_base_link = config_.track_base_link, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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);
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 variablecurrent_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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ;)
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
if (config_.track_base_link) { | ||
// Find closes robot position to path and then project carrot on goal |
There was a problem hiding this comment.
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
I closed this one in favor of a new PR train to fix #123 . |
Refactored the output parameter of
Controller::findPositionOnPlan()
to return value.See:
Please note the following in
Controller::update()
where this function is used:findPositionOnPlan()
in different branches of the if statement, we now have 1.path_pose_idx
only once we have a value for it, so we can make it const.current_tf_for_find_position
. it has a complex initialization but with the IILE we can do so in one go and make the variable const. see http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es28-use-lambdas-for-complex-initialization-especially-of-const-variables