SOLA
All Classes Namespaces Functions Variables Enumerations Friends Pages
consensus.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_CONSENSUS_H_
18#define DAISI_PATH_PLANNING_CONSENSUS_CONSENSUS_H_
19
20#include "path_planning/consensus/central/central_participant.h"
21#include "path_planning/consensus/consensus_types.h"
22#include "path_planning/consensus/constants.h"
23#include "path_planning/consensus/paxos/constants.h"
24#include "path_planning/consensus/paxos/paxos_consensus.h"
25#include "path_planning/constants.h"
26#include "sola-ns3/sola_ns3_wrapper.h"
27
28namespace daisi::path_planning::consensus {
29
32class Consensus {
33public:
34 Consensus(consensus::ConsensusSettings settings,
35 const std::shared_ptr<sola_ns3::SOLAWrapperNs3> &sola, uint32_t node_id,
36 std::shared_ptr<PathPlanningLoggerNs3> logger);
37
48 void findConsensus(const PointTimePairs &points, double seconds_earliest_start,
49 std::function<void(uint32_t id, double start_time)> success_cb,
50 std::function<void(uint32_t id)> fail_cb);
51
58 void recvTopicMessage(const std::string &topic, const std::string &msg);
59
60private:
61 std::variant<std::monostate, PaxosConsensus,
63 consensus_;
64};
65} // namespace daisi::path_planning::consensus
66#endif // DAISI_PATH_PLANNING_CONSENSUS_CONSENSUS_H_
Participant/Client in the centralized client-server occupancy management.
Definition central_participant.h:27
void findConsensus(const PointTimePairs &points, double seconds_earliest_start, std::function< void(uint32_t id, double start_time)> success_cb, std::function< void(uint32_t id)> fail_cb)
Definition consensus.cpp:36
void recvTopicMessage(const std::string &topic, const std::string &msg)
Definition consensus.cpp:49