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

Allow robot-specific finishing request and specify parking spots #379

Merged
merged 13 commits into from
Oct 4, 2024
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;
mxgrey marked this conversation as resolved.
Show resolved Hide resolved

/// 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);
mxgrey marked this conversation as resolved.
Show resolved Hide resolved

/// 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;
mxgrey marked this conversation as resolved.
Show resolved Hide resolved
}

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
Loading