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

Drive on heading #2898

Merged
merged 36 commits into from
May 4, 2022
Merged

Conversation

jwallace42
Copy link
Contributor


Basic Info

Info Please fill out this column
Ticket(s) this addresses #2888
Primary OS tested on Ubuntu
Robotic platform tested on Gazebo

Description of contribution in a few bullet points

Extended the backup behavior to drive on heading. The behavior can now go forwards or backwards.

Description of documentation updates required from your changes

Changes to the behavior server docs and bt nodes docs.


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

@mergify
Copy link
Contributor

mergify bot commented Apr 7, 2022

@jwallace42, please properly fill in PR template in the future. @SteveMacenski, use this instead.

  • 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

@SteveMacenski
Copy link
Member

SteveMacenski commented Apr 7, 2022

What you suggest is definitely not unreasonable, but it is a very large change which will effect every user's configurations since that plugin will cease to exist and all behavior trees will need a different BT node used. I would like to be cautious due to that to try to make this as least disruptive as possible.

Semantically, I think about "back up" versus "drive straight" as 2 different action contexts even though they're representing related things.

Within the BT, would it be possible to have a derived class from drive on heading for backup so that we still have a backup BT node that can be used in the BTs for semantically different tasks? So then we'd have both BT nodes available requiring no changes to end users BTs but then have the additional drive at current heading action (back up just checks its negative). Same with cancel.

I'm debating what I would want for the plugins in the behavior server. From one perceptive, we could do the analog thing here to have both a drive on current heading + backup behavior plugins. But that feels really redundant, and the BT node of backup could just call the renamed behavior plugin for the same results -- we just need to enforce the negative value in the backup version of the BT node. I don't think we need to duplicate the plugins code. What do you think?

I've never done this before, but I think if you created 2 instances in here https://github.com/ros-planning/navigation2/blob/a32ebfaa0ca161de9f6a0841fc1a536c3a0e75ba/nav2_behaviors/behavior_plugin.xml#L9 of the name "backup" and of "driveonheading", then it should make it so that you can load this same plugin based on both names if specified in a parameter file. You'd have to check though. If we did that, we could not duplicate any code, but also not require users to update their YAML files based on the change to load. We could add a depreciation warning into the description.

That leaves the only open question is the action topic ID. For the high level BT node, both can use the drive on current heading name. Or, for the backup version, we could use the original backup name when it is registered.

For the behavior plugin, the drive on current heading is fine. If we aliased the backup plugin loading name, I think it would load the plugin correctly, but if we didn't replace the behavior ID in the yaml from backup to drive_on_heading, then it would use the backup action topic which is wrong, I believe. So I think that implies then that the backup BT node should also use the backup moniker to prevent the need of users to change anything for the current behavior.

but that would brake the use of backup BT node to hook up to the drive at current heading server, without manually overriding it in the BT XML server_name field. So its backward compatibility or the ability moving forward to use semantic use of both back up and drive at heading. Or just duplicating both the BT XML and the behavior plugin to have both.

Options, options, options... I need to think about this. I'm leaning towards duplication though so we can have both forward and backward compatibility, even though they're pretty much the same thing. But if we use derived classes, we can at least reduce the code duplication to the bare minimum on registering topic IDs and checking negative signs.

At some point in the medium term or distant future, we can deprecate backup action, but I fear doing it right now given the already big change between recovery and behavior server already made in this distribution upgrade from galactic -> humble. Another side of the coin is "yolo" because we already have changed so much, may as well just load into it and make 1 very annoying transition vs several minorly irritating transitions.

Thoughts?

@jwallace42
Copy link
Contributor Author

It is a lot of changes but the only thing they have to do is switch the BT xml file right? Just change the node names and switch sign of the values.

But I really don't know much about the how the upgrading from galactic to humble works. It there something else they would have to do?

@mergify
Copy link
Contributor

mergify bot commented Apr 8, 2022

This pull request is in conflict. Could you fix it @jwallace42?

@SteveMacenski
Copy link
Member

It is a lot of changes but the only thing they have to do is switch the BT xml file right? Just change the node names and switch sign of the values.

If you derive from this as a base class and make a derived class for backup, it would be the sign and when registering the plugin, using the backup name / action rather than drive on heading.

But I really don't know much about the how the upgrading from galactic to humble works. It there something else they would have to do?

If we didn't make it easy for them, they'd have to modify their configs and BT XMLs because the backup action wouldn't exist and the backup BT node wouldn't exist anymore.

@jwallace42
Copy link
Contributor Author

Alright, so the goal is still support old BT xml. I will just create a derived backup class. Would there be a plan to faze out the backup node or would we always have it?

@SteveMacenski
Copy link
Member

This is a good question. I think the BT node would be there forever, I think the actual backend separate action server / behavior plugin would be deprecated. The Backup BT node would just be redirected to that new server after the next distribution release.

I think "DriveOnHeading" vs "BackUp" are semantically different to a autonomy system designer, so having both would make more clear in design context the intent of the move, so both would be nice.

I figure once we have the drive on heading + rotate, we can do a little demo of having the robot drive in a shape or something (e.g. drive 1 meter, turn 90 deg, drive 1 meter, turn 90 deg, ...) which could be helpful for calibration and a POC of its use. Those primitives are common for students in entry-level robotics courses to need to use, so I figure having them around is helpful. Updating the Python API with them would be even more useful. But that takes like 15 minutes, not a big deal

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.

Really good -- if I wasn't trying to reduce code duplication, I think we could even call it done right here.

