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

Task request time and initiator in Booking #81

Merged
merged 18 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
04d30f2
Fixed missing constructor implementation, commented to deprecate next…
aaronchongth Apr 16, 2023
85b6d88
Add requester to factories, add request time and initiator to ChargeB…
aaronchongth May 9, 2023
46c7520
Using requester instead of initiator, added new make API to legacy Cl…
aaronchongth May 9, 2023
d727898
lint
aaronchongth May 9, 2023
c702c9b
Revert to original constructor with optional arguments appended, prop…
aaronchongth May 31, 2023
80518e4
Move description into booking, lint
aaronchongth May 31, 2023
3a87fc9
Pass a clock functor to ParkRobotFactory
aaronchongth Jun 1, 2023
c4fe0a9
Using non-deprecated Request constructor
aaronchongth Jun 1, 2023
9911e73
new make_request API to include requester and request time
aaronchongth Jun 1, 2023
4567762
Overload TaskPlanner constructor with a name argument
aaronchongth Jun 1, 2023
14e1e1c
Retained old API and marked as deprecated
aaronchongth Jun 1, 2023
e6e0a7e
Overloading booking instead of adding default arguments
aaronchongth Jun 12, 2023
cfd63bb
Overloading all affected functions with non optional arguments
aaronchongth Jun 12, 2023
4df00c6
Lint
aaronchongth Jun 12, 2023
2c29ba0
Revert deprecation tag on Request, to be done in a separate PR
aaronchongth Jun 13, 2023
0370e5a
Argument name changes, linting, documentation
aaronchongth Jun 14, 2023
5029715
TaskPlanner constructor to have planner id as first argument
aaronchongth Jun 14, 2023
ff5f0ec
request factories to accept a callback that returns the current time
aaronchongth Jun 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Yadunund marked this conversation as resolved.
Show resolved Hide resolved
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;
aaronchongth marked this conversation as resolved.
Show resolved Hide resolved

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