Skip to content

Commit beaa2ed

Browse files
authored
Merge pull request #84 from BlueAndi/platoon/leader_refactoring
Platoon: Leader App
2 parents b61db69 + 0f91e24 commit beaa2ed

22 files changed

+2019
-762
lines changed

data/config/follower_1.json

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"robotName": "follower_1",
3+
"wifi": {
4+
"ssid": "TheForce",
5+
"pswd": "hanshotfirst"
6+
},
7+
"mqtt": {
8+
"host": "localhost",
9+
"port": 1883
10+
},
11+
"ap": {
12+
"ssid": "DCS_AP",
13+
"pswd": "hanshotfirst"
14+
},
15+
"webServer": {
16+
"user": "admin",
17+
"pswd": "admin"
18+
},
19+
"platoon": {
20+
"platoonId": "0",
21+
"vehicleId": "1"
22+
},
23+
"initialPosition": {
24+
"x": "0",
25+
"y": "0",
26+
"heading": "0"
27+
}
28+
}

data/config/follower_2.json

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"robotName": "follower_2",
3+
"wifi": {
4+
"ssid": "TheForce",
5+
"pswd": "hanshotfirst"
6+
},
7+
"mqtt": {
8+
"host": "localhost",
9+
"port": 1883
10+
},
11+
"ap": {
12+
"ssid": "DCS_AP",
13+
"pswd": "hanshotfirst"
14+
},
15+
"webServer": {
16+
"user": "admin",
17+
"pswd": "admin"
18+
},
19+
"platoon": {
20+
"platoonId": "0",
21+
"vehicleId": "2"
22+
},
23+
"initialPosition": {
24+
"x": "0",
25+
"y": "0",
26+
"heading": "0"
27+
}
28+
}