Something I think worth trying, it might not work out due to complexities, but I think it should at least from a architect's 30,000 ft view:

  • I looked at what is involved at deriving backup from the drive on heading BT node, and it literally turns into just as much code, just shuffled around. So no need to do that.
  • I looked at what's involved at deriving backup behavior from the drive on heading behavior plugins, and I think you can reduce essentially all the code. Then you just need to export the plugin and set the different action definition. I think that might need to make DriveOnHeading to be itself templated with a default to DriveOnHeading's message. But that should be a few just method definition changes, in exchange, we have no duplicate code in the behavior plugins for duplicate behavior.

nav2_bringup/launch/tb3_simulation_launch.py Outdated Show resolved Hide resolved
nav2_core/README.md Outdated Show resolved Hide resolved
nav2_behaviors/plugins/drive_on_heading.cpp Outdated Show resolved Hide resolved
@jwallace42
Copy link
Contributor Author

Fixed of test errors. The xml linter complains but the the structure is actually correct.

@SteveMacenski
Copy link
Member

SteveMacenski commented Apr 18, 2022

In XML < or & are strictly illegal to use as values. There are more which are not strictly illegal but are better avoided. Use an entity reference instead. So your XML file generates an error. The entity reference for < is < and > is >

I think that should help? from https://stackoverflow.com/questions/22463154/unescaped-not-allowed-in-attributes-values-error-in-r

If my memory doesn't fault me, I think I've seen that in use other places in ROS as well for this reason

nav2_behaviors/behavior_plugin.xml Outdated Show resolved Hide resolved
nav2_behaviors/plugins/drive_on_heading.hpp Show resolved Hide resolved
nav2_behaviors/plugins/drive_on_heading.hpp Outdated Show resolved Hide resolved
nav2_behaviors/plugins/drive_on_heading.cpp Show resolved Hide resolved
nav2_behaviors/plugins/drive_on_heading.cpp Outdated Show resolved Hide resolved
nav2_behaviors/plugins/drive_on_heading.cpp Outdated Show resolved Hide resolved
@jwallace42
Copy link
Contributor Author

@SteveMacenski should be gtg!

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.

Just some changes on parameterization, but otherwise LGTM!

Did you test manually adding the drive on heading BT XML node in a BT and it worked as you expect?

nav2_bringup/launch/bringup_launch.py Outdated Show resolved Hide resolved
nav2_bringup/launch/tb3_simulation_launch.py Outdated Show resolved Hide resolved
@jwallace42
Copy link
Contributor Author

jwallace42 commented Apr 28, 2022

Just some changes on parameterization, but otherwise LGTM!

Did you test manually adding the drive on heading BT XML node in a BT and it worked as you expect?

I tested it though the behavior tree by manually adding it and it worked as expected. I also made a bunch of action calls to drive_on_heading.

@SteveMacenski
Copy link
Member

SteveMacenski commented Apr 28, 2022

@jwallace42 LGTM last is docs:

  • Add to navigation plugins list in docs
  • Add parameters page for this

Also test coverage is missing https://codecov.io/gh/ros-planning/navigation2/tree/c04e9f73a7f61022ee8bbb7f5a562c86f5354887/nav2_behaviors/plugins

  • No testing for backup behavior
  • No testing for drive on heading behavior

Well actually the testing bits might be due to caching issues. In the circleCI directory, change these 3 instances of v9 to v11 https://github.com/ros-planning/navigation2/blob/main/.circleci/config.yml#L36-L61 to break the cache. But make sure to test and look at the codecov results

@mergify
Copy link
Contributor

mergify bot commented Apr 28, 2022

@jwallace42, 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

https://codecov.io/gh/ros-planning/navigation2/tree/8f722714e31601911b7bcd8515225a4ac13cb7bf/nav2_behaviors/plugins

A bit more test coverage on these would be good -- the cache breaking fixed the issue. This PR would drop the coverage % below 90% for the package

@SteveMacenski SteveMacenski merged commit 54323dc into ros-navigation:main May 4, 2022
@jwallace42 jwallace42 deleted the drive_on_heading branch May 9, 2022 18:50
redvinaa pushed a commit to EnjoyRobotics/navigation2 that referenced this pull request Jun 30, 2022
* renamed class

* rename backup to drive_on_heading

* test file rename

* renamed backup bt node

* renamed ports

* renamed binaries

* named backup cancel

* renamed backup action

* rename yaml

* fixing tests

* undid cmake

* add backup back in for old users

* added back_up back in

* remove commented tests

* rename server

* code review

* code review fixes

* code review

* templated the drive on heading

* fully templated drive on heading

* template fixes for drive on heading

* template working

* linting and boolean fix

* fixed tests

* added multiple files for recoveries

* xml fix

* fixed copyright

* revert

* Update nav2_behaviors/plugins/drive_on_heading.hpp

* Update nav2_behaviors/plugins/drive_on_heading.hpp

* update circleci config

* fixed back_up test

* fixed drive on heading test

Co-authored-by: Steve Macenski <[email protected]>
savalena pushed a commit to savalena/navigation2 that referenced this pull request Jul 5, 2024
* renamed class

* rename backup to drive_on_heading

* test file rename

* renamed backup bt node

* renamed ports

* renamed binaries

* named backup cancel

* renamed backup action

* rename yaml

* fixing tests

* undid cmake

* add backup back in for old users

* added back_up back in

* remove commented tests

* rename server

* code review

* code review fixes

* code review

* templated the drive on heading

* fully templated drive on heading

* template fixes for drive on heading

* template working

* linting and boolean fix

* fixed tests

* added multiple files for recoveries

* xml fix

* fixed copyright

* revert

* Update nav2_behaviors/plugins/drive_on_heading.hpp

* Update nav2_behaviors/plugins/drive_on_heading.hpp

* update circleci config

* fixed back_up test

* fixed drive on heading test

Co-authored-by: Steve Macenski <[email protected]>
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