Class FleetUpdateHandle

Nested Relationships

Nested Types

Inheritance Relationships

Base Type

  • public std::enable_shared_from_this< FleetUpdateHandle >

Class Documentation

class rmf_fleet_adapter::agv::FleetUpdateHandle : public std::enable_shared_from_this<FleetUpdateHandle>

Public Types

using ConsiderRequest = std::function<void(const nlohmann::json &description, Confirmation &confirm)>

Signature for a callback that decides whether to accept a specific category of task request.

Parameters
  • [in] description: A description of the task that is being considered

  • [in] confirm: Use this object to decide if you want to accept the task

using AcceptTaskRequest = std::function<bool(const rmf_task_msgs::msg::TaskProfile &profile)>

A callback function that evaluates whether a fleet will accept a task request

Return

true to indicate that this fleet should accept the request, false to reject the request.

Parameters
  • [in] request: Information about the task request that is being considered.

using AcceptDeliveryRequest = std::function<bool(const rmf_task_msgs::msg::Delivery &request)>

A callback function that evaluates whether a fleet will accept a delivery request.

Return

true to indicate that this fleet should accept the request, false to reject the request.

Parameters
  • [in] request: Information about the delivery request that is being considered.

Public Functions

void add_robot(std::shared_ptr<RobotCommandHandle> command, const std::string &name, const rmf_traffic::Profile &profile, rmf_traffic::agv::Plan::StartSet start, std::function<void(std::shared_ptr<RobotUpdateHandle> handle)> handle_cb)

Add a robot to this fleet adapter.

Return

a handle to give the adapter updates about the robot.

Parameters
  • [in] command: A reference to a command handle for this robot.

  • [in] name: The name of this robot.

  • [in] profile: The profile of this robot. This profile should account for the largest possible payload that the robot might carry.

  • [in] start: The initial location of the robot, expressed as a Plan::StartSet. Multiple Start objects might be needed if the robot is not starting precisely on a waypoint. The function rmf_traffic::agv::compute_plan_starts() may help with this.

  • [in] handle_cb: This callback function will get triggered when the RobotUpdateHandle is ready to be used by the Fleet API side of the Adapter. Setting up a new robot requires communication with the Schedule Node, so there may be a delay before the robot is ready to be used.

FleetUpdateHandle &consider_delivery_requests(ConsiderRequest consider_pickup, ConsiderRequest consider_dropoff)

Allow this fleet adapter to consider delivery requests.

Pass in nullptrs to disable delivery requests.

By default, delivery requests are not accepted until you provide these callbacks.

The FleetUpdateHandle will ensure that the requests are feasible for the robots before triggering these callbacks.

Parameters
  • [in] consider_pickup: Decide whether to accept a pickup request. The description will satisfy the event_description_PickUp.json schema of rmf_fleet_adapter.

  • [in] consider_dropoff: Decide whether to accept a dropoff request. The description will satisfy the event_description_DropOff.json schema of rmf_fleet_adapter.

FleetUpdateHandle &consider_cleaning_requests(ConsiderRequest consider)

Allow this fleet adapter to consider cleaning requests.

Pass in a nullptr to disable cleaning requests.

By default, cleaning requests are not accepted until you provide this callback.

Parameters
  • [in] consider: Decide whether to accept a cleaning request. The description will satisfy the event_description_Clean.json schema of rmf_fleet_adapter. The FleetUpdateHandle will ensure that the request is feasible for the robots before triggering this callback.

FleetUpdateHandle &consider_patrol_requests(ConsiderRequest consider)

Allow this fleet adapter to consider patrol requests.

Pass in a nullptr to disable patrol requests.

By default, patrol requests are always accepted.

Parameters
  • [in] consider: Decide whether to accept a patrol request. The description will satisfy the task_description_Patrol.json schema of rmf_fleet_adapter. The FleetUpdateHandle will ensure that the request is feasible for the robots before triggering this callback.

FleetUpdateHandle &consider_composed_requests(ConsiderRequest consider)

Allow this fleet adapter to consider composed requests.

Pass in a nullptr to disable composed requests.

By default, composed requests are always accepted, as long as the events that they are composed of are accepted.

Parameters
  • [in] consider: Decide whether to accept a composed request. The description will satisfy the task_description_Compose.json schema of rmf_fleet_adapter. The FleetUpdateHandle will ensure that the request is feasible for the robots before triggering this callback.

FleetUpdateHandle &add_performable_action(const std::string &category, ConsiderRequest consider)

Allow this fleet adapter to execute a PerformAction activity of specified category which may be present in sequence event.

Parameters
  • [in] category: A string that categorizes the action. This value should be used when filling out the category field in event_description_PerformAction.json schema.

  • [in] consider: Decide whether to accept the action based on the description field in event_description_PerformAction.json schema.

