SOLA
Loading...
Searching...
No Matches
path_planning_manager.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_PATH_PLANNING_PATH_PLANNING_MANAGER_H_
18#define DAISI_PATH_PLANNING_PATH_PLANNING_MANAGER_H_
19
20#include <deque>
21#include <optional>
22#include <unordered_map>
23#include <utility>
24
25#include "agv_physical_basic.h"
26#include "cpps/amr/amr_kinematics.h"
27#include "cpps/common/cpps_logger_ns3.h"
28#include "manager/manager.h"
29#include "minhton/logging/logger_interface.h"
30#include "ns3/bridge-helper.h"
31#include "ns3/csma-helper.h"
32#include "ns3/internet-stack-helper.h"
33#include "ns3/ipv4-address-helper.h"
34#include "ns3/ipv4-static-routing-helper.h"
35#include "ns3/net-device-container.h"
36#include "ns3/nstime.h"
37#include "ns3/simulator.h"
38#include "path_planning/consensus/consensus_types.h"
39#include "path_planning/path_planning_application.h"
40
41namespace daisi::path_planning {
42
44class PathPlanningManager final : public Manager<PathPlanningApplication> {
45public:
46 explicit PathPlanningManager(const std::string &scenario_config_file);
47 void setup() final;
48 void initAGV(uint32_t index);
49
50 void initPickupStation(uint32_t index);
51 void postInitPickupStation(uint32_t index);
52
53 void initDeliveryStation(uint32_t index);
54 void postInitDeliveryStation(uint32_t index);
55
56 void initCentralConsensus();
57
58 void registerAGVByAuthority(uint32_t index);
59 void connect(int index);
60
61private:
62 void setupNodes();
63
67 void setRouteInfo();
68
69 void scheduleSpawnTO(uint32_t pickup_index);
70
75 void setupArp(const ns3::NetDeviceContainer &devices, const ns3::Ipv4InterfaceContainer &ips);
76
77 void setupNetworkEthernet();
78 void setupNetworkWifi();
79 void scheduleEvents() override;
80 [[nodiscard]] uint64_t getNumberOfNodes() override;
81
82 std::string getDatabaseFilename() override;
83
84 void parse();
85 void parseToSpawn(const std::shared_ptr<ScenariofileParser::Table> &spawn_description);
86 void parseScenarioSequence();
87 void parseConsensusSettings();
88
92 void checkSimulationFinished();
93
94 [[nodiscard]] uint32_t getAGVInitialStationNumber(uint32_t agv_id) const;
95
101 std::vector<PickupStationHandoverInfo> getPickupStationRegistry();
102
103 uint32_t number_pickup_stations_ = 0;
104 uint32_t number_delivery_stations_ = 0;
105 uint64_t number_agvs_ = 0;
106 cpps::Topology topology_;
107 uint64_t to_spawn_duration_ms_ = 0;
108
109 // TODO Pack to topology
110 float left_border_ = 0; // x
111 float right_border_ = 0; // x
112 float upper_border_ = 0; // y
113 float lower_border_ = 0; // y
114
115 // Nodes / Network
116 ns3::NodeContainer central_consensus_;
117 ns3::NodeContainer agvs_;
118 ns3::NodeContainer pickup_stations_;
119 ns3::NodeContainer delivery_stations_;
120 ns3::NodeContainer access_points_;
121
122 const double delta_stations_ = 4.0;
123
124 consensus::ConsensusType consensus_type_ = consensus::ConsensusType::kNone;
125 consensus::ConsensusSettings consensus_settings_;
126
127 cpps::AmrDescription description_;
128};
129
130} // namespace daisi::path_planning
131
132#endif // DAISI_PATH_PLANNING_PATH_PLANNING_MANAGER_H_
Definition manager.h:26
Definition amr_description.h:27
Definition amr_topology.h:26
Manager that sets up and runs the path planning use case.
Definition path_planning_manager.h:44