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

[Smac Planner] Enable goal orientation non-specificity #4019

Conversation

stevedanomodolor
Copy link
Contributor

@stevedanomodolor stevedanomodolor commented Dec 20, 2023


Basic Info

Info Please fill out this column
Ticket(s) this addresses (#3789)
Primary OS tested on (Ubuntu, MacOS, Windows)
Robotic platform tested on (Steve's Robot, gazebo simulation of Tally, hardware turtlebot)
Does this PR contain AI generated software? (No; Yes and it is marked inline in the code)

Description of contribution in a few bullet points

Description of documentation updates required from your changes

  • WIP

Future work that may be required in bullet points

For Maintainers:

  • Check that any new parameters added are updated in navigation.ros.org
  • Check that any significant change is added to the migration guide
  • Check that any new features OR changes to existing behaviors are reflected in the tuning guide
  • Check that any new functions have Doxygen added
  • Check that any new features have test coverage
  • Check that any new plugins is added to the plugins page
  • If BT Node, Additionally: add to BT's XML index of nodes for groot, BT package's readme table, and BT library lists

Copy link
Contributor

mergify bot commented Dec 20, 2023

@stevedanomodolor, your PR has failed to build. Please check CI outputs and resolve issues.
You may need to rebase or pull in main due to API changes (or your contribution genuinely fails).

@SteveMacenski
Copy link
Member

SteveMacenski commented Dec 20, 2023

Want to populate the PR template and add a name to the PR? This is opened without any context or statement about the state of this work and if there are any questions (or this is a 'done' implementation)

It would be nice to have some context 😉

@stevedanomodolor stevedanomodolor changed the title WIP [Smac Planner] Enable goal orientation non-specificity Dec 20, 2023
Copy link
Member

@SteveMacenski SteveMacenski left a comment

Choose a reason for hiding this comment

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

Generally this works! Now, you need to modify isGoal() [1] to use those goals to check if any are the item. That should be enough to start actually testing this working!

From there, the next major step is to expand the definitions for AnalyticExpansion to take in the goals and try to expand to each, each iteration. If any are valid, take the shortest.

Please make sure to lint using ament_cpplint and ament_uncrustify. It makes it much easier for me to review and keeps the styling in line with the rest of the project. A little TLC early can make your life alot easier later :-)

[1] https://github.com/ros-planning/navigation2/blob/main/nav2_smac_planner/src/a_star.cpp#L365-L370

@@ -337,6 +337,11 @@ float HybridMotionTable::getAngleFromBin(const unsigned int & bin_idx)
return bin_idx * bin_size;
}

unsigned int getNumOfBins()
{
return num_angle_quantization;
Copy link
Member

Choose a reason for hiding this comment

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

You could just use num_angle_quantization for the one instance this method is used? That seems in style with the rest of it. The table is treated like a global struct to grab info (for better or worse)

}
}

// TODO(@stevedanomodolor) find a better way to do this
Copy link
Member

Choose a reason for hiding this comment

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

What's the concern? I think this works fine, anything more you want to expand on here?


nav2_util::declare_parameter_if_not_declared(
node, name + ".goal_heading", rclcpp::ParameterValue("DEFAULT"));
node->get_parameter(name + ".goal_heading", _goal_heading_type);
Copy link
Member

Choose a reason for hiding this comment

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

You don't need to store the string type if you're storing the enum class

// _goals_coordinates.clear();
std::vector<Coordinates> goal_coordinates;
unsigned int number_of_bins = NodeT::motion_table.getNumOfBins();
if(goal_heading == GoalHeading::DEFAULT){
Copy link
Member

Choose a reason for hiding this comment

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

You could do this with a switch statement which would be more compact

{
_goal = addToGraph(NodeT::getIndex(mx, my, dim_3));
_goals.clear();
// _goals_coordinates.clear();
Copy link
Member

Choose a reason for hiding this comment

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

Remove this line?

static_cast<float>(mx),
static_cast<float>(my),
static_cast<float>(dim_3));
auto has_goals_changed = [](const std::vector<Coordinates> & current_goal_coordinates,const std::vector<Coordinates> & previous_goal_coordinates) -> bool
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 this lambda. Why not simply do A != B? Vectors can be compared. If the Coordinates class doesn't implement the operator=, that seems like an easier solution :-) I'm also not 100% sure why you'er comparing goal_coordinates[i] != goal_coordinates[i+1]and never seem to usecurrent_orprevious_ones. Overall, I think this can be removed with a simpleif A != B` statement inline to the code without the lambda

@stevedanomodolor
Copy link
Contributor Author

Thanks for the review, but it is not ready yet. I have made some changes locally since I made this push. I will close it for now, untill it is fully ready.

@SteveMacenski
Copy link
Member

OK!

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.

2 participants