-
Hi All, I need to develop my own Android app to control the hub as a remote control with advanced features. Using only an Xbox controller isn't sufficient for my needs, as I require additional real-time telemetry data to demonstate it on smartphone screen. I found a potential solution here: https://pybricks.com/projects/tutorials/wireless/hub-to-device/pc-communication/. To evaluate the issue, I created a small test program. It transmits a single value and runs one motor to measure the response time. However, I observed that commands are getting queued, causing the motor to execute stacked commands, changing speed and direction with noticeable delay. Please review my POC for hub. I've stripped out everything that could increase the latency:
My question is: is there an alternative solution for sending and receiving data without delays (similar to the Xbox controller approach) that would be compatible with connecting to an Android smartphone via BLE for use with a my custom app? I’m hoping there’s a native solution similar to this example: https://github.com/pybricks/micropython-bleradio/blob/master/examples/custom_irq.py. Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
I think my starting post was not clear, so I will try to simplify my needs: @laurensvalk , could you guide me in the right direction here? Here’s what I need to achieve:
Sound's pretty easy, but I still cannot find this for pybrick. Thanks. |
Beta Was this translation helpful? Give feedback.
-
Is it still slow with motor.dc instead of motor.run? Motor.run smoothly decelerates, so changing speed rapidly is going to appear slow when it is just physically taking time to stop or reverse. |
Beta Was this translation helpful? Give feedback.
-
As I realized, there is no other way to connect to the Hub under Pybricks control except the option mention above. I found a data transmission delay that allowed me to control the hub correctly. Of course, this won't replace the more preferred option of controlling it with an Xbox controller, but in order to not only control the model but also receive, processing and represent hub telemetry and sensor data, using a smartphone GUI this approach is much more convenient (at least for me). Here's a screenshot of the app: This is a demo video of how app connecting and controlling a test model with some feedback features like hub voltage, gyro and distance sensor data: https://youtube.com/shorts/6E0ajDd5fnM @laurensvalk, How do you think this example of app could be useful to add to the Hub-to-Hub Communications tutorials section on pybricks.com? |
Beta Was this translation helpful? Give feedback.
As I realized, there is no other way to connect to the Hub under Pybricks control except the option mention above. I found a data transmission delay that allowed me to control the hub correctly.
So I wrote my own Android app as an alternative way to control the Hub using a smartphone. I have shared the current realisation of my own Android BLE app with some basic functions:
https://github.com/czuryk/Lego/tree/main/PyBricks/BLE
Of course, this won't replace the more preferred option of controlling it with an Xbox controller, but in order to not only control the model but also receive, processing and represent hub telemetry and sensor data, using a smartphone GUI this approach is much more …