ADORe
ADORe is a modular open source software library and toolkit for decision making, planning, control and simulation of automated vehicles
platoonStateMachine.h
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2017-2020 German Aerospace Center (DLR).
3  * Eclipse ADORe, Automated Driving Open Research https://eclipse.org/adore
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License 2.0 which is available at
7  * http://www.eclipse.org/legal/epl-2.0.
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  * Reza Dariani- initial API and implementation
13  ********************************************************************************/
14 #pragma once
15 #include <boost/statechart/event.hpp>
16 #include <boost/statechart/state_machine.hpp>
17 #include <boost/statechart/simple_state.hpp>
18 #include <boost/statechart/custom_reaction.hpp>
19 #include <boost/statechart/transition.hpp>
20 #include <boost/mpl/list.hpp>
21 #include <iostream>
22 namespace sc = boost::statechart;
23 namespace mpl = boost::mpl;
24 using namespace adore::fun;
25 namespace adore
26 {
27  namespace fun
28  {
29  namespace logic
30  {
31  // class platoonStateMachine
32  // {
33  // public:
34  //NA : Not Able
35  //WF : Want to From
36  //J : Joining
37  //IP : In Platoon
38  //L : Leaving
39  double tau;
44 
45  struct NA2WF : sc::event <NA2WF> {}; // "NOTABLE" to "WANTTOFORM"
46 
47  struct J2NA : sc::event <J2NA> {}; // "JOINING" to "NOTABLE"
48  struct J2WF : sc::event <J2WF> {}; // "JOINING" to "WANTTOFORM"
49  struct J2IP : sc::event <J2IP> {}; // "JOINING" to "IN_PLATOON"
50 
51  struct WF2J : sc::event <WF2J> {}; // "WANTTOFORM" to "JOINING"
52  struct WF2NA : sc::event <WF2NA> {}; // "WANTTOFORM" to "NOTABLE"
53  struct WF2IP : sc::event <WF2IP> {}; // "WANTTOFORM" to "IN_PLATOON"
54 
55  struct IP2J : sc::event <IP2J> {}; // "IN_PLATOON" to "JOINING"
56  struct IP2WF : sc::event <IP2WF> {}; // "IN_PLATOON" to "WANT_TO_FORM"
57  struct IP2NA : sc::event <IP2NA> {}; // "IN_PLATOON" to "NOT_ABLE"
58  struct IP2L : sc::event <IP2L> {}; // "IN_PLATOON" to "LEAVING"
59 
60  struct L2WF : sc::event <L2WF> {}; // "LEAVING" to "WANT_TO_FORM"
61  struct L2NA : sc::event <L2NA> {}; // "LEAVING" to "NOT_ABLE"
62 
63  struct NOT_ABLE;
64  struct WANT_TO_FORM;
65  struct JOINING;
66  struct IN_PLATOON;
67  struct LEAVING;
69 
70 
71  struct PlatooningStateMachine: sc::state_machine <PlatooningStateMachine, WANT_TO_FORM>
72  {
73  public:
74 
75 
76  double getTimeHeadway() {return tau;}
78  double getInPlatoonTimeHeadway() {return 1.5;}
79 
80 
81  };
82  struct WANT_TO_FORM : sc::simple_state<WANT_TO_FORM, PlatooningStateMachine> //WANT_TO_FORM belongs to the state machine
83  {
85  {
86  //std::cout<< "\nPSM TRANSITION TO WANT_TO_FORM";
87  tau = 1.5; //Platooning time headway
88 
90  }
91  typedef mpl::list<
92  sc:: transition<WF2NA, NOT_ABLE> ,
93  sc:: transition<WF2J, JOINING> ,
94  sc:: transition<WF2IP, IN_PLATOON> > reactions;
95 
96  };
97  struct NOT_ABLE: sc::simple_state <NOT_ABLE, PlatooningStateMachine>
98  {
100  {
101  // std::cout<< "\nPSM TRANSITION TO NOT ABLE";
102  tau = 3.0; //not able time headway
104  }
105  typedef sc:: transition<NA2WF, WANT_TO_FORM> reactions;
106  };
107  struct JOINING: sc::simple_state <JOINING, PlatooningStateMachine>
108  {
110  {
111  //std::cout<< "\nPSM TRANSITION TO JOINING";
112  tau = 1.5; //Platooning time headway
114  }
115  typedef mpl::list<
116  sc:: transition<J2WF, WANT_TO_FORM>,
117  sc:: transition<J2NA, NOT_ABLE>,
118  sc:: transition<J2IP, IN_PLATOON> > reactions;
119  };
120  struct IN_PLATOON: sc::simple_state <IN_PLATOON, PlatooningStateMachine>
121  {
123  {
124  //std::cout<< "\nPSM TRANSITION TO IN_PLATOON";
125  tau = 1.5; //Platooning time headway
127  }
128  typedef mpl::list<
129  sc:: transition<IP2J, JOINING> ,
130  sc:: transition<IP2WF, WANT_TO_FORM> ,
131  sc:: transition<IP2NA, NOT_ABLE> ,
132  sc:: transition<IP2L, LEAVING> >reactions;
133  };
134  struct LEAVING: sc::simple_state <LEAVING, PlatooningStateMachine>
135  {
137  {
138  //std::cout<< "\nPSM TRANSITION TO EAVING";
139  tau = 3.; //Leaving time headway
141  }
142  typedef mpl::list<
143  sc:: transition<L2WF, WANT_TO_FORM> ,
144  sc:: transition<L2NA, NOT_ABLE>> reactions;
145  };
146 
147  //};
148  }
149  }
150 }
PLATOONING_STATE
Definition: platoonStateMachine.h:42
@ Joining
Definition: platoonStateMachine.h:42
@ InPlatoon
Definition: platoonStateMachine.h:42
@ NotAble
Definition: platoonStateMachine.h:42
@ Leaving
Definition: platoonStateMachine.h:42
@ WantToForm
Definition: platoonStateMachine.h:42
double tau
Definition: platoonStateMachine.h:39
int PlatooningState
Definition: platoonStateMachine.h:67
double tau_normalDriving
Definition: platoonStateMachine.h:41
double tau_platooning
Definition: platoonStateMachine.h:40
AUTOMATION_LEVEL
Definition: platoonStateMachine.h:43
@ SAE_LEVEL3
Definition: platoonStateMachine.h:43
@ SAE_LEVEL1
Definition: platoonStateMachine.h:43
@ SAE_LEVEL0
Definition: platoonStateMachine.h:43
@ SAE_LEVEL4
Definition: platoonStateMachine.h:43
@ SAE_LEVEL5
Definition: platoonStateMachine.h:43
@ SAE_LEVEL2
Definition: platoonStateMachine.h:43
Definition: initial_state_selector.h:26
Definition: areaofeffectconverter.h:20
Definition: platoonStateMachine.h:121
mpl::list< sc::transition< IP2J, JOINING >, sc::transition< IP2WF, WANT_TO_FORM >, sc::transition< IP2NA, NOT_ABLE >, sc::transition< IP2L, LEAVING > > reactions
Definition: platoonStateMachine.h:132
IN_PLATOON()
Definition: platoonStateMachine.h:122
Definition: platoonStateMachine.h:55
Definition: platoonStateMachine.h:58
Definition: platoonStateMachine.h:57
Definition: platoonStateMachine.h:56
Definition: platoonStateMachine.h:49
Definition: platoonStateMachine.h:47
Definition: platoonStateMachine.h:48
Definition: platoonStateMachine.h:108
JOINING()
Definition: platoonStateMachine.h:109
mpl::list< sc::transition< J2WF, WANT_TO_FORM >, sc::transition< J2NA, NOT_ABLE >, sc::transition< J2IP, IN_PLATOON > > reactions
Definition: platoonStateMachine.h:118
Definition: platoonStateMachine.h:61
Definition: platoonStateMachine.h:60
Definition: platoonStateMachine.h:135
mpl::list< sc::transition< L2WF, WANT_TO_FORM >, sc::transition< L2NA, NOT_ABLE > > reactions
Definition: platoonStateMachine.h:144
LEAVING()
Definition: platoonStateMachine.h:136
Definition: platoonStateMachine.h:45
Definition: platoonStateMachine.h:98
sc::transition< NA2WF, WANT_TO_FORM > reactions
Definition: platoonStateMachine.h:105
NOT_ABLE()
Definition: platoonStateMachine.h:99
Definition: platoonStateMachine.h:72
double getTimeHeadway()
Definition: platoonStateMachine.h:76
int getPlatooningState()
Definition: platoonStateMachine.h:77
double getInPlatoonTimeHeadway()
Definition: platoonStateMachine.h:78
WANT_TO_FORM is defined as an entry state of the state machine
Definition: platoonStateMachine.h:83
WANT_TO_FORM()
Definition: platoonStateMachine.h:84
mpl::list< sc::transition< WF2NA, NOT_ABLE >, sc::transition< WF2J, JOINING >, sc::transition< WF2IP, IN_PLATOON > > reactions
Definition: platoonStateMachine.h:94
Definition: platoonStateMachine.h:53
Definition: platoonStateMachine.h:51
Definition: platoonStateMachine.h:52