Skip to content

Robot Controller

Marco Marini edited this page Jan 15, 2024 · 19 revisions

The controller consists of 4 control processes.

The shutdown process consists of closing communication and active processes. It has priority over all the others and once completed the controller can no longer be activated.

The initialization process consists of establishing the connection with the robot and configuring it. During the initialization process, other processes are interrupted until the initialization process is completed. Initialization occurs when the controller starts and whenever the connection is lost.

The command sending process intervenes at pre-established intervals, checking whether new commands need to be sent always keep the robot aligned with the required commands (move, halt, scan). Whenever the requested status is different from the one previously sent or when more time than the command sending time has elapsed the process sends new commands to the robot.

The state update process receives the robot state by waiting a minimum interval and notifies the new state.

The processes of sending commands and updating the status are active only if the connection with the robot is active.

It is necessary to decouple control processes from inferential ones as they can have different processing times. The reaction times of control processes must be as fast as possible, while those of inferential processing can be slower. For this reason, an inferential process is defined which is activated at intervals not less than the defined reaction time which processes the last available state of the robot.

The events generated by the controller are:

  • new robot status
  • new inference process
  • communication error
  • start/completion of the initialization procedure
  • exceptions

in addition, events are added for the real controller

  • message received
  • message sent

The commands available to the inferential motor are those for controlling the robot:

  • move the sonar sensor
  • halt
  • move the robot

Main process

State diagram

stateDiagram-v2

[*] --> Connecting

Connecting --> Configuring: OK
Configuring --> HandleCommand: OK
HandleCommand--> Waiting: OK
Waiting --> HandleCommand: Timeout

Configuring --> Closing: Error
HandleCommand--> Closing: Error
Waiting --> Closing: Close requested

Closing --> [*]: if end
WaitingRetry --> [*]: if end

Closing --> WaitingRetry: if! not end
Connecting --> WaitingRetry: if error and not end
Connecting --> [*]: if error and end
Loading

Block diagram

flowchart TD

Start((Start))
Stop(((Stop)))
Shutdown((Shutdown))
Reconnect((Reconnect))

SetConnecting[CONNECTING]
SetConnecting1[CONNECTING]
SetConfiguring[CONFIGURING]
SetCommand[COMMMAND]
SetCommand1[COMMAND]
SetWaiting[WAITING]
SetClosing[CLOSING]
SetClosing2[CLOSING]
SetClosing5[CLOSING]
SetWaitingRetry[WAITING_RETRY]
SetWaitingRetry1[WAITING_RETRY]
End1[...]

SetEndTrue[end = true]
SetCloseTrue[close = true]
SetCloseTrue1[close = true]
SetCloseFalse[close = false]
SetOpenTrue[open = true]
SetOpenFalse[open = false]

IsEnd{Is end and \nCONNECTING?}
CheckStatus{Check Status}

Start --> SetConnecting --> CheckStatus

CheckStatus -- CONNECTING --> Connect -- OK --> SetConfiguring --> End1
Connect -- Error --> SetWaitingRetry --> End1

CheckStatus -- CONFIGURING --> Configure -- OK --> SetCloseFalse --> SetOpenTrue --> StartReader --> SetCommand--> End1
Configure -- Error --> SetClosing --> End1

CheckStatus -- COMMAND\n and not close --> HandleCommand -- OK --> SetWaiting --> End1

HandleCommand -- Error --> SetClosing2 --> End1

CheckStatus -- WAITING \nand not close --> Wait --> SetCommand1--> End1

CheckStatus -- WAITING \nand close --> SetClosing5 --> End1

CheckStatus -- CLOSING  --> SetOpenFalse --> Close --> SetWaitingRetry1 --> End1

CheckStatus -- WAITING_RETRY --> WaitRetry --> SetConnecting1 --> End1

End1 --> IsEnd

IsEnd -- Y --> Stop
IsEnd -- N --> CheckStatus

Shutdown --> SetEndTrue --> SetCloseTrue

Reconnect --> SetCloseTrue1

Loading

Reading process

flowchart TD

Start((Start))
Stop(((Stop)))

SetRepeatFalse[exit = true]
EndRepeat[...]

IsExit{not open or exit?}

Start --> IsExit -- N --> ReadStatus -- OK --> SetStatus --> EndRepeat
IsExit -- Y --> Stop
ReadStatus -- Error --> SetRepeatFalse --> EndRepeat
EndRepeat --> IsExit
Loading

Inferential process

flowchart TD

Start((Start))
Stop(((Stop)))

IsInit{init?}
IsEnd{End?}
HasStatus{Has status?}

IsEnd -- Y --> Stop
Start --> IsEnd -- N --> HasStatus -- Y --> IsInit -- Y --> Process --> Wait --> IsEnd
IsInit -- N --> Wait
HasStatus -- N --> Wait

Loading

Revision 0.12.1

Clone this wiki locally