Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leader App #74

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6c42756
Separated setup blocks into methods for better readability.
gabryelreyes Jan 17, 2024
242099e
Removed all unnecessary components
gabryelreyes Jan 17, 2024
78d2144
Created missing SMP channels
gabryelreyes Jan 17, 2024
244f37c
Added configurations for platoon participants
gabryelreyes Jan 15, 2024
3fb85ba
Sending initial data
gabryelreyes Jan 17, 2024
75ea40b
Added longitudinal controller
gabryelreyes Jan 17, 2024
fc8acc2
Added starting heading according to LineFollowerTrack
gabryelreyes Jan 17, 2024
564343e
Added more constructors and utilities to Waypoint class
gabryelreyes Jan 18, 2024
e4002a6
Removed unnecessary members and includes
gabryelreyes Jan 18, 2024
f6cc62d
Updated application
gabryelreyes Jan 18, 2024
7635f7d
Removed unncessary packed attribute
gabryelreyes Jan 18, 2024
88563cc
Send waypoints to follower
gabryelreyes Jan 18, 2024
8715c64
Fixed debug message
gabryelreyes Jan 19, 2024
11ccef5
Initial position sent using a command and not a dedicated channel
gabryelreyes Jan 22, 2024
9b35d91
Added new architecture diagrams
gabryelreyes Jan 22, 2024
f1bb06e
Simplified leader app sequence
gabryelreyes Jan 23, 2024
b3883ae
Added SMP Channels descriptions
gabryelreyes Jan 23, 2024
83b7f60
Added State Machine components
gabryelreyes Jan 23, 2024
b62887d
Defined SMPServer as typedef of templated Server
gabryelreyes Jan 23, 2024
b83f102
Introduced State Machine and startup state
gabryelreyes Jan 23, 2024
e5b4fe7
Added Startup State
gabryelreyes Jan 23, 2024
62d7cce
Fixed include order
gabryelreyes Jan 23, 2024
8215470
Fixed and updated snippets to latest copyright
gabryelreyes Jan 23, 2024
f9643d9
Processing of periodic tasks separated
gabryelreyes Jan 23, 2024
921e4ae
Added missing nothrow
gabryelreyes Jan 24, 2024
74e674b
Added Idle State
gabryelreyes Jan 24, 2024
ccb7bc8
Added driving state.
gabryelreyes Jan 24, 2024
8056d56
fixed CI findings
gabryelreyes Jan 24, 2024
58de6d8
Ru must not be released, as it waits for a speed different to 0
gabryelreyes Jan 24, 2024
981d570
Added Error State
gabryelreyes Jan 24, 2024
9f13513
Moved RemoteControl Commands and responses to SerialMuxChannels
gabryelreyes Jan 24, 2024
c20b01b
Fixed CI findings
gabryelreyes Jan 24, 2024
5cf133c
Fixed PR findings
gabryelreyes Jan 24, 2024
89c4b4a
Implemente concat for String class
gabryelreyes Jan 24, 2024
34fc984
Checked birht message serialization
gabryelreyes Jan 24, 2024
0b68851
removed unnecessary member variable
gabryelreyes Jan 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions doc/architecture/uml/LogicalView/Leader/Leader.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
@startuml DcsClassDiagram

Title DCS Class Diagram

class "Application" as app {
+ setup() : void
+ loop() : void
+ release() : void
- m_serialMuxProtServer : SMPServer
- m_systemStateMachine : StateMachine
- m_remoteControlHandler : RemoteControlHandler
- m_safetyMonitor : SafetyMonitor
}

note right of app
Callbacks for SerialMuxProtServer and MqttClient are defined here.
Uses the setters of each class or state to forward the data.
Uses the getters of each class or state to get the data that shall be sent to the RU or the V2V controller.
end note

