Skip to content

Commit

Permalink
Add in functional estimation and executor plug-ins (ROSI-AP/rosi-ap_c…
Browse files Browse the repository at this point in the history
…ommercial/cag/rmf_scheduler!23)

Signed-off-by: Chen Bainian <[email protected]>

* temp commit for old estimate interface.

Co-authored-by: Santosh Balaji Selvaraj <[email protected]>
  • Loading branch information
Briancbn and Santosh Balaji Selvaraj committed Sep 13, 2023
1 parent 44c41dd commit c817b01
Show file tree
Hide file tree
Showing 98 changed files with 4,535 additions and 1,387 deletions.
4 changes: 2 additions & 2 deletions .doxygen/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ EXTRACT_PACKAGE = NO
EXTRACT_STATIC = YES
INPUT = ./doxygen.md \
../rmf_scheduler/include \
../task_estimate_client_cpp/include \
../conflict_resolver/include \
../rmf_scheduler_plugins/include \
../rmf_scheduler_ros2/include \
USE_MDFILE_AS_MAINPAGE = ./doxygen.md
RECURSIVE = YES
EXCLUDE =
Expand Down
30 changes: 19 additions & 11 deletions rmf_scheduler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,29 @@ include_directories(

add_library(${PROJECT_NAME}
SHARED
src/conflict_identifier.cpp
src/conflict_resolver/cp_solver.cpp
src/dag.cpp
src/dag_executor.cpp
src/conflict/identifier.cpp
src/conflict/cp_solver.cpp
src/data/dag.cpp
src/data/event.cpp
src/data/events_handler.cpp
src/data/schedule.cpp
src/data/series.cpp
src/error_code.cpp
src/events_handler.cpp
src/parser.cpp
src/runtime_interface.cpp
src/runtime.cpp
src/schedule.cpp
src/runtime/dag_executor.cpp
src/runtime/system_time_executor.cpp
src/scheduler.cpp
src/scheduler_options.cpp
src/schema_validator.cpp
src/series.cpp
src/system_time_executor.cpp
src/system_time_utils.cpp
src/task/task_plugin.cpp
src/task/builder.cpp
src/task/estimate_interface.cpp
src/task/estimator.cpp
src/task/execution_interface.cpp
src/task/executor.cpp
src/utils/system_time_utils.cpp
src/log.cpp
src/default_log_handler.cpp
)

ament_target_dependencies(${PROJECT_NAME}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef RMF_SCHEDULER__CONFLICT_RESOLVER__CP_SOLVER_HPP_
#define RMF_SCHEDULER__CONFLICT_RESOLVER__CP_SOLVER_HPP_
#ifndef RMF_SCHEDULER__CONFLICT__CP_SOLVER_HPP_
#define RMF_SCHEDULER__CONFLICT__CP_SOLVER_HPP_

#include <memory>
#include <vector>
#include <string>
#include <unordered_map>

#include "rmf_scheduler/event.hpp"
#include "rmf_scheduler/data/event.hpp"

namespace rmf_scheduler
{
namespace conflict_resolver
namespace conflict
{

// Class to reflect changes of an event
Expand Down Expand Up @@ -55,7 +55,7 @@ class CpSolver

/// Initialize the Solver with events of interest
void init(
const std::vector<Event> & events,
const std::vector<data::Event> & events,
const Window & window,
double time_limit = -1.0);

Expand Down Expand Up @@ -97,7 +97,7 @@ class CpSolver
std::unique_ptr<Impl> impl_;
};

} // namespace conflict_resolver
} // namespace conflict
} // namespace rmf_scheduler

#endif // RMF_SCHEDULER__CONFLICT_RESOLVER__CP_SOLVER_HPP_
#endif // RMF_SCHEDULER__CONFLICT__CP_SOLVER_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef RMF_SCHEDULER__CONFLICT_IDENTIFIER_HPP_
#define RMF_SCHEDULER__CONFLICT_IDENTIFIER_HPP_
#ifndef RMF_SCHEDULER__CONFLICT__IDENTIFIER_HPP_
#define RMF_SCHEDULER__CONFLICT__IDENTIFIER_HPP_

