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

Feature/finishing task #28

Merged
merged 14 commits into from
Aug 31, 2021
1 change: 1 addition & 0 deletions rmf_task/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ find_package(rmf_cmake_uncrustify QUIET)
file(GLOB lib_srcs
"src/rmf_task/agv/*.cpp"
"src/rmf_task/requests/*.cpp"
"src/rmf_task/requests/factory/*.cpp"
"src/rmf_task/*.cpp"
)

Expand Down
10 changes: 7 additions & 3 deletions rmf_task/include/rmf_task/Request.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*
*/

#ifndef RMF_TASK__TASK_HPP
#define RMF_TASK__TASK_HPP
#ifndef RMF_TASK__REQUEST_HPP
#define RMF_TASK__REQUEST_HPP

#include <memory>

Expand Down Expand Up @@ -82,7 +82,8 @@ class Request
const std::string& id,
rmf_traffic::Time earliest_start_time,
ConstPriorityPtr priority,
DescriptionPtr description);
DescriptionPtr description,
bool automatic = false);
mxgrey marked this conversation as resolved.
Show resolved Hide resolved

/// The unique id for this request
const std::string& id() const;
Expand All @@ -96,6 +97,9 @@ class Request
/// Get the description of this request
const DescriptionPtr& description() const;

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

class Implementation;
private:
rmf_utils::impl_ptr<Implementation> _pimpl;
Expand Down
41 changes: 41 additions & 0 deletions rmf_task/include/rmf_task/RequestFactory.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* 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__REQUESTFACTORY_HPP
#define RMF_TASK__REQUESTFACTORY_HPP

#include <rmf_task/Request.hpp>

namespace rmf_task {

//==============================================================================
class RequestFactory
Yadunund marked this conversation as resolved.
Show resolved Hide resolved
{
public:

virtual ConstRequestPtr make_request(
Yadunund marked this conversation as resolved.
Show resolved Hide resolved
const agv::State& state) const = 0;

virtual ~RequestFactory() = default;
};

using RequestFactoryPtr = std::shared_ptr<RequestFactory>;
using ConstRequestFactoryPtr = std::shared_ptr<const RequestFactory>;

} // namespace rmf_task

#endif // RMF_TASK__REQUESTFACTORY_HPP
7 changes: 5 additions & 2 deletions rmf_task/include/rmf_task/agv/TaskPlanner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define RMF_TASK__AGV__TASKPLANNER_HPP

#include <rmf_task/Request.hpp>
#include <rmf_task/RequestFactory.hpp>
#include <rmf_task/CostCalculator.hpp>
#include <rmf_task/agv/Constraints.hpp>
#include <rmf_task/agv/Parameters.hpp>
Expand Down Expand Up @@ -150,7 +151,8 @@ class TaskPlanner
Result greedy_plan(
rmf_traffic::Time time_now,
std::vector<State> agents,
std::vector<ConstRequestPtr> requests);
std::vector<ConstRequestPtr> requests,
ConstRequestFactoryPtr finishing_request = nullptr);

/// Get the optimal planner based assignments for a set of initial states and
/// requests
Expand All @@ -162,7 +164,8 @@ class TaskPlanner
rmf_traffic::Time time_now,
std::vector<State> agents,
std::vector<ConstRequestPtr> requests,
std::function<bool()> interrupter);
std::function<bool()> interrupter,
ConstRequestFactoryPtr finishing_request = nullptr);

/// Compute the cost of a set of assignments
double compute_cost(const Assignments& assignments) const;
Expand Down
3 changes: 2 additions & 1 deletion rmf_task/include/rmf_task/requests/ChargeBattery.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ class ChargeBattery

