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

Add override_status API #191

Merged
merged 5 commits into from
Apr 7, 2022
Merged

Add override_status API #191

merged 5 commits into from
Apr 7, 2022

Conversation

Yadunund
Copy link
Member

@Yadunund Yadunund commented Apr 7, 2022

This PR introducing RobotUpdateHandle::override_status(std::optional<std::string > status) API.

Users can use this API to override the string status for a given robot. By default the TaskManger assigns either idle or working depending on whether the robot is performing a task or not. But in some cases, users may want to explicitly set the status of the robot. In these scenarios, this API may be used. The API internally checks against the robot_state.json schema before accepting the new status. When users want RMF to take back control of the status, they may call this API with std::nullopt.

Signed-off-by: Yadunund yadunund@openrobotics.org

Signed-off-by: Yadunund <yadunund@openrobotics.org>
Signed-off-by: Yadunund <yadunund@openrobotics.org>
@codecov
Copy link

codecov bot commented Apr 7, 2022

Codecov Report

Merging #191 (ed82b00) into main (66721dd) will decrease coverage by 1.37%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #191      +/-   ##
==========================================
- Coverage   19.28%   17.90%   -1.38%     
==========================================
  Files         864      836      -28     
  Lines       79892    76408    -3484     
  Branches    38608    36568    -2040     
==========================================
- Hits        15406    13681    -1725     
- Misses      47829    48076     +247     
+ Partials    16657    14651    -2006     
Flag Coverage Δ
tests 17.90% <ø> (-1.38%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...mock_participants/repetitive_delay_participant.cpp
...et_adapter/src/experimental_lift_watchdog/main.cpp
...f_ros2/rmf_task_ros2/test/bidding/test_SelfBid.cpp
...2/rmf_fleet_adapter/test/phases/test_DoorClose.cpp
...apter/src/rmf_fleet_adapter/phases/RequestLift.cpp
...f_fleet_adapter/jobs/detail/impl_SearchForPath.hpp
..._adapter/src/rmf_fleet_adapter/make_trajectory.cpp
....0/Rx/v2/src/rxcpp/operators/rx-combine_latest.hpp
...os2/rmf_fleet_adapter/src/door_supervisor/Node.cpp
.../src/rmf_task_ros2/bidding/internal_Auctioneer.hpp
... and 1690 more

Copy link
Contributor

@mxgrey mxgrey left a comment

Choose a reason for hiding this comment

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

Thanks for addressing this need. I'm just requesting a couple small tweaks. Otherwise looks good 👍

if (status.has_value())
{
const auto loader =
[n = context->node(), s = _pimpl->schema_dictionary](
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not a huge issue since the schema dictionary only contains one value, but theoretically if it ever increased then this would be a needlessly costly capture, because it makes a complete copy of all the contents of schema_dictionary.

This is a very specific case where it's okay to capture [this], because the lambda will only be used within the scope of this function. I recommend just capturing [this] here to avoid the unnecessary copy. We should also leave a comment explaining why [this] is okay.

Signed-off-by: Yadunund <yadunund@openrobotics.org>
mxgrey
mxgrey previously approved these changes Apr 7, 2022
Copy link
Contributor

@mxgrey mxgrey left a comment

Choose a reason for hiding this comment

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

Thanks for the quick turnaround!

Signed-off-by: Yadunund <yadunund@openrobotics.org>
@Yadunund
Copy link
Member Author

Yadunund commented Apr 7, 2022

Sorry @mxgrey I just pushed a commit to update the bindings. Need your review again.

Signed-off-by: Yadunund <yadunund@gmail.com>
@Yadunund Yadunund merged commit e42b67e into main Apr 7, 2022
@Yadunund Yadunund deleted the feature/override_status branch April 7, 2022 23:56
@@ -126,6 +126,8 @@ PYBIND11_MODULE(rmf_adapter, m) {
py::arg("battery_soc"),
py::call_guard<py::scoped_ostream_redirect,
py::scoped_estream_redirect>())
.def("override_status", &agv::RobotUpdateHandle::override_status,
py::arg("battery_soc"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Is py::arg("battery_soc")) correct?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nope, that's definitely a copy/paste error. I'll correct that in an upcoming PR.

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.

None yet

3 participants