Skip to content

Commit

Permalink
Allow robot-specific finishing request and specify parking spots (#379)
Browse files Browse the repository at this point in the history
* Allow robot-specific finishing request

Signed-off-by: Xiyu Oh <xiyu@openrobotics.org>

* Add printout for configured finishing request without parking spot

Signed-off-by: Xiyu Oh <xiyu@openrobotics.org>

* Cancel existing waiting behavior if new idle task is nothing

Signed-off-by: Xiyu Oh <xiyu@openrobotics.org>

* Add brackets

Signed-off-by: Xiyu Oh <xiyu@openrobotics.org>

* Refactor based on review comments

Signed-off-by: Xiyu Oh <xiyu@openrobotics.org>

* Cleanup

Signed-off-by: Xiyu Oh <xiyu@openrobotics.org>

* Tweak finishing_request parsing

Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>

* Schedule all API activity on the worker

Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>

* Small fixes

Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>

---------

Signed-off-by: Xiyu Oh <xiyu@openrobotics.org>
Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>
Co-authored-by: Michael X. Grey <mxgrey@intrinsic.ai>
  • Loading branch information
xiyuoh and mxgrey authored Oct 4, 2024
1 parent 76ef117 commit 6ab83a2
Show file tree
Hide file tree
Showing 10 changed files with 324 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,15 @@ class EasyFullControl::RobotConfiguration
/// Set the minimum lane length.
void set_min_lane_length(std::optional<double> distance);

/// Get the idle behavior.
///
/// If std::nullopt is used, then the fleet-wide default finishing request
/// will be used.
std::optional<rmf_task::ConstRequestFactoryPtr> finishing_request() const;

/// Set the finishing request.
void set_finishing_request(std::optional<rmf_task::ConstRequestFactoryPtr> request);

class Implementation;
private:
rmf_utils::impl_ptr<Implementation> _pimpl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

#include <rmf_traffic/schedule/Participant.hpp>

#include <rmf_task/RequestFactory.hpp>

#include <Eigen/Geometry>
#include <nlohmann/json.hpp>

Expand Down Expand Up @@ -102,6 +104,13 @@ class RobotUpdateHandle
/// property will be assumed as the charger for this robot.
RobotUpdateHandle& set_charger_waypoint(const std::size_t charger_wp);

/// Set a finishing request for this robot.
RobotUpdateHandle& set_finishing_request(rmf_task::ConstRequestFactoryPtr finishing_request);

/// Set a finishing request for this robot to use the fleet-wide finishing
/// request.
RobotUpdateHandle& use_default_finishing_request();

/// Update the current battery level of the robot by specifying its state of
/// charge as a fraction of its total charge capacity, i.e. a value from 0.0
/// to 1.0.
Expand Down
24 changes: 24 additions & 0 deletions rmf_fleet_adapter/src/rmf_fleet_adapter/TaskManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,24 @@ void TaskManager::set_idle_task(rmf_task::ConstRequestFactoryPtr task)
}
}

//==============================================================================
void TaskManager::use_default_idle_task()
{
auto fleet_handle = _fleet_handle.lock();
if (!fleet_handle)
{
RCLCPP_ERROR(
_context->node()->get_logger(),
"Attempting to use default idle task for [%s] but its fleet is shutting down",
_context->requester_id().c_str());
return;
}
const auto& impl =
agv::FleetUpdateHandle::Implementation::get(*fleet_handle);

set_idle_task(impl.idle_task);
}

//==============================================================================
void TaskManager::set_queue(
const std::vector<TaskManager::Assignment>& assignments)
Expand Down Expand Up @@ -1691,7 +1709,13 @@ void TaskManager::_begin_waiting()
}

if (!_responsive_wait_enabled)
{
if (_waiting)
{
_waiting.cancel({"Idle behavior updated"}, _context->now());
}
return;
}

if (_context->location().empty())
{
Expand Down
2 changes: 2 additions & 0 deletions rmf_fleet_adapter/src/rmf_fleet_adapter/TaskManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ class TaskManager : public std::enable_shared_from_this<TaskManager>

void set_idle_task(rmf_task::ConstRequestFactoryPtr task);

void use_default_idle_task();

/// Set the queue for this task manager with assignments generated from the
/// task planner
void set_queue(const std::vector<Assignment>& assignments);
Expand Down
Loading

0 comments on commit 6ab83a2

Please sign in to comment.