data/config/leader.json

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"robotName": "leader",
3+
"wifi": {
4+
"ssid": "TheForce",
5+
"pswd": "hanshotfirst"
6+
},
7+
"mqtt": {
8+
"host": "localhost",
9+
"port": 1883
10+
},
11+
"ap": {
12+
"ssid": "DCS_AP",
13+
"pswd": "hanshotfirst"
14+
},
15+
"webServer": {
16+
"user": "admin",
17+
"pswd": "admin"
18+
},
19+
"platoon": {
20+
"platoonId": "0",
21+
"vehicleId": "0"
22+
},
23+
"initialPosition": {
24+
"x": "0",
25+
"y": "0",
26+
"heading": "1588"
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
@startuml DcsClassDiagram
2+
3+
Title DCS Class Diagram
4+
5+
class "Application" as app {
6+
+ setup() : void
7+
+ loop() : void
8+
+ release() : void
9+
- m_serialMuxProtServer : SMPServer
10+
- m_systemStateMachine : StateMachine
11+
- m_remoteControlHandler : RemoteControlHandler
12+
- m_safetyMonitor : SafetyMonitor
13+
}
14+
15+
note right of app
16+
Callbacks for SerialMuxProtServer and MqttClient are defined here.
17+
Uses the setters of each class or state to forward the data.
18+
Uses the getters of each class or state to get the data that shall be sent to the RU or the V2V controller.
19+
end note
20+
21+
class "V2V Controller" as v2v {
22+
- m_mqttClient : MqttClient
23+
- m_rxWaypointQueue : Queue
24+
+ init(MqttConfig) : bool
25+
+ process() : bool
26+
+ sendWaypoint(const Waypoint&) : bool
27+
+ getWaypoint(Waypoint&) : bool
28+
}
29+
30+
class StateMachine <<control>> {
31+
+ setState(state : IState*) : void
32+
+ getState() : IState*
33+
+ process() : void
34+
}
35+
36+
class "RemoteCommandResponseHandler" as smpHandler {
37+
+ processResponse(const CommandResponse&) : void
38+
}
39+
40+
note right of smpHandler
41+
This class is responsible for handling
42+
the response from the remote command
43+
sent to RU.
44+
- Notifies StartupState of successful commands.
45+
- Sets max speed in DrivingState.
46+
end note
47+
48+
class "SafetyMonitor" as safety {
49+
+ process(StateMachine& sm) : void
50+
+ getPendingHeartbeat(const Hearbeat& hb) : bool
51+
+ heartbeatCallback(const Hearbeat& hb) : void
52+
}
53+
54+
interface IState {
55+
+ {abstract} entry() : void
56+
+ {abstract} process(sm : StateMachine&) : void
57+
+ {abstract} exit() : void
58+
}
59+
60+
class StartupState <<Singleton>>
61+
{
62+
+ getPendingCommand(Command& cmd) : bool
63+
+ notify(Event event) : void
64+
}
65+
66+
class IdleState <<Singleton>>
67+
68+
class DrivingState <<Singleton>> {
69+
- m_longitudinalController : LongitudinalController
70+
+ setMaxMotorSpeed(int16_t maxMotorSpeed) : void
71+
+ calculateTopMotorSpeed(const Waypoint& currentVehicleData): int16_t
72+
+ setLastFollowerFeedback(const Waypoint& feedback) : void
73+
+ getLatestVehicleData(Waypoint& vehicleData) : bool
74+
}
75+
76+
protocol "SerialMuxChannels" as smpch {
77+
+ typedef SerialMuxProtServer<MAX_CHANNELS> SMPServer
78+
+ struct Command
79+
+ struct CommandReponse
80+
+ struct SpeedData
81+
+ struct VehicleData
82+
}
83+
84+
app *--> v2v
85+
app *--> StateMachine
86+
app *--> smpHandler
87+
app *--> safety
88+
app ..> DrivingState: <<use>>
89+
app ..> StartupState: <<use>>
90+
app ..> smpch: <<use>>
91+
92+
StateMachine o--> "0..1" IState
93+
94+
IState <|.. StartupState: <<realize>>
95+
IState <|.. IdleState: <<realize>>
96+
IState <|.. DrivingState: <<realize>>
97+
IState <|.. ErrorState: <<realize>>
98+
99+
smpHandler ..> StartupState: <<use>>
100+
smpHandler ..> DrivingState: <<use>>
101+
102+
@enduml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
@startuml LeaderAppSequenceDiagram
2+
3+
autoactivate on
4+
5+
Title Leader App Sequence Diagram
6+
7+
participant "App" as App
8+
participant "State Machine" as SM
9+
participant "SMP Server" as Smp
10+
participant "V2V Client" as Mqtt
11+
participant "Remote Command Response Handler" as RCRH
12+
participant "Startup State" as StartupState
13+
participant "Idle State" as IdleState
14+
participant "Driving State" as DrivingState
15+
participant "Safety Monitor" as SafetyMonitor
16+
17+
entity "RadonUlzer" as RU
18+
19+
== State Machine: Startup State ==
20+
21+
group Startup Commands [Repeats for each pending command]
22+
App -> StartupState : getPendingCommand
23+
return pendingCommand
24+
25+
App -> Smp : sendCommand(pendingCommand)
26+
Smp -> RU : send
27+
deactivate
28+
return command sent
29+
30+
RU -->> Smp : response
31+
32+
App -> Smp : process()
33+
Smp -> App : CMD_RSP callback
34+
App -> RCRH : handleCommandResponse(rsp)
35+
alt OK
36+
RCRH -> StartupState : notify(Event event)
37+
return
38+
end
39+
alt max speed received
40+
RCRH -> DrivingState : setMaxSpeed(speed)
41+
return
42+
end
43+
alt error received
44+
RCRH -> SM : setState(ErrorState)
45+
return
46+
end
47+
return
48+
return
49+
return
50+
end group
51+
52+
== State Machine: Idle State ==
53+
54+
group Wait for release
55+
App -> Mqtt : process()
56+
Mqtt -> App : release command
57+
App -> IdleState : release()
58+
return
59+
return
60+
return
61+
62+
end group
63+
64+
== State Machine: Driving State ==
65+
group Driving
66+
App -> Smp : process()
67+
Smp -> App : CurrentVehicleData
68+
App -> DrivingState : CurrentVehicleData
69+
return top speed
70+
App -> Smp : sendSpeed(topSpeed)
71+
Smp -> RU : send
72+
deactivate
73+
return
74+
return
75+
return
76+
77+
App -> Mqtt : process()
78+
Mqtt -> App : lastFollowerFeedbackCallback()
79+
App -> DrivingState : setLastFollowerFeedback(const Waypoint& feedback)
80+
return
81+
return
82+
return
83+
84+
App -> DrivingState : getLatestVehicleData(Waypoint& vehicleData)
85+
return vehicle data is valid
86+
87+
App -> Mqtt : sendWaypoint(const Waypoint& vehicleData)
88+
return
89+
90+
end group
91+
92+
== Stateless ==
93+
94+
loop
95+
App -> Smp : process()
96+
Smp -> App : Heartbeat callback
97+
App -> SafetyMonitor : heartbeatCallback()
98+
return
99+
return
100+
return
101+
102+
App -> SafetyMonitor : process()
103+
SafetyMonitor -> SafetyMonitor : checkHeartbeat()
104+
return false
105+
SafetyMonitor -> SM : setState(ErrorState)
106+
return
107+
return
108+
end loop
109+
110+
@enduml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
@startuml CommSequence
2+
3+
Title Sequence Diagram RU and DCS
4+
5+
autoactivate on
6+
7+
participant "RU" as RU
8+
participant "DCS" as DCS
9+
10+
note across: Possible STATUS = {STARTUP, OK, ERROR}
11+
12+
group State-Independent Messages
13+
RU --> DCS: STATUS: RU_STATE
14+
DCS --> RU: STATUS: DCS_STATE
15+
end
16+
17+
group StateLessSetup
18+
RU --> DCS: Subscribe: STATUS
19+
RU --> DCS: Subscribe: CMD
20+
RU --> DCS: Subscribe: SPEED_SETPOINT
21+
DCS --> RU: Subscribe: STATUS
22+
DCS --> RU: Subscribe: CMD_RSP
23+
DCS --> RU: Subscribe: CURRENT_VEHICLE_DATA
24+
end
25+
26+
group StatupState
27+
DCS -> RU: CMD: GetMaxSpeed
28+
RU -->> DCS: CMD_RSP:OK + maxSpeed
29+
DCS -> RU: CMD: SetInitialPosition
30+
RU -->> DCS: CMD_RSP:OK
31+
end
32+
33+
group LineSensorsCalibrationState
34+
35+
end
36+
37+
group IdleState
38+
DCS -> RU: CMD: Release
39+
RU -->> DCS: CMD_RSP:OK
40+
end
41+
42+
group DrivingState
43+
RU ->> DCS: CURRENT_VEHICLE_DATA:Data
44+
DCS -> DCS: CalculateSpeed
45+
return
46+
DCS --> RU: SPEED_SETPOINT: Top Center Speed
47+
end
48+
49+
group ErrorState
50+
51+
end
52+
53+
@enduml

0 commit comments

Comments
 (0)