BirdBrainTechnologies / BirdBrain-Python-Library

This library issues http requests to the Hummingbird Bit and micro:bit via the BlueBird Connector. You must have the BlueBird Connector installed and running for it to work!
GNU General Public License v3.0
0 stars 3 forks source link

Need help in Getting LED Values #1

Open parassharma2809 opened 1 year ago

parassharma2809 commented 1 year ago

Hey,

We are trying to retrieve the LED/TriLED values from the hummingbird, but there is no direct API provided in the birdbrain.py that can do this. We tried the getSensor API but it just works for the 3 ports with the external sensors. We have a use case where we want to get the values for the LEDs/TriLEDs/Servos directly from the hummingbird bit. We looked into the servlet too for Hummingbird which said that it supports an endpoint /in/led to get the led value. We tried that but it returns an empty response even after connecting the LEDs and trying to get the value from all the ports. Can you please help us with this and let us know if it is possible or do we need to do something else at our end to enable this feature? Also, if it is possible to do this, do we need to set the LED first to get that value (We tried both ways and nothing worked)?

birdbraintech commented 1 year ago

Can you tell us more about your use case? We may be able to adapt the library to provide methods that return the values that the LEDs and servos were most recently set to. That said, they may not be perfectly synced with the actual values on the Hummingbird controller because of Bluetooth packet loss (rare but does happen). There is no way to retrieve the settings from the Hummingbird controller directly.

parassharma2809 commented 1 year ago

So one of the use cases that we have is we want to be able to detect programmatically as soon as an LED or TriLED or Servo is attached to the Hummingbird controller. For that, we were thinking of periodically polling some API that could return us the values of these sensors from the micro bit. That was our reason to go in the direction of using getSensor API. But we weren't able to use it or find any other API that gives us the LED values.

Another way that we were thinking of doing this was to write some code that uses the Pin and Microbit Python Libraries to directly access the pins and then flash this code on the micro bit to get the values. But this won't work as if we'll flash something custom onto the micro bit, it'll remove the previous hummingbird hex file.

We were thinking it should be possible to get the values from LEDs and other sensors as anyway the values from the external sensors are being pulled. Any help in this regard would be appreciated.

birdbraintech commented 1 year ago

Hi Paras, the LED and servo ports are not instrumented in this way - there's no hardware checking if an LED or Servo is plugged into a port. You could potentially do something very complex: create an off-board current measurement circuit that outputs a voltage from 0-3 V that can be read by one of the regular sensor ports. This would work for up to 3 LEDs/servos. Possibly if all you want to know is whether something is plugged in or not, you could expand this more components.

parassharma2809 commented 1 year ago

Hi, thanks for your reply and your suggestion regarding this. We are researchers from the University of Pittsburgh and are very excited to work with Hummingbird this summer in our research studies. There was one more thing. In the HummingBirdServlet.java file (servlet) there are endpoints "led/" and "triled/" which led us to believe that it might be possible to get the values of the led and triled at a point. Just wanted to make sure that those also won't work and won't give us the correct values of the sensors. Because based on the endpoints of the server in that repository it seemed to us that it might be the server to which the birdbrain.py script is sending its request to.

birdbraintech commented 1 year ago

The code you linked to is for the BirdBrain Robot Server, which was made for the Hummingbird Duo and original Hummingbird kit. The Duo is still available for sale, but most people use the newer Hummingbird Bit, and this Python library is for the Hummingbird Bit. The Duo also does not have the capability to read if a servo or LED is attached to it - I am not sure why we made an /in/led endpoint in the code, but at best they would return what those outputs are being set to. Please let us know how your projects progress and if we can provide any other assistance - happy to help!

On Tue, May 23, 2023 at 10:32 AM Paras Sharma @.***> wrote:

Hi, thanks for your reply and your suggestion regarding this. We are researchers from the University of Pittsburgh and are very excited to work with Hummingbird this summer in our research studies. There was one more thing. In the HummingBirdServlet.java file (servlet https://github.com/BirdBrainTechnologies/BirdBrainRobotServer/blob/master/src/birdbrain/finchandHummingbirdServer/HummingbirdServlet.java) there are endpoints "led/" and "triled/" which led us to believe that it might be possible to get the values of the led and triled at a point. Just wanted to make sure that those also won't work and won't give us the correct values of the sensors. Because based on the endpoints of the server in that repository it seemed to us that it might be the server to which the birdbrain.py script is sending its request to.

— Reply to this email directly, view it on GitHub https://github.com/BirdBrainTechnologies/BirdBrain-Python-Library/issues/1#issuecomment-1559538163, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABIYEOFWF2SEGBVW44QTEPTXHTC67ANCNFSM6AAAAAAYG4IABY . You are receiving this because you commented.Message ID: @.*** .com>