Skip to content

Commit

Permalink
Task request time and initiator in Booking (#81)
Browse files Browse the repository at this point in the history
* Fixed missing constructor implementation, commented to deprecate next time, new booking constructor

Signed-off-by: Aaron Chong <[email protected]>

* Add requester to factories, add request time and initiator to ChargeBattery and Loop

Signed-off-by: Aaron Chong <[email protected]>

* Using requester instead of initiator, added new make API to legacy Clean and Deliver

Signed-off-by: Aaron Chong <[email protected]>

* lint

Signed-off-by: Aaron Chong <[email protected]>

* Revert to original constructor with optional arguments appended, propagated changes to all constructors and make functions

Signed-off-by: Aaron Chong <[email protected]>

* Move description into booking, lint

Signed-off-by: Aaron Chong <[email protected]>

* Pass a clock functor to ParkRobotFactory

Signed-off-by: Aaron Chong <[email protected]>

* Using non-deprecated Request constructor

Signed-off-by: Aaron Chong <[email protected]>

* new make_request API to include requester and request time

Signed-off-by: Aaron Chong <[email protected]>

* Overload TaskPlanner constructor with a name argument

Signed-off-by: Aaron Chong <[email protected]>

* Retained old API and marked as deprecated

Signed-off-by: Aaron Chong <[email protected]>

* Overloading booking instead of adding default arguments

Signed-off-by: Aaron Chong <[email protected]>

* Overloading all affected functions with non optional arguments

Signed-off-by: Aaron Chong <[email protected]>

* Lint

Signed-off-by: Aaron Chong <[email protected]>

* Revert deprecation tag on Request, to be done in a separate PR

Signed-off-by: Aaron Chong <[email protected]>

* Argument name changes, linting, documentation

Signed-off-by: Aaron Chong <[email protected]>

* TaskPlanner constructor to have planner id as first argument

Signed-off-by: Aaron Chong <[email protected]>

* request factories to accept a callback that returns the current time

Signed-off-by: Aaron Chong <[email protected]>

---------

Signed-off-by: Aaron Chong <[email protected]>
(cherry picked from commit a7875a9)
Signed-off-by: Aaron Chong <[email protected]>
  • Loading branch information
aaronchongth committed Jun 16, 2023
1 parent f59c07d commit f9c01c1
Show file tree
Hide file tree
Showing 21 changed files with 621 additions and 79 deletions.
9 changes: 6 additions & 3 deletions rmf_task/include/rmf_task/RequestFactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ class RequestFactory
public:

/// Generate a request for the AGV given the state that the robot will have
/// when it is ready to perform the request
virtual ConstRequestPtr make_request(
const State& state) const = 0;
/// when it is ready to perform the request.
///
/// \param[in] state
/// The state that the robot will have when it is ready to perform the
/// request.
virtual ConstRequestPtr make_request(const State& state) const = 0;

virtual ~RequestFactory() = default;
};
Expand Down
61 changes: 49 additions & 12 deletions rmf_task/include/rmf_task/Task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <rmf_traffic/Time.hpp>

#include <memory>
#include <optional>
#include <functional>

namespace rmf_task {
Expand Down Expand Up @@ -67,33 +68,69 @@ class Task::Booking

/// Constructor
///
/// \param[in] id_
/// \param[in] id
/// The identity of the booking
///
/// \param[in] earliest_start_time_
/// \param[in] earliest_start_time
/// The earliest time that the task may begin
///
/// \param[in] priority_
/// \param[in] priority
/// The priority of the booking
///
/// \param[in] automatic_
/// \param[in] automatic
/// Whether this booking was automatically generated
Booking(
std::string id_,
rmf_traffic::Time earliest_start_time_,
ConstPriorityPtr priority_,
bool automatic_ = false);
std::string id,
rmf_traffic::Time earliest_start_time,
ConstPriorityPtr priority,
bool automatic = false);

/// The unique id for this booking
/// Constructor
///
/// \param[in] id
/// The identity of the booking.
///
/// \param[in] earliest_start_time
/// The earliest time that the task may begin.
///
/// \param[in] priority
/// The priority of the booking.
///
/// \param[in] requester
/// The identifier of the entity that requested this task.
///
/// \param[in] request_time
/// The time that this task was booked.
///
/// \param[in] automatic
/// Whether this booking was automatically generated, default value as
/// false.
Booking(
std::string id,
rmf_traffic::Time earliest_start_time,
ConstPriorityPtr priority,
const std::string& requester,
rmf_traffic::Time request_time,
bool automatic = false);