class "V2V Controller" as v2v {
- m_mqttClient : MqttClient
- m_rxWaypointQueue : Queue
+ init(MqttConfig) : bool
+ process() : bool
+ sendWaypoint(const Waypoint&) : bool
+ getWaypoint(Waypoint&) : bool
}

class StateMachine <<control>> {
+ setState(state : IState*) : void
+ getState() : IState*
+ process() : void
}

class "RemoteCommandResponseHandler" as smpHandler {
+ processResponse(const CommandResponse&) : void
}

note right of smpHandler
This class is responsible for handling
the response from the remote command
sent to RU.
- Notifies StartupState of successful commands.
- Sets max speed in DrivingState.
end note

class "SafetyMonitor" as safety {
+ process(StateMachine& sm) : void
+ getPendingHeartbeat(const Hearbeat& hb) : bool
+ heartbeatCallback(const Hearbeat& hb) : void
}

interface IState {
+ {abstract} entry() : void
+ {abstract} process(sm : StateMachine&) : void
+ {abstract} exit() : void
}

class StartupState <<Singleton>>
{
+ getPendingCommand(Command& cmd) : bool
+ notify(Event event) : void
}

class IdleState <<Singleton>>

class DrivingState <<Singleton>> {
- m_longitudinalController : LongitudinalController
+ setMaxMotorSpeed(int16_t maxMotorSpeed) : void
+ calculateTopMotorSpeed(const Waypoint& currentVehicleData): int16_t
+ setLastFollowerFeedback(const Waypoint& feedback) : void
+ getLatestVehicleData(Waypoint& vehicleData) : bool
}

protocol "SerialMuxChannels" as smpch {
+ typedef SerialMuxProtServer<MAX_CHANNELS> SMPServer
+ struct Command
+ struct CommandReponse
+ struct SpeedData
+ struct VehicleData
}

app *--> v2v
app *--> StateMachine
app *--> smpHandler
app *--> safety
app ..> DrivingState: <<use>>
app ..> StartupState: <<use>>
app ..> smpch: <<use>>

StateMachine o--> "0..1" IState

IState <|.. StartupState: <<realize>>
IState <|.. IdleState: <<realize>>
IState <|.. DrivingState: <<realize>>
IState <|.. ErrorState: <<realize>>

smpHandler ..> StartupState: <<use>>
smpHandler ..> DrivingState: <<use>>

@enduml
131 changes: 131 additions & 0 deletions doc/architecture/uml/ProcessView/Leader/AppSequence.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
@startuml LeaderAppSequenceDiagram

autoactivate on

Title Leader App Sequence Diagram

participant "App" as App
participant "State Machine" as SM
participant "SMP Server" as Smp
participant "V2V Client" as Mqtt
participant "Remote Command Response Handler" as RCRH
participant "Startup State" as StartupState
participant "Driving State" as DrivingState
participant "Safety Monitor" as SafetyMonitor

entity "RadonUlzer" as RU

== State Machine: Startup State ==

group Startup Commands [Repeats for each pending command]
App -> SM : process()
SM -> StartupState : process()
return
return

App -> StartupState : getPendingCommand(Command& cmd) : bool
StartupState -> SM: inCorrectState()
return true
return pending command is valid

App -> Smp : sendCommand(cmd) : bool
Smp -> RU : send
deactivate
return command sent

RU -->> Smp : response

App -> Smp : process()
Smp -> App : CMD_RSP callback
App -> RCRH : handleCommandResponse(rsp)
RCRH -> StartupState : notify(Event event)
return
RCRH -> DrivingState : setMaxSpeed(speed)
return
return
return
return
end group

App -> SM : process()
SM -> StartupState : process()
StartupState -> SM : setState(IdleState)
return
return
return

== State Machine: Idle State ==

group Wait for release
App -> Mqtt : process()
Mqtt -> App : cmdCallback(releaseCmd)
App -> Smp : sendCommand(releaseCmd)
Smp -> RU : send
deactivate
return
return
return

