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

Fix potential issues around tasks starting #403

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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