static ConstRequestPtr make(
rmf_traffic::Time earliest_start_time,
ConstPriorityPtr priority = nullptr);
ConstPriorityPtr priority = nullptr,
bool automatic = true);
};

} // namespace requests
Expand Down
3 changes: 2 additions & 1 deletion rmf_task/include/rmf_task/requests/Clean.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ class Clean
const rmf_traffic::Trajectory& cleaning_path,
const std::string& id,
rmf_traffic::Time earliest_start_time,
ConstPriorityPtr priority = nullptr);
ConstPriorityPtr priority = nullptr,
bool automatic = false);
};

} // namespace requests
Expand Down
3 changes: 2 additions & 1 deletion rmf_task/include/rmf_task/requests/Delivery.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ class Delivery
rmf_traffic::Duration dropoff_wait,
const std::string& id,
rmf_traffic::Time earliest_start_time,
ConstPriorityPtr priority = nullptr);
ConstPriorityPtr priority = nullptr,
bool automatic = false);
};

} // namespace requests
Expand Down
3 changes: 2 additions & 1 deletion rmf_task/include/rmf_task/requests/Loop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ class Loop
std::size_t num_loops,
const std::string& id,
rmf_traffic::Time earliest_start_time,
ConstPriorityPtr priority = nullptr);
ConstPriorityPtr priority = nullptr,
bool automatic = false);
};

} // namespace tasks
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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__REQUESTS__FACTORY__CHARGEBATTERYFACTORY_HPP
#define RMF_TASK__REQUESTS__FACTORY__CHARGEBATTERYFACTORY_HPP

#include <rmf_task/RequestFactory.hpp>
#include <rmf_task/agv/State.hpp>

#include <rmf_utils/impl_ptr.hpp>

namespace rmf_task {
namespace requests {

//==============================================================================
class ChargeBatteryFactory : public RequestFactory
mxgrey marked this conversation as resolved.
Show resolved Hide resolved
{
public:

ChargeBatteryFactory();

ConstRequestPtr make_request(
const agv::State& state) const final;

class Implementation;

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

} // namespace requests
} // namespace rmf_task

#endif // RMF_TASK__REQUESTS__FACTORY__CHARGEBATTERYFACTORY_HPP
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* 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__REQUESTS__FACTORY__RETURNTOCHARGERFACTORY_HPP
#define RMF_TASK__REQUESTS__FACTORY__RETURNTOCHARGERFACTORY_HPP

#include <rmf_task/RequestFactory.hpp>
#include <rmf_task/agv/State.hpp>

#include <rmf_utils/impl_ptr.hpp>

namespace rmf_task {
namespace requests {

//==============================================================================
// Retuns a Loop request from current state back to its charging waypoint
Yadunund marked this conversation as resolved.
Show resolved Hide resolved
class ReturnToChargerFactory : public RequestFactory
{
public:

ReturnToChargerFactory();

ConstRequestPtr make_request(
const agv::State& state) const final;

class Implementation;

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

} // namespace requests
} // namespace rmf_task

#endif // RMF_TASK__REQUESTS__FACTORY__RETURNTOCHARGERFACTORY_HPP
15 changes: 12 additions & 3 deletions rmf_task/src/rmf_task/Request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,23 @@ class Request::Implementation
rmf_traffic::Time earliest_start_time;
rmf_task::ConstPriorityPtr priority;
DescriptionPtr description;
bool automatic;
};

//==============================================================================
Request::Request(
const std::string& id,
rmf_traffic::Time earliest_start_time,
ConstPriorityPtr priority,
DescriptionPtr description)
DescriptionPtr description,
bool automatic)
: _pimpl(rmf_utils::make_impl<Implementation>(
Implementation {
id,
earliest_start_time,
std::move(priority),
std::move(description)
std::move(description),
automatic
}))
{
// Do nothing
Expand Down Expand Up @@ -70,4 +73,10 @@ const Request::DescriptionPtr& Request::description() const
return _pimpl->description;
}

} // namespace rmf_task
//==============================================================================
bool Request::automatic() const
{
return _pimpl->automatic;
}

} // namespace rmf_task
Loading