OpenBot leverages smartphones as brains for low-cost robots. We have designed a small electric vehicle that costs about $50 and serves as a robot body. Our software stack for Android smartphones supports advanced robotics workloads such as person following and real-time autonomous navigation.
Bug Description
App crashes in the Object Tracking Fragment when the Auto Mode switch is activated.
To Reproduce
Steps to reproduce the behavior:
Go to Object Tracking
Turn on the Auto Mode switch
App may immediately crash
Logcat:
07-22 12:02:06.196 26472-26554/org.openbot E/AndroidRuntime: FATAL EXCEPTION: inference
Process: org.openbot, PID: 26472
android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:8203)
at android.view.ViewRootImpl.invalidateChildInParent(ViewRootImpl.java:1309)
at android.view.ViewGroup.invalidateChild(ViewGroup.java:5430)
at android.view.View.invalidateInternal(View.java:13959)
at android.view.View.invalidate(View.java:13923)
at android.view.View.invalidate(View.java:13907)
at android.widget.TextView.checkForRelayout(TextView.java:8373)
at android.widget.TextView.setText(TextView.java:5001)
at android.widget.TextView.setText(TextView.java:4828)
at android.widget.TextView.setText(TextView.java:4803)
at org.openbot.objectNav.ObjectNavFragment.handleDriveCommand(ObjectNavFragment.java:500)
at org.openbot.objectNav.ObjectNavFragment.lambda$processFrame$20$ObjectNavFragment(ObjectNavFragment.java:481)
at org.openbot.objectNav.-$$Lambda$ObjectNavFragment$0cdHF_u8fuQJw1ABfb-EY_bHL6g.run(lambda)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.os.HandlerThread.run(HandlerThread.java:61)
Fix
In ObjectNavFragment.handleDriveCommand the textview controlInfo is being updated from a child thread. It should be called from the main thread, in this way:
Bug Description App crashes in the Object Tracking Fragment when the Auto Mode switch is activated.
To Reproduce Steps to reproduce the behavior:
Fix In ObjectNavFragment.handleDriveCommand the textview controlInfo is being updated from a child thread. It should be called from the main thread, in this way:
In the same way, the onConnectionEstablished is updating another text view:
This is similar to this issue
Screenshots Here is the gif for a better explanation:
Smartphone (please complete the following information):