Skip to content

Commit

Permalink
Fix potential issues around tasks starting
Browse files Browse the repository at this point in the history
Signed-off-by: Michael X. Grey <[email protected]>
  • Loading branch information
mxgrey committed Feb 20, 2025
1 parent e4d1d87 commit 0e5380a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
14 changes: 14 additions & 0 deletions rmf_fleet_adapter/src/rmf_fleet_adapter/TaskManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,15 @@ nlohmann::json TaskManager::submit_direct_request(
request_id.c_str(),
robot.c_str());

_context->worker().schedule([w = weak_from_this()](const auto&)
{
if (const auto self = w.lock())
{
// Schedule this manager to check if it should run this task.
self->_begin_next_task();
}
});

// Publish api response
nlohmann::json response_json;
response_json["success"] = true;
Expand Down Expand Up @@ -1499,6 +1508,7 @@ void TaskManager::_begin_next_task()
const rmf_traffic::Time now = rmf_traffic_ros2::convert(
_context->node()->now());


if (now >= deployment_time)
{
if (_waiting)
Expand Down Expand Up @@ -1550,7 +1560,9 @@ void TaskManager::_begin_next_task()
[w = weak_from_this()](const auto&)
{
if (const auto self = w.lock())
{
self->_begin_next_task();
}
});

return;
Expand Down Expand Up @@ -2557,7 +2569,9 @@ std::function<void()> TaskManager::_task_finished(std::string id)
[w = self->weak_from_this()](const auto&)
{
if (const auto self = w.lock())
{
self->_begin_next_task();
}
});
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ void WaitForTraffic::Active::_consider_going()
for (const auto& dep : _dependencies)
{
if (!dep.reached() && !dep.deprecated())
{
all_dependencies_reached = false;
}
}

if (all_dependencies_reached)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ std::shared_ptr<LegacyTask::ActivePhase> WaitForCharge::Pending::begin()
"Robot [%s] has begun waiting for its battery to charge to %.1f%%. "
"Please ensure that the robot is charging.",
_context->name().c_str(),
_charge_to_soc.value_or(1.0) * 100.0);
_charge_to_soc.value_or(0.98) * 100.0);

active->_battery_soc_subscription = _context->observe_battery_soc()
.observe_on(rxcpp::identity_same_worker(_context->worker()))
Expand Down

0 comments on commit 0e5380a

Please sign in to comment.