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

Galactic code review #29

Merged
merged 9 commits into from
Jun 8, 2023
Merged

Galactic code review #29

merged 9 commits into from
Jun 8, 2023

Conversation

cesar-lopez-mar
Copy link
Contributor

Made most changes suggested in PR25 #25

bool do_publish = false;
float orientation = eDirNone;
float orientation = dir::none;
RCLCPP_INFO(rclcpp::get_logger("FullCoveragePathPlanner"), "Received goalpoints with length: %lu", goalpoints.size());
if (goalpoints.size() > 1)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you elaborate more on your previous comment?

Copy link
Member

Choose a reason for hiding this comment

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

Sure!

Early-outs make the code more readable by handling the exceptions in a short block at the top.

function do_awesome()
{
  if (everything_okay_as_expected)
  {
    Do 
    lots 
    of 
    indented stuff
  }
  else
  {
    warn about it
  }
}

Can be replaced by:

function do_awesome()
{
  if (!everything_okay_as_expected)
  { 
    warn about it
    return;
  }

  Do 
  lots 
  of 
  stuff
}

Copy link
Member

Choose a reason for hiding this comment

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

And here it looks like goalpoints.size() <= 1 is exceptional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it... in our case the function does not return right after the else condition, so we can not early-out. I can switch the order to at least show the especial case first.

Copy link
Member

Choose a reason for hiding this comment

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

Aaah, I thought it did!
Then you may leave it like this as well. Up to you.

Copy link
Member

Choose a reason for hiding this comment

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

On a similar note. I think the node dies if goalpoints.size() == 0. Since that case isn't handled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep.. will add that one

@cesar-lopez-mar cesar-lopez-mar linked an issue Aug 9, 2021 that may be closed by this pull request
@cesar-lopez-mar
Copy link
Contributor Author

ping


namespace full_coverage_path_planner
{

enum dir
Copy link
Member

Choose a reason for hiding this comment

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

enum class dir

@Timple
Copy link
Member

Timple commented Aug 11, 2021

These improvements all look good, so approving.

But this PR is of course only a review of the improvements, not a full review. So that issue stays open.

I'll pick that up later this week.

@Timple Timple merged commit d5acf3c into galactic Jun 8, 2023
@Timple Timple deleted the galactic-code-review branch June 8, 2023 11:17
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.

Perform full galactic review
2 participants