Imports System.Threading
Imports System.Drawing


Module modBackground
    Public Class classBackground
        Public Sub subBackgroundMonitor()
            ' Background Thread
            '    updates Bot's odometry  
            '    monitors 'moving' and sets tmiMoveInfo.boolBotIsMoving to FALSE at end of move
            Try
                Thread.CurrentThread.Name = "threadBackground"
                While Not boolShutDown
                    If tmiMoveInfo.boolBotIsMoving Then ' 
                        Do
                            tbpBotPose = ftnLocalizeUsingOdometry(tbpBotPose)
                            If boolSlam And Not boolLocalizationInProgress Then tbpBotPose = ftnLocalizeRBPF_Top(tbpBotPose, True) ' 
                            subwait(50)
                        Loop Until CBool(InStr(ftnSendCommand("moving"), "False"))
                        ftnSetMoveInfo(tmiMoveInfo.tomTypeOfMove, tmiMoveInfo.tbpStartingPose, tmiMoveInfo.tbpTargetPose, False)
                    End If
                    subWait(550)
                End While
            Catch ex As Exception
                frmDebug.subWriteLogs(" EXCEPTION in subBackgroundMonitor :  " & ex.ToString)
            End Try
        End Sub



    End Class
End Module