void close_lanes(std::vector<std::size_t> lane_indices)

Specify a set of lanes that should be closed.

void open_lanes(std::vector<std::size_t> lane_indices)

Specify a set of lanes that should be open.

bool set_task_planner_params(std::shared_ptr<rmf_battery::agv::BatterySystem> battery_system, std::shared_ptr<rmf_battery::MotionPowerSink> motion_sink, std::shared_ptr<rmf_battery::DevicePowerSink> ambient_sink, std::shared_ptr<rmf_battery::DevicePowerSink> tool_sink, double recharge_threshold, double recharge_soc, bool account_for_battery_drain, rmf_task::ConstRequestFactoryPtr finishing_requst = nullptr)

Set the parameters required for task planning. Without calling this function, this fleet will not bid for and accept tasks.

Return

true if task planner parameters were successfully updated.

Parameters
  • [in] battery_system: Specify the battery system used by the vehicles in this fleet.

  • [in] motion_sink: Specify the motion sink that describes the vehicles in this fleet.

  • [in] ambient_sink: Specify the device sink for ambient sensors used by the vehicles in this fleet.

  • [in] tool_sink: Specify the device sink for special tools used by the vehicles in this fleet.

  • [in] recharge_threshold: The threshold for state of charge below which robots in this fleet will cease to operate and require recharging. A value between 0.0 and 1.0 should be specified.

  • [in] recharge_soc: The state of charge to which robots in this fleet should be charged up to by automatic recharging tasks. A value between 0.0 and 1.0 should be specified.

  • [in] account_for_battery_drain: Specify whether battery drain is to be considered while allocating tasks. If false, battery drain will not be considered when planning for tasks. As a consequence, charging tasks will not be automatically assigned to vehicles in this fleet when battery levels fall below the recharge_threshold.

  • [in] finishing_request: A factory for a request that should be performed by each robot in this fleet at the end of its assignments.

FleetUpdateHandle &accept_task_requests(AcceptTaskRequest check)

Provide a callback that indicates whether this fleet will accept a BidNotice request. By default all requests will be rejected.

Note

The callback function that you give should ideally be non-blocking and return quickly. It’s meant to check whether this fleet’s vehicles are compatible with the requested payload, pickup, and dropoff behavior settings. The path planning feasibility will be taken care of by the adapter internally.

FleetUpdateHandle &accept_delivery_requests(AcceptDeliveryRequest check)

Provide a callback that indicates whether this fleet will accept a delivery request. By default all delivery requests will be rejected.

Note

The callback function that you give should ideally be non-blocking and return quickly. It’s meant to check whether this fleet’s vehicles are compatible with the requested payload, pickup, and dropoff behavior settings. The path planning feasibility will be taken care of by the adapter internally.

FleetUpdateHandle &default_maximum_delay(std::optional<rmf_traffic::Duration> value)

Specify the default value for how high the delay of the current itinerary can become before it gets interrupted and replanned. A nullopt value will allow for an arbitrarily long delay to build up without being interrupted.

std::optional<rmf_traffic::Duration> default_maximum_delay() const

Get the default value for the maximum acceptable delay.

FleetUpdateHandle &fleet_state_publish_period(std::optional<rmf_traffic::Duration> value)

The behavior is identical to fleet_state_topic_publish_period.

FleetUpdateHandle &fleet_state_topic_publish_period(std::optional<rmf_traffic::Duration> value)

Specify a period for how often the fleet state message is published for this fleet. Passing in std::nullopt will disable the fleet state message publishing. The default value is 1s.

FleetUpdateHandle &fleet_state_update_period(std::optional<rmf_traffic::Duration> value)

Specify a period for how often the fleet state is updated in the database and to the API server. This is separate from publishing the fleet state over the ROS2 fleet state topic. Passing in std::nullopt will disable the updating, but this is not recommended unless you intend to provide the API server with the fleet states through some other means.

The default value is 1s.

FleetUpdateHandle(FleetUpdateHandle&&) = delete
FleetUpdateHandle &operator=(FleetUpdateHandle&&) = delete
class Confirmation

Confirmation is a class used by the task acceptance callbacks to decide if a task description should be accepted.

Public Functions

Confirmation()

Constructor.

Confirmation &accept()

Call this function to decide that you want to accept the task request. If this function is never called, it will be assumed that the task is rejected.

bool is_accepted() const

Check whether.

Confirmation &errors(std::vector<std::string> error_messages)

Call this function to bring attention to errors related to the task request. Each call to this function will overwrite any past calls, so it is recommended to only call it once.

Confirmation &add_errors(std::vector<std::string> error_messages)

Call this function to add errors instead of overwriting the ones that were already there.

const std::vector<std::string> &errors() const

Check the errors that have been given to this confirmation.