-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Nav2 toolkit #5116
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
Nav2 toolkit #5116
Conversation
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.
Good first stab!
Maybe lets wait until some more of this is fixed, but eventually we'll also need to add a configuration guide entry for this package in the docs.nav2.org and a migration guide entry to let folks know about the new features!
Anywhere that "AMCL" in mentioned in logs or naming, we should remove that and generally just talk about the pose publisher (which as an implementation detail is just AMCL for now). That way its not confusing when folks are using something that isn't AMCL, like SLAM Toolbox or another solution like VSLAM.
nav2_toolkit/src/pose_saver_node.cpp
Outdated
std::bind(&PoseSaverNode::reset_pose_file_cb, this, std::placeholders::_1, std::placeholders::_2)); | ||
|
||
if (auto_start) { | ||
saving_active_ = true; |
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.
Is saving_active_
needed? If the timer is running shouldn't it always be true? Every time its toggled it should be stopped.
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.
True,but i feel its better having a separate flag which keeps track of it.
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.
It doesn't, please remove. Its another piece of state that could be mishandled and cause bugs
nav2_toolkit/src/pose_saver_node.cpp
Outdated
} | ||
} | ||
|
||
// Wait for AMCL to subscribe to /initialpose |
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 think if we abstract out the functionality of restore_service_cb
into a new method, that method could just be called here and called in the service callback to share this capability.
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 good suggestion! Made it.
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 dont see it being used in the startup
@pranavk-2003, your PR has failed to build. Please check CI outputs and resolve issues. |
@pranavk-2003 let me know when you want me to take a look again! I see you pushed some changes but a number of items are not yet addressed 😄 |
Its somewhat figured out,I'll let you know soon , got busy with university stuff ☹ .the few pushed stuff i still have to test.I am right now finding it difficult to get the nav2_package() macro right for nav2_toolkit. |
Hey @SteveMacenski ,I think i am done with the code updates , you can now have a look again throughout.The doxygen docs is in progress. : ) Also the checks are failing , let me know what has to be done for that too. |
@pranavk-2003 open the failing jobs and fix the issues they lay out :-) It looks like alot of static code quality issues in linting |
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.
Needs test coverage as well!
nav2_toolkit/src/pose_saver_main.cpp
Outdated
@@ -0,0 +1,11 @@ | |||
#include "rclcpp/rclcpp.hpp" |
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.
Missing copyright header
nav2_toolkit/package.xml
Outdated
</description> | ||
|
||
|
||
<maintainer email="pranavkolekar13@gmail.com">Pranav</maintainer> |
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.
Add me too so I get emails on build issues
nav2_bringup/params/nav2_params.yaml
Outdated
@@ -79,7 +79,6 @@ bt_navigator: | |||
- nav_to_pose |
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.
Please resolve by adding back in
def generate_launch_description(): | ||
bringup_dir = get_package_share_directory('nav2_bringup') | ||
default_params_file = os.path.join(bringup_dir, 'params', 'nav2_params.yaml') | ||
default_pose_file = os.path.join(os.environ['HOME'], 'last_known_pose.yaml') |
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.
Remove, this should be considered in the node.
nav2_toolkit/CMakeLists.txt
Outdated
project(nav2_toolkit) | ||
|
||
find_package(nav2_common REQUIRED) | ||
nav2_package() |
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.
After all find_package
s
nav2_toolkit/README.md
Outdated
@@ -0,0 +1,12 @@ | |||
# nav2_toolkit | |||
|
|||
A modular ROS 2 node for persisting and restoring the robot's last known pose using the `/amcl_pose` topic. This is useful in applications where the robot is never manually moved (e.g. warehouse robots), and it enables automatic re-localization. |
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.
@pranavk-2003 this wasnt completed
nav2_toolkit/src/pose_saver_node.cpp
Outdated
"/amcl_pose", 10, | ||
std::bind(&PoseSaverNode::pose_callback, this, std::placeholders::_1)); | ||
|
||
initial_pose_pub_ = this->create_publisher<geometry_msgs::msg::PoseWithCovarianceStamped>("/initialpose", 10); |
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.
Rather than publishing the initial pose whereas you do not know if it was received, using a service means you know it was received properly due to getting a response. If none is given, then you can error handle
nav2_toolkit/src/pose_saver_node.cpp
Outdated
|
||
void PoseSaverNode::pose_callback(const geometry_msgs::msg::PoseWithCovarianceStamped::SharedPtr msg) | ||
{ | ||
last_pose_ = std::make_shared<geometry_msgs::msg::PoseWithCovarianceStamped>(*msg); |
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.
No, just store the *msg
object itself
nav2_toolkit/src/pose_saver_node.cpp
Outdated
} | ||
} | ||
|
||
// Wait for AMCL to subscribe to /initialpose |
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 dont see it being used in the startup
nav2_toolkit/src/pose_saver_node.cpp
Outdated
std::bind(&PoseSaverNode::reset_pose_file_cb, this, std::placeholders::_1, std::placeholders::_2)); | ||
|
||
if (auto_start) { | ||
saving_active_ = true; |
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.
It doesn't, please remove. Its another piece of state that could be mishandled and cause bugs
nav2_toolkit/src/pose_saver_node.cpp
Outdated
if (!saving_active_ || !last_pose_) return; | ||
|
||
try { | ||
write_pose_to_file(pose_file_path_); |
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.
Why not write to file when AMCL publishes to the pose topic? We could always throttle that to store every N
seconds in case it is a fast publishing topic like from VSLAM, but then we could remove this timer entirely.
nav2_toolkit/src/pose_saver_node.cpp
Outdated
|
||
void PoseSaverNode::pose_callback(const geometry_msgs::msg::PoseWithCovarianceStamped::SharedPtr msg) | ||
{ | ||
last_pose_ = std::make_shared<geometry_msgs::msg::PoseWithCovarianceStamped>(*msg); |
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.
Ex check if we should write by the write frequency when we get a pose here and then write it in this callback if saving_active_
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.
So what i understood from this is, when everytime amcl publishes a pose, it should be written to the file , instead of every N th second.For fast publishing it shall write every Nth second.But the question i have is , how would we decide when to write using timer and when to write with amcl publish update? A condition?
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.
So what i understood from this is, when everytime amcl publishes a pose, it should be written to the file , instead of every N th second.
Each time this callback is triggered, check against the last write time (variable to store) and write if greater than the maximum write frequency. Else, do nothing. That way if this topic publishes very fast, like in VSLAM, we're not doing a ton of IO at 100hz and instead writing to files every 1hz or less to get the general pose of the robot.
rclcpp::Time time_now = now();
if (time_now - last_write_time_ >= write_duration_)
{
last_write_time_ = time_now;
// do writing operation
}
Hey okay, so what shall it be?test as in demos for using the tool? |
Okay i understood how to solve those errors, i would solve these after all the code adjustments are done , as the code adjustments would introduce more of them |
You should create a unit test that runs the object and then publishes some data to the topic its listening to. Check after awhile that there's a file at the requested location and the data is correct. Then run another tests with autostart on and test that it correctly reads from that file and publishes / calls the service to set the pose correctly (the test object should expose the service, so nothing else should be running). Then another test should be with autostart / auto-store off and call the services to start / stop / reset and check that it does what it should do. Finally, a series of unit tests that checks CI should then tell you the coverage metrics in the codecov job - we need it to be at least 90% to be merged |
Also as a matter of practice, do not resolve the PR topic discussions. I'll hit "resolve" when I verify that it was completed as intended. It makes my life easier as a maintainer to know that I validated each of my previous comments in your updated fixes without having to go back through all of the collapsed tabs each time :-) |
This pull request is in conflict. Could you fix it @pranavk-2003? |
596bc7a
to
cb39462
Compare
Resolved the conflicts, @SteveMacenski i'll let you know when i want you to check this PR again. |
@pranavk-2003, your PR has failed to build. Please check CI outputs and resolve issues. |
Hey @SteveMacenski its been a while.I have added tests, adjusted the code according to your recommendations and enhancement suggestions.I have tried to solve and fix most of what we discussed last time.Please review the changes and let me know any modifications.Also dont worry about the checks as i will fix them after all the code changes are done.I have also relocated the BaseFootprintPublisher to nav2_toolkit.:) |
@pranavk-2003, your PR has failed to build. Please check CI outputs and resolve issues. |
Sincere apologies @SteveMacenski for the delay between last and this update and this dual mention .I understand its alot of work to review this PR from the start again , but i'll make sure to wrapup this PR to the earliest from now without any delays. |
OK! Let me know when you're ready. Please also heed the linters + DCO sign offs. It will make it much easier for me to review if the styling is consistent and I'm not distracted with pointing out pedantic errors. It also doesn't seem to build - which would be a minimum requirement for me to review. Try rebasing / pulling in main |
@pranavk-2003, your PR has failed to build. Please check CI outputs and resolve issues. |
2 similar comments
@pranavk-2003, your PR has failed to build. Please check CI outputs and resolve issues. |
@pranavk-2003, your PR has failed to build. Please check CI outputs and resolve issues. |
Sorry for the email spams of builds, ill remove you as a maintainer for now so it would not spam you. |
a4ae040
to
418a50b
Compare
Hi @SteveMacenski i think i might have done something wrong while trying to sign off my old commits :( . What should i do? maybe make a new draft PR.Although i Fixed most of the Build check fails.i would guess the failing ones are because of DCO.Please guide me through this.Apologies for the extra steps — really appreciate your patience. |
There are alot of merge conflicts. You could either resolve them or possibly try applying your work on an up-to-date branch and opening a new PR. I'm still seeing alot of build and linter errors if you check the failing red jobs above. They're mostly from linting that if you check on the linting jobs will tell you exactly how to fix them |
418a50b
to
b3804cf
Compare
This pull request is in conflict. Could you fix it @pranavk-2003? |
@pranavk-2003, your PR has failed to build. Please check CI outputs and resolve issues. |
b3804cf
to
b66ef49
Compare
Basic Info
Description of testing performed
Functional tests were conducted on turtlebot3 and are working as expected
Description of contribution in a few bullet points
nav2_toolkit
which has QOL features, which can be handy while working with Nav2 .Description of documentation updates required from your changes
Description of how this change was tested
All the changes were tested multiple times in simulation over a course of 3 weeks.
Future work that may be required in bullet points
In total , this package will contain 3 tools i.e
For Maintainers: