diff --git a/.gitignore b/.gitignore index a8a6e51..ec6f810 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ # autogenerated files -lib/cmn_hdrs/ros_info.h +/lib/cmn_hdrs/ros_info.h *.pyc + +# PlantUML diagram export directory +/diagrams/out/ diff --git a/projects/can_transceiver/diagrams/common_sequence.puml b/projects/can_transceiver/diagrams/common_sequence.puml new file mode 100644 index 0000000..95bca74 --- /dev/null +++ b/projects/can_transceiver/diagrams/common_sequence.puml @@ -0,0 +1,37 @@ +@startuml common_sequence +title Local Transceiver Common Sequence + +!include %getenv("PLANTUML_TEMPLATE_PATH") + +autonumber + +!startsub PARTICIPANTS +box "Common Sequence" +participant CanTransceiver as can +participant CanTransceiverRosIntf as ros_intf +end box +== Inbound == +!endsub PARTICIPANTS + +-> can : Inbound Sensor(s) [CAN] + +!startsub SEQUENCE + +activate can +can -> can : Convert from CAN to ROS +can -> can : Filter Sensor(s) +can -> ros_intf --++ : Transmit Sensor(s) [ROS] +ros_intf -> : Publish sensor(s) to Software ROS Network +deactivate ros_intf + +== Outbound == + +ros_intf <- ++ : Command(s) from Software ROS Network (ex. Desired Heading) +can <- ros_intf --++ : Transmit Command(s) [ROS] +can -> can : Convert Command(s) from ROS to CAN +!endsub SEQUENCE + +<- can : Outbound Command(s) [CAN] +deactivate can + +@enduml diff --git a/projects/can_transceiver/diagrams/deployment_sequence.puml b/projects/can_transceiver/diagrams/deployment_sequence.puml new file mode 100644 index 0000000..f1d9174 --- /dev/null +++ b/projects/can_transceiver/diagrams/deployment_sequence.puml @@ -0,0 +1,16 @@ +@startuml deployment_sequence +title Local Transceiver Deployment Sequence + +!include %getenv("PLANTUML_TEMPLATE_PATH") + +autonumber + +!includesub common_sequence.puml!PARTICIPANTS + +-> can : Sensors from ELEC [CAN] + +!includesub common_sequence.puml!SEQUENCE + +<- can -- : Transmit Command(s) to ELEC [CAN] + +@enduml diff --git a/projects/can_transceiver/diagrams/simulation_sequence.puml b/projects/can_transceiver/diagrams/simulation_sequence.puml new file mode 100644 index 0000000..43578fb --- /dev/null +++ b/projects/can_transceiver/diagrams/simulation_sequence.puml @@ -0,0 +1,29 @@ +@startuml simulation_sequence +title Local Transceiver Simulation Sequence + +!include %getenv("PLANTUML_TEMPLATE_PATH") + +autonumber + +box "Simulation Sequence" +participant CanSimIntf as sim_intf +participant CanSimTransceiver as sim_t +end box + +!includesub common_sequence.puml!PARTICIPANTS + +-> sim_intf ++ : Mock Sensors from Simulator [ROS] +sim_intf -> sim_t --++ : Process Mock Sensors [ROS] +sim_t -> sim_t : Convert ROS sensor object to CAN +sim_t --> can -- : Call new Sensors API [CAN] +deactivate sim_intf +note right sim_t : API call should be async to replicate deployment behavior. + +!includesub common_sequence.puml!SEQUENCE + +sim_t <-- can --++ : Call Write to CAN API +note left can : API call should be async to replicate deployment behavior. +sim_t -> sim_t : Convert Command(s) from CAN to ROS +sim_intf <- sim_t --++ : Transmit Command(s) [ROS] +activate sim_intf +<- sim_intf -- : Publish Command(s) to Simulator [ROS] diff --git a/projects/local_transceiver/diagrams/common.puml b/projects/local_transceiver/diagrams/common.puml new file mode 100644 index 0000000..63c2147 --- /dev/null +++ b/projects/local_transceiver/diagrams/common.puml @@ -0,0 +1,19 @@ +' To be included by other files. Do not use on its own. +@startuml common + +box Modules +participant "Local Transceiver ROS Intf" as intf +participant "Local Transceiver" as local +end box + +box Resources +Collections "Sensor Buffer" as buf +Queue "Serial Port" as port +end box + +note across + As ROS is used for synchronizing access to resources, the module control + flow is blocking, meaning only one subsequence can happen at at a time. +end note + +@enduml diff --git a/projects/local_transceiver/diagrams/receive_global_path_sequence.puml b/projects/local_transceiver/diagrams/receive_global_path_sequence.puml new file mode 100644 index 0000000..e5a672f --- /dev/null +++ b/projects/local_transceiver/diagrams/receive_global_path_sequence.puml @@ -0,0 +1,24 @@ +@startuml receive_global_path_sequence +title Local Transceiver Receive Global Path Sequence + +!include %getenv("PLANTUML_TEMPLATE_PATH") +!include common.puml + +autonumber + +== Update Global Waypoints Subsequence == + +note over buf : Unused + +intf -> intf ++ : Update Timer Triggers +intf -> local ++ : Get Global Waypoints +local -> local : Create Global Waypoints Object +loop While Iridium Mailbox is Not Empty &&\nThere are Global Waypoints Remaining + local --> port : Issue AT Read Command + local <-- port : Read response + local -> local : Update Global Waypoints Object +end +opt If New Global Waypoints + intf <- local -- : Return New Global Waypoints + <- intf -- : Publish Global Waypoints +end diff --git a/projects/local_transceiver/diagrams/transmit_sensors_sequence.puml b/projects/local_transceiver/diagrams/transmit_sensors_sequence.puml new file mode 100644 index 0000000..c0fc227 --- /dev/null +++ b/projects/local_transceiver/diagrams/transmit_sensors_sequence.puml @@ -0,0 +1,40 @@ +@startuml transmit_sensors_sequence +title Local Transceiver Transmit Sensors Sequence + +!include %getenv("PLANTUML_TEMPLATE_PATH") +!include common.puml + +autonumber + +== Update Sensors Subsequence == + +note across : Very Frequent - On Demand Execution + +-> intf ++ : New Sensor Data +intf -> local ++ : Update Sensor +local -> local : Convert Data from ROS to Google Protobuf +local --> buf : Store Sensor in Buffer +deactivate intf +deactivate local + +... + +== Transmit Sensors Subsequence == + +note across : Very Infrequent - Execute Every Few Hours + +intf -> intf ++ : Transmit Timer Triggers +intf -> local ++ : Start Transmission +local <-- buf : Read Current Sensors +local -> local : Serialize Sensor Data +local -> local : Create AT Write Binary Command With Data +note right of local : If payload is too large, split the data across multiple commands +loop Until Successful or Unsuccessful Attempts + local --> port : Write Command + local <-- port : Read Response +end +opt If Failed to Transmit Sensors Data + intf <- local -- : Return failure + intf -> intf : Set Shorter Transmit Timer Interval +end +deactivate intf diff --git a/projects/remote_transceiver/diagrams/common.puml b/projects/remote_transceiver/diagrams/common.puml new file mode 100644 index 0000000..ee3c27d --- /dev/null +++ b/projects/remote_transceiver/diagrams/common.puml @@ -0,0 +1,16 @@ +' To be included in other files, do not use on its own +@startuml common + +box Modules +participant "HTTP Handler" as handler +participant "HTTP Server" as server +participant SailbotDB as db +end box + +note over handler, server + Part of the same class. The handler is separated from the + server in the diagram to illustrate that the server does + not block on requests, and multiple can be handled simultaneously. +end note + +@endmul diff --git a/projects/remote_transceiver/diagrams/receive_sensors_sequence.puml b/projects/remote_transceiver/diagrams/receive_sensors_sequence.puml new file mode 100644 index 0000000..780fe79 --- /dev/null +++ b/projects/remote_transceiver/diagrams/receive_sensors_sequence.puml @@ -0,0 +1,35 @@ +@startuml receive_sensors_sequence +title Remote Transceiver Receive Sensors Sequence + +!include %getenv("PLANTUML_TEMPLATE_PATH") +!include common.puml + +autonumber + +box Resources +Collections "Sensors Buffer" as buf +Database "MongoDB" as mongo +end box + +note over buf : Contents of this buffer are \nunparsed, raw binary strings + +-> handler ++ : POST Sensors +handler -> server --++: Process POST Request +server -> server : Parse HTTP +server --> buf : Update Sensors Buffer +alt If Incomplete Sensors Payload + handler <- server --++ : Return OK + <- handler -- : Send Response + +else Else All Sensor Payloads Received + activate server + handler <-- server ++ : Return OK + note right of server : Execution continues after returning HTTP response + <- handler -- : Send Response + server <-- buf : Read Entire Buffer + server -> server : Parse Protobuf Sensors Object from Binary + server -> db ++ : Commit Sensors to DB + db -> db : Convert Sensors to BSON Format + db --> mongo -- : Write Sensors to MongoDB + deactivate server +end diff --git a/projects/remote_transceiver/diagrams/transmit_global_path_sequence.puml b/projects/remote_transceiver/diagrams/transmit_global_path_sequence.puml new file mode 100644 index 0000000..f8d1bb8 --- /dev/null +++ b/projects/remote_transceiver/diagrams/transmit_global_path_sequence.puml @@ -0,0 +1,30 @@ +@startuml transmit_global_path_sequence +title Remote Transceiver Transmit Global Path Sequence + +!include %getenv("PLANTUML_TEMPLATE_PATH") +!include common.puml + +autonumber + +note over db : Unused + +-> handler ++ : POST Global Path +handler -> server --++ : Process POST request +server -> server : Parse HTTP Request for Waypoints +server -> server : Convert Waypoints to Protobuf and Serialize +opt If Waypoints are too Large for One Message + server -> server : Split Waypoints Across Multiples Messages +end +loop For Each Waypoint Message + server -> handler ++ : Transmit Waypoints + <-- handler : POST Waypoints to Iridium + handler -> server -- : POST complete + note over handler, server + To prevent out of order transmissions on random + POST failures, POSTING to Iridium should be a + blocking operation. + end note +end +deactivate server + +@enduml