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

Flexible task definitions #39

Merged
merged 88 commits into from
Feb 13, 2022
Merged
Changes from 1 commit
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
29f3b8c
Remove agv namespace and introduce CompositeData
mxgrey Sep 1, 2021
2ea66b5
Redesign State to be composable
mxgrey Sep 2, 2021
b181017
Defining task execution interfaces
mxgrey Sep 2, 2021
096ae8a
Adding a task logging interface
mxgrey Sep 3, 2021
86c3c13
Drafting the interfaces for phase sequence tasks
mxgrey Sep 3, 2021
e00b02c
Satisfy uncrustify
mxgrey Sep 3, 2021
7a7d7d3
Draft interface for Task Factory
mxgrey Sep 3, 2021
15aac52
Rework the design, improve consistency
mxgrey Sep 6, 2021
873693a
Satisfy uncrustify
mxgrey Sep 6, 2021
67f9398
Beginning to implement GoToPlace::Description
mxgrey Sep 6, 2021
68f2fda
Redesigning travel estimation cache
mxgrey Sep 7, 2021
1707f4f
Redesigning travel estimation
mxgrey Sep 7, 2021
45d62a6
Prototyping PickUp phase
mxgrey Sep 8, 2021
81380c8
Finish implementation of PickUp and begin API of DropOff
mxgrey Sep 9, 2021
21054b9
Implementing DropOff phase
mxgrey Sep 10, 2021
3b83b5d
Reorganizing
mxgrey Sep 10, 2021
7c31994
More reorganization
mxgrey Sep 10, 2021
9103c90
Gradually ironing out the transition to the reorganization
mxgrey Sep 10, 2021
66777a8
Continuing implementation of phase sequence task
mxgrey Sep 11, 2021
820cc33
Thinking about how to implement backups for phase sequence tasks
mxgrey Sep 13, 2021
5e14e82
Work reactive backup callbacks into the system
mxgrey Sep 13, 2021
e330d36
Creating minimal example of task activation
mxgrey Sep 13, 2021
d2911aa
Create minimal example of task restoring
mxgrey Sep 14, 2021
3505ac0
Use derived class implementation of backup
mxgrey Sep 14, 2021
724eb0a
Finish comment
mxgrey Sep 14, 2021
ecbe258
Creating an integration test to guide the implementation of backups
mxgrey Sep 14, 2021
37830d5
Move backups test into integration folder
mxgrey Sep 14, 2021
56c1f40
Continuing to implement backup and restore for phase sequence tasks
mxgrey Sep 23, 2021
ed651ae
Finished backup/restore implementation -- needs testing
mxgrey Sep 24, 2021
e1c2d51
Implementing phase activator
mxgrey Sep 24, 2021
3995281
Migrating to JSON and json-schema
mxgrey Oct 6, 2021
e2116b0
Fix header guards and begin schema header template
mxgrey Oct 6, 2021
8c2844f
Working on the generation of schema headers
mxgrey Oct 7, 2021
0615abf
Update transitive dependency
mxgrey Oct 7, 2021
973b387
Merge branch 'redesign_v2' of ssh://github.com/open-rmf/rmf_task into…
mxgrey Oct 7, 2021
05b4754
Able to generate schemas
mxgrey Oct 7, 2021
d730e02
Reimplement backups using json
mxgrey Oct 7, 2021
ae6c0c7
Include original message in error log
mxgrey Oct 11, 2021
d744b63
Put active phase snapshots into completed phases
mxgrey Oct 12, 2021
eab243b
Iterating on RestoreBackup phase
mxgrey Oct 13, 2021
cc329cf
Implement backup file manager (#41)
cnboonhan Oct 14, 2021
76ec880
Fix merge conflicts
mxgrey Oct 14, 2021
a7b3bc4
Rename Condition to Event
mxgrey Oct 14, 2021
7aee6bc
Introducing VersionedString and using it for event names + details
mxgrey Oct 15, 2021
fbb2160
Implementing the SimpleEvent class
mxgrey Oct 15, 2021
f1d3f62
Migrate to using the RestoreBackup phase
mxgrey Oct 18, 2021
6b46765
Abstracting Phase and Event interfaces into Activity
mxgrey Oct 18, 2021
cfb1e90
Finish refactoring to introduce Activity class namespace
mxgrey Oct 20, 2021
0611526
Remove the GoToPlace phase in favor of GoToPlace event
mxgrey Oct 20, 2021
d19c7ad
Remember to include <string>
mxgrey Oct 21, 2021
7d8db73
Use a const reference for pending tasks
mxgrey Oct 21, 2021
11831e0
Remember to include <string> pt. 2
mxgrey Oct 21, 2021
c720ffb
Refactoring Event to State, Standby, and Active, and implementing Eve…
mxgrey Nov 1, 2021
390f5a4
Implementing Event Sequence Standby
mxgrey Nov 1, 2021
54765af
Implementing the Event Sequence class
mxgrey Nov 3, 2021
036867b
Define the schema for event sequence backups
mxgrey Nov 3, 2021
eaf95ea
Finished implementing event sequence
mxgrey Nov 6, 2021
56ec2a2
Refactoring Sequence into a more generic Bundle
mxgrey Nov 6, 2021
cb5619c
Migrating schema header generation to rmf_api_msgs
mxgrey Nov 10, 2021
df57b7f
Add some conceptual sample schemas for task descriptions
mxgrey Nov 10, 2021
a0e39f7
Move schemas into subdirectory
mxgrey Nov 24, 2021
2108d42
Merge branch 'redesign_v2_task_schemas' into redesign_v2_Bundle
mxgrey Nov 24, 2021
3610da5
tweaks
mxgrey Nov 30, 2021
10fd78a
Refactor Sequence into Bundle
mxgrey Dec 7, 2021
2314e14
Filling in implementation gaps and beginning task sequence test
mxgrey Dec 8, 2021
1dd1659
Fix implementation bugs and begin unit tests for task sequences
mxgrey Dec 9, 2021
d11032e
Allow event bundles to be activated from a vector of Standbys
mxgrey Dec 14, 2021
cc8bf3d
Allow users to directly create Bundle Standbys, not Actives
mxgrey Dec 14, 2021
7420e52
Implement unfolding for tasks and events
mxgrey Dec 16, 2021
9842bd9
Remember to include implementation header
mxgrey Dec 16, 2021
0112e25
Make activate and restore const
mxgrey Dec 17, 2021
070e864
Add sequence numbers to logs and fix log iteration
mxgrey Dec 20, 2021
3aef75f
Add plain text info for task descriptions
mxgrey Dec 21, 2021
416503d
Handle cases with no ambient drain
mxgrey Dec 22, 2021
f05dda0
Create a Placeholder event to help eliminate boilerplate
mxgrey Dec 22, 2021
9fbd9d4
Fix circular reference
mxgrey Dec 31, 2021
113b671
Return more specific Clean Description
mxgrey Jan 9, 2022
c6b9ed4
fix empty itinerary duration
youliangtan Jan 18, 2022
c4d17fb
PerformAction Event Description (#49)
Yadunund Jan 20, 2022
dc4bbdb
nit rosdep json pkg name
youliangtan Jan 26, 2022
b783c18
Fix segfaults with PerformAction (#51)
Yadunund Jan 27, 2022
8195e4b
Use ament_uncrustify
Yadunund Jan 28, 2022
75b5f93
compile tests (#52)
xiyuoh Jan 28, 2022
ec67d50
Report the active phase's start time
mxgrey Feb 10, 2022
a895149
Merge branch 'main' into redesign_v2
mxgrey Feb 12, 2022
a8f63f0
Update repos
mxgrey Feb 12, 2022
a9b6ec6
Merge branch 'redesign_v2' of ssh://github.com/open-rmf/rmf_task into…
mxgrey Feb 12, 2022
956cf5b
Satisfy uncrustify
mxgrey Feb 12, 2022
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
Prev Previous commit
Next Next commit
Rework the design, improve consistency
Signed-off-by: Michael X. Grey <[email protected]>
mxgrey committed Sep 6, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 15aac52166a3ac8be5b76ce5b2c47c3f006804ac
65 changes: 55 additions & 10 deletions rmf_task/include/rmf_task/Request.hpp
Original file line number Diff line number Diff line change
@@ -36,6 +36,49 @@ namespace rmf_task {
class Request
{
public:

class Tag
{
public:

/// Constructor
///
/// \param[in] id_
/// The identify of the request
///
/// \param[in] earliest_start_time_
/// The earliest time that the request may begin
///
/// \param[in] priority_
/// The priority of the request
///
/// \param[in] automatic_
/// Whether this request was automatically generated
Tag(
std::string id_,
rmf_traffic::Time earliest_start_time_,
ConstPriorityPtr priority_,
bool automatic_ = false);

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

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

/// Get the priority of this request
ConstPriorityPtr priority() const;

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

class Implementation;
private:
rmf_utils::impl_ptr<Implementation> _pimpl;
};

using ConstTagPtr = std::shared_ptr<const Tag>;

/// An abstract interface for computing the estimate and invariant durations
/// of this request
class Model
@@ -95,28 +138,30 @@ class Request
///
/// \param[in] automatic
/// True if this request is auto-generated
//
// TODO(MXG): Deprecate this constructor?
Request(
const std::string& id,
rmf_traffic::Time earliest_start_time,
ConstPriorityPtr priority,
ConstDescriptionPtr description,
bool automatic = false);

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

/// Get the earliest time that this request may begin
rmf_traffic::Time earliest_start_time() const;
/// Constructor
///
/// \param[in] tag
/// Tag of the request
///
/// \param[in] description
/// Description for this request
Request(ConstTagPtr tag, ConstDescriptionPtr description);

/// Get the priority of this request
ConstPriorityPtr priority() const;
/// Get the tag of this request
const ConstTagPtr& tag() const;

/// Get the description of this request
const ConstDescriptionPtr& description() const;

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

class Implementation;
private:
rmf_utils::impl_ptr<Implementation> _pimpl;
42 changes: 42 additions & 0 deletions rmf_task/include/rmf_task/detail/Resume.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (C) 2021 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#ifndef RMF_TASK__DETAIL__RESUME_HPP
#define RMF_TASK__DETAIL__RESUME_HPP

#include <rmf_utils/impl_ptr.hpp>

namespace rmf_task {
namespace detail {

//==============================================================================
class Resume
{
public:

/// Call this object to tell the Task to resume.
void operator()() const;

class Implementation;
private:
rmf_utils::unique_impl_ptr<Implementation> _pimpl;
};

} // namespace detail
} // namespace rmf_task

#endif // RMF_TASK__DETAIL__RESUME_HPP
92 changes: 78 additions & 14 deletions rmf_task/include/rmf_task/execute/Phase.hpp
Original file line number Diff line number Diff line change
@@ -30,16 +30,64 @@ namespace rmf_task {
namespace execute {

//==============================================================================
class CompletedPhase
class Phase
{
public:

class Tag;
using ConstTagPtr = std::shared_ptr<const Tag>;

class Completed;
using ConstCompletedPtr = std::shared_ptr<const Completed>;

class Active;
using ConstActivePtr = std::shared_ptr<const Active>;

class Snapshot;
using ConstSnapshotPtr = std::shared_ptr<const Snapshot>;

class Pending;
using ConstPendingPtr = std::shared_ptr<const Pending>;
};

//==============================================================================
/// Basic static information about a phase. This information should go
/// unchanged from the Pending state, through the Active state, and into the
/// Completed state.
class Phase::Tag
{
public:

/// Name of the phase
const std::string& name() const;

/// Details about the phase
const std::string& detail() const;

/// The original (ideal) estimate of how long the phase will last
rmf_traffic::Duration original_duration_estimate() const;

class Implementation;
private:
rmf_utils::impl_ptr<Implementation> _pimpl;
};

//==============================================================================
/// Information about a phase that has been completed.
class Phase::Completed
{
public:

/// Tag of the phase
const ConstTagPtr& tag() const;

/// The final log of the phase
const Log::View& log() const;

/// The actual time that the phase started
rmf_traffic::Time start_time() const;
rmf_traffic::Time original_finish_estimate() const;

/// The actual time that the phase finished.
rmf_traffic::Time finish_time() const;

class Implementation;
@@ -48,15 +96,12 @@ class CompletedPhase
};

//==============================================================================
class ActivePhase
class Phase::Active
{
public:

/// The name of this phase.
virtual std::string name() const = 0;

/// Details about this phase
virtual std::string detail() const = 0;
/// Tag of the phase
virtual ConstTagPtr tag() const = 0;

/// The condition that needs to be satisfied for this phase to be complete
virtual ConstConditionPtr finish_condition() const = 0;
@@ -65,19 +110,38 @@ class ActivePhase
virtual rmf_traffic::Time estimate_finish_time() const = 0;

// Virtual destructor
virtual ~ActivePhase() = default;
virtual ~Active() = default;
};

using ConstActivePhasePtr = std::shared_ptr<const ActivePhase>;
//==============================================================================
class Phase::Snapshot : public Phase::Active
{
public:

/// Make a snapshot of an Active phase
static ConstSnapshotPtr make(const Active& active);

// Documentation inherited
ConstTagPtr tag() const final;

// Documentation inherited
ConstConditionPtr finish_condition() const final;

// Documentation inherited
rmf_traffic::Time estimate_finish_time() const final;

class Implementation;
private:
rmf_utils::impl_ptr<Implementation> _pimpl;
};

//==============================================================================
class PendingPhase
class Phase::Pending
{
public:

const std::string& name() const;
const std::string& detail() const;
rmf_traffic::Duration duration_estimate() const;
/// Tag of the phase
const ConstTagPtr& tag() const;

class Implementation;
private:
64 changes: 35 additions & 29 deletions rmf_task/include/rmf_task/execute/Task.hpp
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
#define RMF_TASK__EXECUTE__TASK_HPP

#include <rmf_task/execute/Phase.hpp>
#include <rmf_task/detail/Resume.hpp>
#include <rmf_task/Request.hpp>

#include <memory>
@@ -33,44 +34,48 @@ class Task
{
public:

/// Descriptions of the phases that have been completed
virtual const std::vector<CompletedPhase>& completed_phases() const = 0;
/// Basic static information about the task.
class Tag
{
public:

/// Interface for the phase that is currently active
virtual ConstActivePhasePtr active_phase() const = 0;
/// The original request that this Task is carrying out
const Request::ConstTagPtr& request() const;

/// Descriptions of the phases that are expected in the future
virtual std::vector<PendingPhase> pending_phases() const = 0;
/// The category of this Task.
const std::string& category() const;

/// Details about this Task.
const std::string& detail() const;

/// The original finish estimate of this Task.
rmf_traffic::Time original_finish_estimate() const;

class Implementation;
private:
rmf_utils::impl_ptr<Implementation> _pimpl;
};

/// The ID of this Task
virtual std::string id() const = 0;
/// Descriptions of the phases that have been completed
virtual const std::vector<Phase::ConstCompletedPtr>&
completed_phases() const = 0;

/// The category of this Task
virtual std::string category() const = 0;
/// Interface for the phase that is currently active
virtual Phase::ConstActivePtr active_phase() const = 0;

/// Human-readable details about this task
virtual std::string detail() const = 0;
/// Descriptions of the phases that are expected in the future
virtual std::vector<Phase::Pending> pending_phases() const = 0;

/// The original task Request that spawned this Task
virtual const Request& original_request() const = 0;
/// The request tag of this Task
virtual const Request::ConstTagPtr& tag() const = 0;

/// Estimate the overall finishing time of the task
virtual rmf_traffic::Time estimate_finish_time() const = 0;

/// The Resume class keeps track of when the Task is allowed to Resume.
/// You can either call the object's operator() or let the object expire to
/// tell the Task that it may resume.
class Resume
{
public:

/// Call this object to tell the Task to resume.
void operator()() const;

class Implementation;
private:
rmf_utils::unique_impl_ptr<Implementation> _pimpl;
};
/// You can either call the Resume object's operator() or let the object
/// expire to tell the Task that it may resume.
class Resume : public detail::Resume {};

/// Tell this Task that it needs to be interrupted. An interruption means
/// the robot may be commanded to do other tasks before this task resumes.
@@ -107,10 +112,11 @@ class Task

/// Kill this Task. The behavior that follows a kill will vary between
/// different Tasks, but generally it means that the robot should be returned
/// to safe idle state as soon as possible, even if it remains encumbered by
/// to a safe idle state as soon as possible, even if it remains encumbered by
/// something related to this Task.
///
/// The finished callback will be triggered when the Task is fully killed.
/// The Task should continue to be tracked as normal. When its finished
/// callback is triggered, the killing is complete.
///
/// The kill() command supersedes the cancel() command. Calling cancel() after
/// calling kill() will have no effect.
2 changes: 1 addition & 1 deletion rmf_task/include/rmf_task/execute/TaskFactory.hpp
Original file line number Diff line number Diff line change
@@ -57,7 +57,7 @@ class TaskFactory
using Activate =
std::function<
execute::ConstTaskPtr(
const Request& request,
const Request::ConstTagPtr& request,
const Description& description,
std::function<void(ConstConditionPtr)> update,
std::function<void(ConstConditionPtr)> finished)
Loading