-
Notifications
You must be signed in to change notification settings - Fork 645
Added parameter check_min_dist_and_heading_precisely
#808
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
Conversation
src/slam_toolbox_common.cpp
Outdated
| static Pose2 last_pose; | ||
| static rclcpp::Time last_scan_time = rclcpp::Time(0.); | ||
| static double min_dist2 = | ||
| static double min_dist2 = 0.81 * // within 10% for correction error |
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 these multipliers Or rather, keep them the same as before
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.
Oh, you did put a "👍🏻" on 0.9 here: #545 (comment), so I used it. I thought, the previous 0.8 * min_dist2 was
0.9 * 0.9 = 0.81.
- Okay, for the distance squared, keeping
0.8. - For the angle,
0.9or not at all?
In my tests, no multipliers, obviously gave the closest updates according to the given minimum_travel_distance and minimum_travel_heading values. So I was about to push the change with pleasure before you strikethroughed 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.
Since this fix changes previous behavior, e.g. old test rosbags wouldn't produce the same maps, I think keeping the previous values doesn't make much difference. I even considered adding a new param named allow_pure_rotational_updates with a default value of false, and keeping everything the same as before when it’s set to false.
- People generating new maps with this fix, wouldn't mind (I think)
- People using localization node, would notice a different behaviour, and an occasional small CPU spike, but robots in production usually don't upgrade their packages to avoid these.
I'm new here, wasn't sure if it is really necessary to preserve the previous behaviour. I was also not sure about backporting this to Jazzy or making the change backportable in the first place.
This change is bigger than how it looks. I don't wanna be the person who broke slam_toolbox 🙃 Would implementing the allow_pure_rotational_updates parameter be a better approach?
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.
Would implementing the allow_pure_rotational_updates parameter be a better approach?
yes please, I think that makes sense. Make sure to document it in the readme's configuration section and I can merge this. I approve of the code, minus that update
|
Planning on adding the new parameter? |
|
Currently working on it, updated the issue title, because I discovered that the min heading param is actually used only sometimes with the previous magic you did, but that also caused min distance param to behave differently. I also saw that the map wasn't updating after exceeding min dist sometimes. Now, I created more troubles for myself, even though the previous Also started creating it in the wrong place but realised that I could just get the parameter in the /**
* @note Currently not used in the Mapper class; either of the minimum travel parameters is always
* checked here before processing a scan. Used by ROS nodes to decide which scans to process.
*
* Whether to always check if both MinimumTravelHeading and MinimumTravelDistance are satisfied
* precisely before processing a scan.
* When set to false, the MinimumTravelHeading check allows processing a scan only rarely when
* the ROS nodes consider the MinimumTravelDistance satisfied, but the Mapper class, which uses a
* stricter tolerance, does not. In such cases, the HasMovedEnough() check approves the update
* based on the MinimumTravelHeading. This default behavior suits most cases where, for example,
* rotational odometry is poor.
* When set to true, scans with pose changes exceeding the MinimumTravelHeading, such as in-place
* rotational movements, are also forwarded to the mapper to be processed without requiring
* translational movement to meet the MinimumTravelDistance threshold. In this mode, the ROS
* nodes' MinimumTravelDistance check always matches the Mapper's strictness.
* Default value is false.
*/
Parameter<kt_bool>* m_pCheckMinimumTravelsPrecisely;Will try to convince you to approve removing the 10% correction multipliers when this param is |
|
if (squaredTravelDistance >= math::Square(m_pMinimumTravelDistance->GetValue()) - KT_TOLERANCE)so sometimes, the difference is approved by I can see that this magic you did, improves mapping quality, even when users play with min travel params. But I think, when localising, we need the param |
|
I requested a review but I should add, tested the changes in sim, with Jazzy. Didn't even compile with Rolling, there were some other issues and I just diff-checked the I can try to compile, if you have a docker file for testing. But I can't promise a time frame of delivery if you want me to test with Rolling in sim 🙃 |
minimum_travel_headingcheck_minimum_travels_precisely
|
Sorry for the delay, I was at ROSCon and then took my annual post-ROSCon vacation. Back at my desk now. You can just compile in the standard OSRF rolling docker container. You mentioned that this degraded performance in one of your intermediate comments. Did you resolve that? Obviously reducing performance isn't something I want... |
src/slam_toolbox_common.cpp
Outdated
| // check if the movement is enough | ||
| const double dist2 = last_pose.SquaredDistance(pose); | ||
| if (dist2 < 0.8 * min_dist2 || scan_ctr < 5) { | ||
| if (check_minimum_travels_precisely_) { |
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.
Other option: Doesn't Karto itself check if enough distance/heading change has occurred? If so, you could have this totally bypassed and use the karto limits from the parameterizations. I think this was done here to get around the 'work' done prior to that check as an optimization.
But I could be remembering wrong, this was almost 10 years ago
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 guessed the same, asked to myself "why check twice", for an optimization maybe, so I wanted to keep it same.
There are other things being done before checking HasMovedEnough in Karto, I hadn't dug enough to see what are those, how of much this 'work' prior is helpful when the robot hasn't moved enough, so I didn't continue digging.
Adding a new check_if_moved_enough method parameter to Process and ProcessLocalization methods in Karto and not checking HasMovedEnough if this parameter is true would effectively bypass the second check:
Mapper::Process(LocalizedRangeScan * pScan, Matrix3 * covariance, bool check_if_moved_enough = false)Since checking in the toolbox before Karto, is presumably better for optimisation.
I can add the new toolbox parameter to Karto too, add a commented out serialisation of the parameter like below and just check it instead of using a method parameter.
...
ar & BOOST_SERIALIZATION_NVP(m_pMinimumDistancePenalty);
ar & BOOST_SERIALIZATION_NVP(m_pUseResponseExpansion);
// NOTE: the following two lines are commented out to avoid breaking the serialization of already existing maps
// ar & BOOST_SERIALIZATION_NVP(m_pMinPassThrough);
// ar & BOOST_SERIALIZATION_NVP(m_pOccupancyThreshold);
// ar & BOOST_SERIALIZATION_NVP(m_pCheckIfMovedEnough); <--- new oneBut I would prefer this bypassing operation to be a separate PR since it is a work on another thing which was here before this PR. And also honestly, so I can delay doing it and put it in my TODO list, by opening a shiny issue about it. You can ping me later in that issue.
Welcome back, hope you rested well. Currently dealing with it. I had Rolling installed on my machine natively when I wrote this fix and decided not to build it because of the
The "occasional small CPU spike" I mentioned was about the natural, expected behaviour. Right now, if I will answer the review comments now. |
|
I was finally able to build it after commenting out //#include "rclcpp/rclcpp/qos.hpp"Ofc this and other changes I mentioned, to be able to build it, are not pushed. |
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.
LGTM - any other adjustments before merge? This does, obviously, need to compile on Rolling though as the ros2 main branch :-)
Nope, will open the same PR for
I'd open an ✨issue✨ that it currently doesn't 🙃 but that seems unnecessary;
edit (this is not related to the compiling, so should've been separated):About bypassing the double check problem we talked above, I can open another issue. Because it was present before this PR. |
|
I'm a bit unclear. Are you saying this PR, due to your changes, does not compile? Or that it does not compile in general? (I really need to setup CI for this repo; I have no idea why I haven't thus far. A bit ridiculous if you ask me ... about me) |
|
The main branch was not compiling already, before my changes. To be sure that there is nothing wrong with my changes, I did the things I said above to be able to build. With Jazzy, same changes, no problem at all. Yeah CI would be great. |
SteveMacenski
left a comment
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.
Got it - another problem for another time
check_minimum_travels_preciselycheck_min_dist_and_heading_precisely
Basic Info
I'm not sure about the 10% correction error parts, removed it while testing to see if the updates work with the given min distance and angle,
and then added them back.