SOLA
Loading...
Searching...
No Matches
agv_logical.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_AGV_LOGICAL_H_
18#define DAISI_PATH_PLANNING_AGV_LOGICAL_H_
19
20#include <memory>
21
22#include "cpps/amr/amr_description.h"
23#include "cpps/amr/amr_topology.h"
24#include "cpps/amr/model/amr_static_ability.h"
25#include "logging/logger_manager.h"
26#include "ns3/socket.h"
27#include "path_planning/consensus/consensus_types.h"
28#include "path_planning/consensus/constants.h"
29#include "path_planning/consensus/paxos/paxos_replication_manager.h"
30#include "path_planning/constants.h"
31#include "path_planning/message/drive_message.h"
32#include "path_planning/message/misc/new_authority_agv.h"
33#include "path_planning/message/types_all.h"
34#include "path_planning/path_planning_logger_ns_3.h"
35#include "sola-ns3/sola_ns3_wrapper.h"
36
37namespace daisi::path_planning {
38
42public:
43 AGVLogical(cpps::Topology topology, consensus::ConsensusSettings consensus_settings,
44 bool first_node, const ns3::Ptr<ns3::Socket> &socket, uint32_t device_id);
45
46 std::string getConnectionString() const;
47
54 void registerByAuthority(const std::string &ip);
55
56private:
57 bool connectionRequest(ns3::Ptr<ns3::Socket> socket, const ns3::Address &addr);
58 void newConnectionCreated(ns3::Ptr<ns3::Socket> socket, const ns3::Address &addr);
59
60 void logAMR() const;
61
62 void processMessageField(const message::FieldMessage &msg);
63 void processMessageDescription(const std::string &payload);
64 void processMessageUpdate(const message::PositionUpdate &msg);
65
66 void readFromSocket(ns3::Ptr<ns3::Socket> socket);
67
68 const uint32_t device_id_ = 0;
69 ns3::Ptr<ns3::Socket> socket_;
70 ns3::Ptr<ns3::Socket> socket_agv_;
71 std::shared_ptr<sola_ns3::SOLAWrapperNs3> sola_;
72 std::shared_ptr<PathPlanningLoggerNs3> logger_;
73 bool first_node_;
74 std::string uuid_;
75 cpps::Topology topology_;
76 uint32_t current_authority_station_id_ = UINT32_MAX;
77 std::string current_authority_ip_ = "NONE";
78 uint16_t current_authority_port_ = 0;
79 double last_x_ = 0.0;
80 double last_y_ = 0.0;
81
82 cpps::AmrDescription description_;
83
84 void processTopicMessage(const sola::TopicMessage &msg);
85 consensus::ConsensusSettings consensus_settings_;
86 std::optional<consensus::PaxosReplicationManager> replication_manager_;
87
89 void initReplication();
90
91 void processMessage(const sola::Message &msg);
92 void processDriveMessage(const message::DriveMessage &msg);
93 void processHandoverMessage(const message::HandoverMessage &msg);
94 void processReachedGoal();
95 void postInit();
96
98 void init();
99};
100} // namespace daisi::path_planning
101
102#endif // DAISI_PATH_PLANNING_AGV_LOGICAL_H_
Definition amr_description.h:27
Definition amr_topology.h:26
Definition agv_logical.h:41
void registerByAuthority(const std::string &ip)
Definition agv_logical.cpp:173
Message that is send from PickupStation to logical AGV with drive instructions.
Definition drive_message.h:30
Definition handover_message.h:29
Update of the actual AGV position send from AGVPhysicalBasic to AGVLogical.
Definition position_update.h:24
Definition message.h:20