SOLA
Loading...
Searching...
No Matches
amr_fleet.h
1// Copyright 2023 The SOLA authors
2//
3// This file is part of DAISI.
4//
5// DAISI is free software: you can redistribute it and/or modify it under the terms of the GNU
6// General Public License as published by the Free Software Foundation; version 2.
7//
8// DAISI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
9// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
10// Public License for more details.
11//
12// You should have received a copy of the GNU General Public License along with DAISI. If not, see
13// <https://www.gnu.org/licenses/>.
14//
15// SPDX-License-Identifier: GPL-2.0-only
16
17#ifndef DAISI_CPPS_AMR_MODEL_AMR_FLEET_H_
18#define DAISI_CPPS_AMR_MODEL_AMR_FLEET_H_
19
20#include <optional>
21#include <stdexcept>
22#include <unordered_map>
23#include <vector>
24
25#include "cpps/amr/amr_kinematics.h"
26#include "cpps/amr/model/amr_static_ability.h"
27
28namespace daisi::cpps {
29
30class AmrFleet {
31public:
32 using AmrInfo = std::pair<amr::AmrStaticAbility, AmrKinematics>;
33
34 static AmrFleet &get() { return getImpl(); }
35
36 static void init(const std::vector<AmrInfo> &infos) { getImpl(infos); }
37
38 AmrFleet(AmrFleet const &) = delete;
39 void operator=(AmrFleet const &) = delete;
40
41 // -----------------------------------------
42
43 std::vector<amr::AmrStaticAbility> getFittingExistingAbilities(
44 const amr::AmrStaticAbility &ability_requirement) const;
45
46 amr::AmrStaticAbility getClosestExistingAbility(
47 const amr::AmrStaticAbility &ability_requirement) const;
48
49 std::vector<amr::AmrStaticAbility> getAllExistingAbilities() const;
50
51 std::string getTopicForAbility(const amr::AmrStaticAbility &ability) const;
52
53 AmrKinematics getKinematicsOfAbility(const amr::AmrStaticAbility &ability) const;
54
55 static std::string getDefaultTopic() { return "defaulttopic"; }
56
57private:
58 std::vector<AmrInfo> infos_;
59
60 static AmrFleet &getImpl(const std::optional<std::vector<AmrInfo>> &infos = std::nullopt) {
61 static AmrFleet instance{infos};
62 return instance;
63 }
64
65 explicit AmrFleet(const std::optional<std::vector<AmrInfo>> &infos) {
66 if (!infos.has_value()) {
67 throw std::runtime_error("AmrFleet not initialized");
68 }
69
70 infos_ = infos.value();
71 }
72
73 AmrFleet() = default;
74};
75
76} // namespace daisi::cpps
77
78#endif
Definition amr_fleet.h:30
std::vector< amr::AmrStaticAbility > getFittingExistingAbilities(const amr::AmrStaticAbility &ability_requirement) const
Definition amr_fleet.cpp:25
std::vector< amr::AmrStaticAbility > getAllExistingAbilities() const
\mathcal{G} = {G1, G2, ...} in thesis
Definition amr_fleet.cpp:80
Definition amr_kinematics.h:23
Definition amr_static_ability.h:32