SOLA
Loading...
Searching...
No Matches
central_participant.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_CONSENSUS_CENTRAL_PARTICIPANT_H_
18#define DAISI_PATH_PLANNING_CONSENSUS_CENTRAL_PARTICIPANT_H_
19
20#include "path_planning/consensus/central/central_settings.h"
21#include "path_planning/consensus/consensus_base.h"
22#include "path_planning/path_planning_logger_ns_3.h"
23#include "sola-ns3/sola_ns3_wrapper.h"
24
25namespace daisi::path_planning::consensus {
27class CentralParticipant : public ConsensusBase<CentralParticipant, CentralSettings> {
28public:
29 CentralParticipant(const std::shared_ptr<sola_ns3::SOLAWrapperNs3> &sola,
30 const CentralSettings &settings,
31 std::shared_ptr<PathPlanningLoggerNs3> logger);
32
33private:
34 friend ConsensusBase;
35
36 // CRTP implementation
37 void findConsensusImpl(const PointTimePairs &points, double seconds_earliest_start,
38 std::function<void(uint32_t, double)> success_cb,
39 std::function<void(uint32_t)> fail_cb);
40 void recvTopicMessageImpl(const std::string &topic, const std::string &msg);
41
46 void processMessage(const solanet::Message &msg);
47
48 std::unique_ptr<solanet::Network>
49 network_;
52 std::shared_ptr<PathPlanningLoggerNs3> logger_;
53
54 uint32_t next_request_id_ = 0;
55
57 struct CurrentRequest {
58 uint32_t request_id;
59 std::function<void(uint32_t, double)> success_cb;
60 std::function<void(uint32_t)> fail_cb;
61 std::vector<std::tuple<float, float, double>> intersection_times;
62 };
63
64 std::unordered_map<uint32_t, CurrentRequest>
65 requests_;
66};
67} // namespace daisi::path_planning::consensus
68
69#endif // DAISI_PATH_PLANNING_CONSENSUS_CENTRAL_PARTICIPANT_H_
Participant/Client in the centralized client-server occupancy management.
Definition central_participant.h:27
CRTP base class for a consensus algorithm.
Definition consensus_base.h:29
Definition message.h:14
Definition central_settings.h:24