RU -->> Smp : response

App -> Smp : process()
Smp -> App : CMD_RSP callback
App -> RCRH : handleCommandResponse(OK)
RCRH -> SM : setState(DrivingState)
return
return
return
return
end group

== State Machine: Driving State ==
group Driving
App -> Smp : process()
Smp -> App : currentVehicleDataCallback(CurrentVehicleData data)
App -> DrivingState : calculateTopMotorSpeed(const Waypoint& currentVehicleData): int16_t
DrivingState -> SM : inCorrectState()
return true
return top speed
App -> Smp : sendSpeed(topSpeed)
Smp -> RU : send
deactivate
return
return
return

App -> Mqtt : process()
Mqtt -> App : lastFollowerFeedbackCallback()
App -> DrivingState : setLastFollowerFeedback(const Waypoint& feedback)
return
return
return

App -> DrivingState : getLatestVehicleData(Waypoint& vehicleData)
DrivingState -> SM : inCorrectState()
return true
return vehicle data is valid

App -> Mqtt : sendWaypoint(const Waypoint& vehicleData)
return

end group

== Stateless ==

loop
App -> Smp : process()
Smp -> App : Heartbeat callback
App -> SafetyMonitor : heartbeatCallback()
return
return
return

App -> SafetyMonitor : process()
SafetyMonitor -> SafetyMonitor : checkHeartbeat()
return false
SafetyMonitor -> SM : setState(ErrorState)
return
return
end loop

@enduml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
@startuml CommSequence

Title Sequence Diagram RU and DCS

autoactivate on

participant "RU" as RU
participant "DCS" as DCS

note across: Possible STATUS = {STARTUP, OK, ERROR}

group State-Independent Messages
RU --> DCS: STATUS: RU_STATE
DCS --> RU: STATUS: DCS_STATE
end

group StateLessSetup
RU --> DCS: Subscribe: STATUS
RU --> DCS: Subscribe: CMD
RU --> DCS: Subscribe: SPEED_SETPOINT
DCS --> RU: Subscribe: STATUS
DCS --> RU: Subscribe: CMD_RSP
DCS --> RU: Subscribe: CURRENT_VEHICLE_DATA
end

group StatupState
DCS -> RU: CMD: GetMaxSpeed
RU -->> DCS: CMD_RSP:OK + maxSpeed
DCS -> RU: CMD: SetInitialPosition
RU -->> DCS: CMD_RSP:OK
end

group LineSensorsCalibrationState

end

group IdleState
DCS -> RU: CMD: Release
RU -->> DCS: CMD_RSP:OK
end

group DrivingState
RU ->> DCS: CURRENT_VEHICLE_DATA:Data
DCS -> DCS: CalculateSpeed
return
DCS --> RU: SPEED_SETPOINT: Top Center Speed
end

group ErrorState

end

@enduml
43 changes: 43 additions & 0 deletions doc/architecture/uml/ProcessView/Leader/StateMachine.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
@startuml DcsStateMachine

Title DroidControlShip ConvoyLeader State Machine

hide empty description

state StatelessSetup
state ErrorState
state StartupState
state IdleState
state DrivingState

[*] --> StatelessSetup: Power up
StatelessSetup -right-> StartupState : [Basic services initialized]
StatelessSetup --> ErrorState: [Basic services init failed]

StartupState --> IdleState : [Initial data loaded and exchanged]
StartupState --> ErrorState : [Error in initialization]

IdleState --> DrivingState : [Release command received]
IdleState --> ErrorState : [Lost connection to RU]

DrivingState --> IdleState : [Stop command received]
DrivingState --> ErrorState : [Error while driving]

note left of StatelessSetup
Initialization of:
- Logger
- HAL
- Network
- MQTT
- SMP
- Longitudinal Controller
end note

note right of StartupState
Establish connections:
- Network
- MQTT
- SMP
end note

@enduml
Loading