Multi-robot Playground
RendezvousPlan.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023, Alysson Ribeiro da Silva
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice, this
9  * list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. All advertising materials mentioning features or use of this software must
16  * display the following acknowledgement:
17  * This product includes software developed by Alysson Ribeiro da Silva.
18  *
19  * 4. Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from
21  * this software without specific prior written permission.
22  *
23  * 5. The source and the binary form, and any modifications made to them
24  * may not be used for the purpose of training or improving machine learning
25  * algorithms, including but not limited to artificial intelligence, natural
26  * language processing, or data mining. This condition applies to any derivatives,
27  * modifications, or updates based on the Software code. Any usage of the source
28  * or the binary form in an AI-training dataset is considered a breach of
29  * this License.
30  *
31  * THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER "AS IS" AND ANY EXPRESS OR
32  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
33  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
34  * EVENT SHALL COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
36  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
37  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
38  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
39  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
40  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 */
42 
43 #include <vector>
44 #include "tf/tf.h"
45 #include "ros/ros.h"
46 
47 struct agreement_el {
49  double timer;
50 };
51 
53  public:
54  RendezvousPlan(ros::NodeHandle& nodeHandle, const int& id);
56 
57  int GetCurrentAgreement();
58  double GetCurrentAgreementTimer();
60 
61  void InitializeLocation(tf::Vector3 location);
62  void Update(const double& deltaTime);
64  void SetNextAgreement();
65  void UpdateCurrentAgreementLocation(tf::Vector3 newLocation);
66  tf::Vector3 GetCurrentAgreementLocation();
67  void PrintLocations();
68  void Print();
69  void PrintCurrent();
70  void PrintRealization();
73 
74  // relization
75  void RealizePlan(const int& robotId);
76  void ResetPlanRealization();
77  bool WasPlanRealized();
78 
79  std::vector<int>* GetPlanPtr();
80 
81  private:
82  std::string GenerateAgreementKey(const int& index);
83 
84  int id, width;
86  double current_timer;
87  std::vector< std::pair<int, std::vector<agreement_el>> > agreements;
88  std::map<std::string, tf::Vector3> agreements_locations;
89 
90  std::vector<std::vector<agreement_el>> agreementsIParticipate;
91 
92  std::vector<int> currentPlanRealization;
93 };
RendezvousPlan
Definition: RendezvousPlan.h:52
RendezvousPlan::CheckConsensusCurrentPlan
bool CheckConsensusCurrentPlan()
RendezvousPlan::current_timer
double current_timer
Definition: RendezvousPlan.h:86
RendezvousPlan::agreementsIParticipate
std::vector< std::vector< agreement_el > > agreementsIParticipate
Definition: RendezvousPlan.h:90
RendezvousPlan::currentPlanRealization
std::vector< int > currentPlanRealization
Definition: RendezvousPlan.h:92
RendezvousPlan::ResetPlanRealization
void ResetPlanRealization()
agreement_el
Definition: RendezvousPlan.h:47
agreement_el::participate
int participate
Definition: RendezvousPlan.h:48
RendezvousPlan::~RendezvousPlan
~RendezvousPlan()
RendezvousPlan::WasPlanRealized
bool WasPlanRealized()
RendezvousPlan::ShouldFulfillAgreement
bool ShouldFulfillAgreement()
RendezvousPlan::agreements_locations
std::map< std::string, tf::Vector3 > agreements_locations
Definition: RendezvousPlan.h:88
RendezvousPlan::width
int width
Definition: RendezvousPlan.h:84
agreement_el::timer
double timer
Definition: RendezvousPlan.h:49
RendezvousPlan::GetCurrentAgreementLocation
tf::Vector3 GetCurrentAgreementLocation()
RendezvousPlan::GetCurrentAgreementTimer
double GetCurrentAgreementTimer()
RendezvousPlan::GenerateAgreementKey
std::string GenerateAgreementKey(const int &index)
RendezvousPlan::RealizePlan
void RealizePlan(const int &robotId)
RendezvousPlan::PrintLocations
void PrintLocations()
RendezvousPlan::GetCurrentAgreement
int GetCurrentAgreement()
RendezvousPlan::RendezvousPlan
RendezvousPlan(ros::NodeHandle &nodeHandle, const int &id)
RendezvousPlan::Print
void Print()
RendezvousPlan::GetCurrentAgreementUniqueID
int GetCurrentAgreementUniqueID()
RendezvousPlan::PrintCurrent
void PrintCurrent()
RendezvousPlan::InitializeLocation
void InitializeLocation(tf::Vector3 location)
RendezvousPlan::Update
void Update(const double &deltaTime)
RendezvousPlan::id
int id
Definition: RendezvousPlan.h:84
RendezvousPlan::SetNextAgreement
void SetNextAgreement()
RendezvousPlan::UpdateCurrentAgreementLocation
void UpdateCurrentAgreementLocation(tf::Vector3 newLocation)
RendezvousPlan::GetPlanPtr
std::vector< int > * GetPlanPtr()
RendezvousPlan::PrintRealization
void PrintRealization()
RendezvousPlan::current_agreement
int current_agreement
Definition: RendezvousPlan.h:85
RendezvousPlan::GetCurrentAgreementConsensusID
int GetCurrentAgreementConsensusID()
RendezvousPlan::agreements
std::vector< std::pair< int, std::vector< agreement_el > > > agreements
Definition: RendezvousPlan.h:87