/// The unique id for this booking.
const std::string& id() const;

/// Get the earliest time that this booking may begin
/// Get the earliest time that this booking may begin.
rmf_traffic::Time earliest_start_time() const;

/// Get the priority of this booking
/// Get the priority of this booking.
ConstPriorityPtr priority() const;

// Returns true if this booking was automatically generated
/// Get the identifier of the entity that requested this booking. Returns a
/// nullopt if no requester was defined.
std::optional<std::string> requester() const;

/// Get the time that this booking was requested. Returns a nullopt if no
/// request time was defined.
std::optional<rmf_traffic::Time> request_time() const;

// Returns true if this booking was automatically generated.
bool automatic() const;

class Implementation;
Expand Down
17 changes: 17 additions & 0 deletions rmf_task/include/rmf_task/TaskPlanner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,23 @@ class TaskPlanner
Configuration configuration,
Options default_options);

/// Constructor
///
/// \param[in] planner_id
/// Identifier of this task planner, to be used for booking automated
/// requests.
///
/// \param[in] configuration
/// The configuration for the planner.
///
/// \param[in] default_options
/// Default options for the task planner to use when solving for assignments.
/// These options can be overriden each time a plan is requested.
TaskPlanner(
const std::string& planner_id,
Configuration configuration,
Options default_options);

/// Get a const reference to configuration of this task planner
const Configuration& configuration() const;

Expand Down
23 changes: 23 additions & 0 deletions rmf_task/include/rmf_task/requests/ChargeBattery.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,29 @@ class ChargeBattery
rmf_traffic::Time earliest_start_time,
ConstPriorityPtr priority = nullptr,
bool automatic = true);

/// Generate a chargebattery request.
///
/// \param[in] earliest_start_time
/// The desired start time for this request.
///
/// \param[in] requester
/// The entity that issued this request.
///
/// \param[in] request_time
/// The time this request was generated or submitted.
///
/// \param[in] priority
/// The priority for this request.
///
/// \param[in] automatic
/// True if this request is auto-generated, default value as true.
static ConstRequestPtr make(
rmf_traffic::Time earliest_start_time,
const std::string& requester,
rmf_traffic::Time request_time,
ConstPriorityPtr priority = nullptr,
bool automatic = true);
};

} // namespace requests
Expand Down
24 changes: 21 additions & 3 deletions rmf_task/include/rmf_task/requests/ChargeBatteryFactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@
#ifndef RMF_TASK__REQUESTS__FACTORY__CHARGEBATTERYFACTORY_HPP
#define RMF_TASK__REQUESTS__FACTORY__CHARGEBATTERYFACTORY_HPP

#include <functional>
#include <optional>
#include <string>

#include <rmf_task/RequestFactory.hpp>
#include <rmf_task/State.hpp>
#include <rmf_traffic/Time.hpp>

#include <rmf_utils/impl_ptr.hpp>

Expand All @@ -30,16 +35,29 @@ namespace requests {
/// The ChargeBatteryFactory will generate a ChargeBattery request which
/// requires an AGV to return to its desginated charging_waypoint as specified
/// in its agv::State and wait till its battery charges up to the recharge_soc
/// confugred in agv::Constraints recharge_soc specified in its agv::Constraints
/// configured in agv::Constraints recharge_soc specified in its
/// agv::Constraints
class ChargeBatteryFactory : public RequestFactory
{
public:

/// Constructor
ChargeBatteryFactory();

/// Constructor
///
/// \param[in] requester
/// The identifier of the entity that owns this RequestFactory, that will be
/// the designated requester of each new request.
///
/// \param[in] time_now_cb
/// Callback function that returns the current time.
explicit ChargeBatteryFactory(
const std::string& requester,
std::function<rmf_traffic::Time()> time_now_cb);

/// Documentation inherited
ConstRequestPtr make_request(
const State& state) const final;
ConstRequestPtr make_request(const State& state) const final;

class Implementation;

Expand Down
43 changes: 43 additions & 0 deletions rmf_task/include/rmf_task/requests/Clean.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,49 @@ class Clean
rmf_traffic::Time earliest_start_time,
ConstPriorityPtr priority = nullptr,
bool automatic = false);

/// Generate a clean request.
///
/// \param[in] start_waypoint
/// The graph index for the location where the AGV should begin its cleaning
/// operation.
///
/// \param[in] end_waypoint
/// The graph index for the location where the AGV ends up after its cleaning
/// operation.
///
/// \param[in] cleaning_path
/// A trajectory that describes the motion of the AGV during the cleaning
/// operation. This is used to determine the process duration and expected
/// battery drain.
///
/// \param[in] id
/// A unique id for this request.
///
/// \param[in] earliest_start_time
/// The desired start time for this request.
///
/// \param[in] requester
/// The entity that issued this request.
///
/// \param[in] request_time
/// The time this request was generated or submitted.
///
/// \param[in] priority
/// The priority for this request.
///
/// \param[in] automatic
/// True if this request is auto-generated, default value as false.
static ConstRequestPtr make(
std::size_t start_waypoint,
std::size_t end_waypoint,
const rmf_traffic::Trajectory& cleaning_path,
const std::string& id,
rmf_traffic::Time earliest_start_time,
const std::string& requester,
rmf_traffic::Time request_time,
ConstPriorityPtr priority = nullptr,
bool automatic = false);
};

} // namespace requests
Expand Down
56 changes: 56 additions & 0 deletions rmf_task/include/rmf_task/requests/Delivery.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,62 @@ class Delivery
bool automatic = false,
std::string pickup_from_dispenser = "",
std::string dropoff_to_ingestor = "");

