Class Writer

Nested Relationships

Nested Types

Inheritance Relationships

Derived Type

Class Documentation

class Writer

A pure abstract interface class that defines an API for writing to the schedule database. This API is implemented by the Database class, but it should also be implemented for any middleware that intends to have a schedule participant write changes to a remote database.

Subclassed by rmf_traffic::schedule::Database

Public Types

using ParticipantId = rmf_traffic::schedule::ParticipantId
using ParticipantDescription = rmf_traffic::schedule::ParticipantDescription
using Itinerary = rmf_traffic::schedule::Itinerary
using ItineraryVersion = rmf_traffic::schedule::ItineraryVersion
using ProgressVersion = rmf_traffic::schedule::ProgressVersion
using PlanId = rmf_traffic::PlanId
using Duration = rmf_traffic::Duration
using RouteId = rmf_traffic::RouteId
using CheckpointId = rmf_traffic::CheckpointId
using StorageId = uint64_t

Public Functions

virtual void set(ParticipantId participant, PlanId plan, const Itinerary &itinerary, StorageId storage_base, ItineraryVersion version) = 0

Set a brand new itinerary for a participant. This will replace any itinerary that is already in the schedule for the participant.

Parameters:
  • participant[in] The ID of the participant whose itinerary is being updated.

  • plan[in] The ID of the plan that this new itinerary belongs to.

  • itinerary[in] The new itinerary of the participant.

  • storage_base[in] The storage index offset that the database should use for this plan. This should generally be the integer number of total routes that the participant has ever given to the writer prior to setting this new itinerary. This value helps ensure consistent unique IDs for every route, even after a database has failed over or restarted.

  • version[in] The version for this itinerary change.

virtual void extend(ParticipantId participant, const Itinerary &routes, ItineraryVersion version) = 0

Add a set of routes to the itinerary of this participant.

Parameters:
  • participant[in] The ID of the participant whose itinerary is being updated.

  • routes[in] The set of routes that should be added to the itinerary.

  • version[in] The version for this itinerary change

virtual void delay(ParticipantId participant, Duration delay, ItineraryVersion version) = 0

Add a delay to the itinerary from the specified Time.

Nothing about the routes in the itinerary will be changed except that waypoints will shifted through time.

Parameters:
  • participant[in] The ID of the participant whose itinerary is being delayed.

  • delay[in] This is the duration of time to delay all qualifying Trajectory Waypoints.

  • version[in] The version for this itinerary change

virtual void reached(ParticipantId participant, PlanId plan, const std::vector<CheckpointId> &reached_checkpoints, ProgressVersion version) = 0

Indicate that a participant has reached certain checkpoints.

Parameters:
  • participant[in] The ID of the participant whose progress is being set.

  • plan[in] The ID of the plan which progress has been made for.

  • reached_checkpoints[in] The set of checkpoints that have been reached. The indices in the vector must correspond to the RouteIds of the plan.

  • version[in] The version number for this progress.

virtual void clear(ParticipantId participant, ItineraryVersion version) = 0

Erase an itinerary from this database.

Parameters:
  • participant[in] The ID of the participant whose itinerary is being erased.

  • version[in] The version for this itinerary change

virtual Registration register_participant(ParticipantDescription participant_info) = 0

Register a new participant.

Parameters:
  • participant_info[in] Information about the new participant.

  • time[in] The time at which the registration is being requested.

Returns:

result of registering the new participant.

virtual void unregister_participant(ParticipantId participant) = 0

Unregister an existing participant.

Parameters:

participant[in] The ID of the participant to unregister.

Returns:

the new version of the schedule.

virtual void update_description(ParticipantId participant, ParticipantDescription desc) = 0

Updates a participants footprint

Parameters:
  • participant[in] The ID of the participant to update

  • desc[in] The participant description

virtual ~Writer() = default
class Registration

Information resulting from registering a participant.

Public Functions

Registration(ParticipantId id, ItineraryVersion version, PlanId plan_id, StorageId storage_base)

Constructor

Parameters:
  • id[in] The ID for the registered participant

  • version[in] The last itinerary version for the registered participant

  • plan_id[in] The last plan_id for the registered participant

  • storage_base[in] The next storage base that the registered participant should use

ParticipantId id() const

The ID of the registered participant.

ItineraryVersion last_itinerary_version() const

The last itinerary version of the registered participant. New Participants will begin by adding up from this version when issuing schedule updates.

This value might vary for systems that enforce participant uniqueness. If this participant was registered in the past and is now being re-registered, then the version number will pick up where it previously left off.

PlanId last_plan_id() const

The last Route ID of the registered participant. New Participants will begin by adding up from this Route ID when issuing new schedule updates.

Similar to last_itinerary_version, this value might vary for systems that enforce participant uniqueness.

StorageId next_storage_base() const

The next storage base that the participant should use.