Reject dynamic kinematic parameter updates when speed limit is active#5832
Conversation
881cdea to
39abfc1
Compare
mini-1235
left a comment
There was a problem hiding this comment.
Alternatively, we could use the addPreCallback function in ParameterHandler. When dynamic parameters are set, we check whether the user is trying to modify kinematic parameters. If s.constraints != s.base_constraints, we reject the update; otherwise, we allow it to proceed and handle it in the post-callback as usual
| getParam(s.base_constraints.az_max, "az_max", 3.5f); | ||
| // Kinematic constraint parameters use ParameterType::Static to prevent default dynamic updates. | ||
| // Custom callbacks below guard against updates when a speed limit is active. | ||
| getParam(s.base_constraints.vx_max, "vx_max", 0.5f, ParameterType::Static); |
There was a problem hiding this comment.
This would reject dynamic reconfiguration of vx_max and other settings even when s.constraints == s.base_constraints, which is probably not what we want
|
agreed !! |
Codecov Report❌ Patch coverage is
... and 23 files with indirect coverage changes 🚀 New features to boost your workflow:
|
445d01e to
995f67f
Compare
|
@Arnav-panjla, is this ready for another round of review? Please also add a unit test to make sure it's working as expected :) |
| // Register guarded callbacks for kinematic constraint parameters. | ||
| // These callbacks reject dynamic updates when a speed limit is active to prevent | ||
| // unintentionally resetting the modified constraints back to base values. | ||
| auto registerKinematicParam = [this](float & setting, const std::string & param_name) { |
There was a problem hiding this comment.
I might be wrong, but I don't think it works. Did you check the parameter value after it was rejected?
There was a problem hiding this comment.
I checked ParameterHandler
These callbacks run inside dynamicParamsCallback (the ROS2 on-set handler),
so returning successful = false does prevent the parameter from being stored.
To make this unambiguous, I’ll explicitly initialize result.successful = true and only flip it to false when rejecting.
Do let me know if am wrong
There was a problem hiding this comment.
Let's say we are entering a speed filter, so at that point we should reject any changes to the kinematic parameters.
If you set them the first time, it is probably rejected. But if you try to set them again, will it be rejected this time?
Also note that the log appears twice, once as a warning and once as an error, which is probably not ideal.
[component_container_isolated-9] [WARN 1767807521.540716534] [controller_server]: Rejected dynamic parameter update to 'vx_max': a speed limit is currently active. Kinematic parameters cannot be changed while speed limit modifies constraints. (operator()() at /root/nav2_ws/src/navigation2/nav2_mppi_controller/src/optimizer.cpp:124)
[component_container_isolated-9] [INFO 1767807521.541442244] [controller_server]: Optimizer reset (reset() at /root/nav2_ws/src/navigation2/nav2_mppi_controller/src/optimizer.cpp:223)
[component_container_isolated-9] [ERROR 1767807521.541469324] [controller_server]: Rejected dynamic update to 'vx_max': speed limit is active (constraints != base_constraints). Clear the speed limit first. (dynamicParamsCallback() at /root/nav2_ws/src/navigation2/nav2_mppi_controller/src/parameters_handler.cpp:93)
Earlier, I suggested adding this to the pre-callback because we already have a parameter callback there by default. This would also log the updated parameter values in verbose mode, which I think we would want to keep.
There was a problem hiding this comment.
a new if (result.successful) was added by @Arnav-panjla . This should mitigate repeated attempted changes.
|
@Arnav-panjla, could you please fix the unit test? It is currently failing in our CI I will take a deeper look again on this PR tomorrow |
|
@Arnav-panjla, just in case you missed the notifications, I have actually commented here: #5832 (comment) 😄 |
|
Ah, my bad! 😄 |
|
@Arnav-panjla any updates? :) |
|
@Arnav-panjla any updates? |
|
@mini-1235 If time is a constraint, I'd like to work on the CI tests and any other concerns left to fix |
|
Hi @Pana1v I could use some help, |
…avigation#5832) Signed-off-by: Arnav-Panjla <arnavpanjla@gmail.com>
|
Hi, feel free to work on this / collaborate, please ping me again when this is ready for review :) |
Hi, I cannot push yet, can you add me as a collaborator to your fork. Pushing through the indentation and I guess your last commit address the previous concerns, will look out for any more. |
|
@Arnav-panjla you could also fork off of their fork (and/or cherry pick the commits to your main nav2 fork) and work from there and open another PR. Just tell us in the PR body it supersedes this one and we can close this out to continue :-) |
|
I am currently working on closing #4907, as part of this effort, we are refactoring the dynamic parameter pattern in each package to align with the new parameter api:
full context in https://docs.ros.org/en/rolling/Concepts/Basic/About-Parameters.html At this point, I think it makes more sense to directly follow the new parameter api pattern rather than continuing with the previous approach I suggested, see more in #5964. This would also simplify this PR and make it easier to implement, I think. Also please pull in / rebase main, the build error is likely due to the underlay repositories not being up to date, we have updated in a few weeks ago :) |
f7c57b7 to
5190f8f
Compare
…avigation#5832) Signed-off-by: Arnav-Panjla <arnavpanjla@gmail.com>
|
This pull request is in conflict. Could you fix it @Arnav-panjla? |
|
With #5964 now merged, I think this PR can be simplified. Basically, we just need to add pre-callbacks for the relevant parameters, without modifying the implementation inside parameter_handler. See the example here @Arnav-panjla @Pana1v would either of you be interested in picking this up so we can move this issue/PR toward closure? |
|
sure, will work on it over this weekend |
0b5774e to
65c449c
Compare
|
This pull request is in conflict. Could you fix it @Arnav-panjla? |
|
PTAL @mini-1235 |
mini-1235
left a comment
There was a problem hiding this comment.
I left a few comments, but overall LGTM!
For the DCO, I think you need to add @Arnav-panjla as coauthor in your commits?
fb8c4dc to
ea2d2af
Compare
…avigation#5832) Signed-off-by: Arnav-Panjla <arnavpanjla@gmail.com>
|
If you take a look at the diff, you probably did something wrong when rebasing |
|
yeah, working on it |
ea2d2af to
d0a9a8c
Compare
|
I will approve once DCO passes :) If you run into any trouble fixing it, it might be easier to open a new PR instead |
…avigation#5832) Signed-off-by: Arnav-Panjla <arnavpanjla@gmail.com> Signed-off-by: Arnav Panjla <arnavpanjla@gmail.com>
d0a9a8c to
e3486b3
Compare
…avigation#5832) Signed-off-by: Arnav-Panjla <arnavpanjla@gmail.com> Signed-off-by: Arnav Panjla <arnavpanjla@gmail.com> Signed-off-by: Maurice <mauricepurnawan@gmail.com>
e3486b3 to
878a255
Compare
|
This pull request is in conflict. Could you fix it @Arnav-panjla? |
878a255 to
d0a9a8c
Compare
Signed-off-by: Arnav-panjla <arnavpanjla@gmail.com> Signed-off-by: Panav Arpit Raaj <praajarpit@gmail.com>
Signed-off-by: Arnav-panjla <arnavpanjla@gmail.com> Signed-off-by: Panav Arpit Raaj <praajarpit@gmail.com>
…tive and Removed ParameterType::Static Signed-off-by: Arnav-panjla <arnavpanjla@gmail.com> Signed-off-by: Panav Arpit Raaj <praajarpit@gmail.com>
Signed-off-by: Arnav-panjla <arnavpanjla@gmail.com> Signed-off-by: Panav Arpit Raaj <praajarpit@gmail.com>
Signed-off-by: Arnav-panjla <arnavpanjla@gmail.com> Signed-off-by: Panav Arpit Raaj <praajarpit@gmail.com>
…avigation#5832) Signed-off-by: Arnav-Panjla <arnavpanjla@gmail.com>
Signed-off-by: Panav Arpit Raaj <praajarpit@gmail.com>
Signed-off-by: panav <panav@10xconstruction.com> Signed-off-by: Panav Arpit Raaj <praajarpit@gmail.com>
Signed-off-by: panav <panav@10xconstruction.com>
…PreCallback in optimizer Signed-off-by: panav <panav@10xconstruction.com> Signed-off-by: Panav Arpit Raaj <praajarpit@gmail.com>
Co-authored-by: Maurice Alexander Purnawan <mauricepurnawan@gmail.com> Signed-off-by: Panav <63401208+Pana1v@users.noreply.github.com> Signed-off-by: Panav Arpit Raaj <praajarpit@gmail.com>
…parameter updates during active speed limits and refine parameter handling logic. Signed-off-by: Panav Arpit Raaj <praajarpit@gmail.com>
d0a9a8c to
ec62ce6
Compare
mini-1235
left a comment
There was a problem hiding this comment.
Thanks! I will pass this along to @SteveMacenski for a final review to see if he has any additional suggestions
|
Thanks @mini-1235! |
SteveMacenski
left a comment
There was a problem hiding this comment.
Otherwise very clever and well done
Signed-off-by: Arnav-Panjla <arnavpanjla@gmail.com>
Basic Info
Description of contribution in a few bullet points
isSpeedLimitActive()helper method to detect when speed limit has modified constraintsDescription of documentation updates required from your changes
Description of how this change was tested
Future work that may be required in bullet points
For Maintainers:
backport-*.