/// Generate a delivery request.
///
/// \param[in] pickup_waypoint
/// The graph index for the pickup location.
///
/// \param[in] pickup_wait
/// The expected duration the AGV has to wait at the pickup location for
/// the items to be loaded.
///
/// \param[in] dropoff_waypoint
/// The graph index for the dropoff location.
///
/// \param[in] dropoff_wait
/// The expected duration the AGV has to wait at the dropoff location for
/// the items to be unloaded.
///
/// \param[in] id
/// A unique id for this request.
///
/// \param[in] earliest_start_time
/// The desired start time for this request.
///
/// \param[in] requester
/// The entity that issued this request.
///
/// \param[in] request_time
/// The time this request was generated or submitted.
///
/// \param[in] priority
/// The priority for this request.
///
/// \param[in] automatic
/// True if this request is auto-generated, default value as false.
///
/// \param[in] pickup_from_dispenser
/// The name of the dispenser to pick up the delivery item from, at the
/// designated pickup waypoint. This field is optional.
///
/// \param[in] dropoff_to_ingestor
/// The name of the ingestor to drop off the delivery item to, at the
/// designated dropoff waypoint. This field is optional.
static ConstRequestPtr make(
std::size_t pickup_waypoint,
rmf_traffic::Duration pickup_wait,
std::size_t dropoff_waypoint,
rmf_traffic::Duration dropoff_wait,
Payload payload,
const std::string& id,
rmf_traffic::Time earliest_start_time,
const std::string& requester,
rmf_traffic::Time request_time,
ConstPriorityPtr priority = nullptr,
bool automatic = false,
std::string pickup_from_dispenser = "",
std::string dropoff_to_ingestor = "");
};

} // namespace requests
Expand Down
40 changes: 40 additions & 0 deletions rmf_task/include/rmf_task/requests/Loop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,46 @@ class Loop
rmf_traffic::Time earliest_start_time,
ConstPriorityPtr priority = nullptr,
bool automatic = false);

/// Generate a loop request.
///
/// \param[in] start_waypoint
/// The graph index for the starting waypoint of the loop.
///
/// \param[in] finish_waypoint
/// The graph index for the finishing waypoint of the loop.
///
/// \param[in] num_loops
/// The number of times the AGV should loop between the start_waypoint and
/// finish_waypoint.
///
/// \param[in] id
/// A unique id for this request.
///
/// \param[in] earliest_start_time
/// The desired start time for this request.
///
/// \param[in] requester
/// The entity that issued this request.
///
/// \param[in] request_time
/// The time this request was generated or submitted.
///
/// \param[in] priority
/// The priority for this request.
///
/// \param[in] automatic
/// True if this request is auto-generated, default as false.
static ConstRequestPtr make(
std::size_t start_waypoint,
std::size_t finish_waypoint,
std::size_t num_loops,
const std::string& id,
rmf_traffic::Time earliest_start_time,
const std::string& requester,
rmf_traffic::Time request_time,
ConstPriorityPtr priority = nullptr,
bool automatic = false);
};

} // namespace tasks
Expand Down
Loading

0 comments on commit f9c01c1

Please sign in to comment.