Announcement

Collapse
No announcement yet.

Robot Controller app using UI thread

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Robot Controller app using UI thread

    Hello,
    Our team recently received our set and have built a basic robot. While running the example K9TankDrive OpMode, the robot controller phone had a dialog open, which stopped the UI thread (until the dialog was finished) and caused the robot to be stuck and continue moving forward although we had stopped moving the joysticks forward. This led us to believe that the FTC Robot Controller app was running on the UI thread.

    We were wondering if the FTC SDK code will be changed so that processes will be done on a worker thread instead of the UI thread, as the Android design guidelines recommend: "In any situation in which your app performs a potentially lengthy operation, you should not perform the work on the UI thread, but instead create a worker thread and do most of the work there." We believe that this will be necessary as FTC robots may need to do intensive calculations, and it may cause the program to freeze.

    Thanks,
    Team 4855

  • #2
    I believe it does run on the UI thread from what Tom Eng's said in the past, which is doing it completely wrong.
    The workaround for heavy computation is to spawn another thread to do it and use inter-thread communication to communicate with it,
    for resources see this and this.

    ~liam

    Comment


    • #3
      We do not control the robot from the UI thread. You can see this for yourself by going into developer options and enabling strict mode. Your robot stopped responding for other reasons.

      Comment


      • #4
        Thank you for your quick response. We will try to pinpoint the source of the error.

        Thanks,
        Team 4855

        Comment


        • #5
          Android Apps have a "lifecycle" that needs to be carefully managed by the developer to avoid hang-ups. This is just a guess, but it sounds like the robot controller app may have been "paused" and "resumed" by the system. If those system events are not explicitly handled in the code for the UI thread then it could potentially cause unexpected behavior. Other than the response from Jonathan above, I'm not sure how these events are handled on the UI thread in the FTC SDK:
          http://developer.android.com/trainin...cle/index.html
          Hope this helps.

          Comment

          Working...
          X