#include <cstdint>
#include <vector>
Expand All @@ -22,7 +22,7 @@
#include <unordered_set>
#include <utility>

#include "rmf_scheduler/event.hpp"
#include "rmf_scheduler/data/event.hpp"

namespace rmf_scheduler
{
Expand Down Expand Up @@ -68,7 +68,7 @@ bool simple_conflict_check(
* \return[out] A list of pairs of ids of conflicting events
*/
std::vector<Conflict> identify_conflicts(
const std::vector<Event> & events,
const std::vector<data::Event> & events,
const std::unordered_set<std::string> & allowed_types = {},
const std::vector<std::string> & filters = {},
const std::string & method = "optimal");
Expand All @@ -85,7 +85,7 @@ std::vector<Conflict> identify_conflicts(
*/
std::vector<std::unordered_map<std::string, std::vector<std::string>>>
categorise_by_filter(
const std::vector<Event> & events,
const std::vector<data::Event> & events,
const std::vector<std::string> & filters,
const std::unordered_set<std::string> & allowed_types = {});

Expand All @@ -95,11 +95,11 @@ categorise_by_filter(
* \return[out] id based on the filtered result
*/
std::unordered_map<std::string, std::vector<std::string>> categorise_by_type(
const std::vector<Event> & events,
const std::vector<data::Event> & events,
const std::unordered_set<std::string> & allowed_types = {});

} // namespace utils

} // namespace rmf_scheduler

#endif // RMF_SCHEDULER__CONFLICT_IDENTIFIER_HPP_
#endif // RMF_SCHEDULER__CONFLICT__IDENTIFIER_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef RMF_SCHEDULER__DAG_HPP_
#define RMF_SCHEDULER__DAG_HPP_
#ifndef RMF_SCHEDULER__DATA__DAG_HPP_
#define RMF_SCHEDULER__DATA__DAG_HPP_

#include <cstdarg>
#include <memory>
Expand All @@ -24,6 +24,7 @@
#include <vector>

#include "rmf_scheduler/exception.hpp"
#include "rmf_scheduler/error_code.hpp"

namespace tf
{
Expand All @@ -34,9 +35,17 @@ class Taskflow;
namespace rmf_scheduler
{

namespace runtime
{
class DAGExecutor;
} // namespace runtime

namespace data
{

class DAG
{
friend class DAGExecutor;
friend class runtime::DAGExecutor;

public:
using DependencyInfo = std::vector<std::string>;
Expand Down Expand Up @@ -121,13 +130,19 @@ class DAG
Description temp_description_info_;
};

} // namespace data

namespace exception
{

class DAGIDException : public IDException
{
public:
template<typename ... Args>
DAGIDException(const char * id, const char * msg, Args && ... args)
: IDException(id, msg, std::forward<Args>(args) ...)
: IDException(
ErrorCode::FAILURE | ErrorCode::INVALID_ID | ErrorCode::INVALID_DEPENDENCY,
id, msg, std::forward<Args>(args) ...)
{
add_prefix("DAGIDException:\n ");
}
Expand All @@ -139,12 +154,16 @@ class DAGCyclicException : public ExceptionTemplate
public:
template<typename ... Args>
DAGCyclicException(const char * msg, Args && ... args)
: ExceptionTemplate(msg, std::forward<Args>(args) ...)
: ExceptionTemplate(
ErrorCode::FAILURE | ErrorCode::INVALID_LOGIC | ErrorCode::INVALID_DEPENDENCY,
msg, std::forward<Args>(args) ...)
{
add_prefix("DAGCyclicException:\n ");
}
};

} // namespace exception

} // namespace rmf_scheduler

#endif // RMF_SCHEDULER__DAG_HPP_
#endif // RMF_SCHEDULER__DATA__DAG_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,35 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef RMF_SCHEDULER__EVENT_HPP_
#define RMF_SCHEDULER__EVENT_HPP_
#ifndef RMF_SCHEDULER__DATA__EVENT_HPP_
#define RMF_SCHEDULER__DATA__EVENT_HPP_

#include <cstdint>
#include <memory>
#include <string>
#include <vector>

namespace rmf_scheduler
{

namespace data
{

/// Basic information about the Event
struct Event
{
explicit Event(
std::string _description,
std::string _type,
uint64_t _start_time,
uint64_t _duration,
std::string _id,
std::string _series_id,
std::string _dag_id,
std::string _event_details);

Event() = default;

/// Event description
std::string description;

Expand All @@ -51,9 +67,13 @@ struct Event

/// Event details
std::string event_details;

/// Task details
std::string task_details;
};

} // namespace data

} // namespace rmf_scheduler

#endif // RMF_SCHEDULER__EVENT_HPP_
#endif // RMF_SCHEDULER__DATA__EVENT_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef RMF_SCHEDULER__EVENTS_HANDLER_HPP_
#define RMF_SCHEDULER__EVENTS_HANDLER_HPP_
#ifndef RMF_SCHEDULER__DATA__EVENTS_HANDLER_HPP_
#define RMF_SCHEDULER__DATA__EVENTS_HANDLER_HPP_

#include <cstdarg>

Expand All @@ -24,12 +24,16 @@
#include <utility>
#include <vector>

#include "rmf_scheduler/event.hpp"
#include "rmf_scheduler/data/event.hpp"
#include "rmf_scheduler/exception.hpp"
#include "rmf_scheduler/error_code.hpp"

namespace rmf_scheduler
{

namespace data
{

class EventsHandler
{
public:
Expand Down Expand Up @@ -73,19 +77,28 @@ class EventsHandler
StartTimeLookup start_time_lookup_;
};

} // namespace data

namespace exception
{

class EventsHandlerIDException : public IDException
{
public:
template<typename ... Args>
EventsHandlerIDException(const char * id, const char * msg, Args && ... args)
: IDException(id, msg, std::forward<Args>(args) ...)
: IDException(
ErrorCode::FAILURE | ErrorCode::INVALID_ID | ErrorCode::INVALID_EVENT,
id, msg, std::forward<Args>(args) ...)
{
add_prefix("EventsHandlerIDException:\n ");
}

~EventsHandlerIDException() = default;
};

} // namespace exception

} // namespace rmf_scheduler

#endif // RMF_SCHEDULER__EVENTS_HANDLER_HPP_
#endif // RMF_SCHEDULER__DATA__EVENTS_HANDLER_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,23 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef RMF_SCHEDULER__SCHEDULE_HPP_
#define RMF_SCHEDULER__SCHEDULE_HPP_
#ifndef RMF_SCHEDULER__DATA__SCHEDULE_HPP_
#define RMF_SCHEDULER__DATA__SCHEDULE_HPP_

#include <string>
#include <vector>
#include <unordered_map>

#include "rmf_scheduler/events_handler.hpp"
#include "rmf_scheduler/dag.hpp"
#include "rmf_scheduler/series.hpp"
#include "rmf_scheduler/data/events_handler.hpp"
#include "rmf_scheduler/data/dag.hpp"
#include "rmf_scheduler/data/series.hpp"

namespace rmf_scheduler
{

namespace data
{

/// Schedule class
class Schedule
{
Expand Down Expand Up @@ -171,6 +174,9 @@ class Schedule
void delete_dag_series(
const std::string & series_id);

/// Expand event series and add additional events
void expand_all_series_until(uint64_t time);

/// Get Series
const Series & get_series(
const std::string & series_id) const;
Expand Down Expand Up @@ -281,6 +287,8 @@ class Schedule
std::unordered_map<std::string, Series> series_map_;
};

} // namespace data

} // namespace rmf_scheduler

#endif // RMF_SCHEDULER__SCHEDULE_HPP_
#endif // RMF_SCHEDULER__DATA__SCHEDULE_HPP_
Loading

0 comments on commit c817b01

Please sign in to comment.