artificial-intelligence-class / spherov2.py

Unofficial Python API for all Sphero toys
MIT License
63 stars 24 forks source link

Sensor values for BB8? #18

Closed berickson closed 2 years ago

berickson commented 2 years ago

This is similar to #16, but for BB8. I have a BB8 and can control lights and movement, but all sensors read None. It looks like no sensor messages are coming back from the robot. I wouldn't mind hacking it myself if I got a little direction on what might be required. Fixing uuids? Message filters?

superfashi commented 2 years ago

Huh based on what we currently have, BB8 seems to have the same set of sensors as Sphero, which uses v1 controls (spherov2/controls/v1.py). Can you add some debugging output on SensorControl class in v1.py and see if it sends back any data at all?

berickson commented 2 years ago

Thanks. I'll try that.

berickson commented 2 years ago

I added some logging and found messages being sent back to __new_packet, but then being ignored with key of (254, 3).

To get myself running, I took a line from commands/async_.py and used it to replace code in sensor.py as below:

I replaced sensor_streaming_data_notify = ( (24, 2, 0xff), lambda listener, p: listener(list(struct.unpack('>%df' % (len(p.data) // 4), p.data)))) with sensor_streaming_data_notify = ( (0xfe, 3), lambda listener, p: listener(list(struct.unpack('>%dh' % (len(p.data) // 2), p.data)))) This got me running and sensor values are working, but I'm guessing this would break other robots if they were previously working.

superfashi commented 2 years ago

I see. This commit https://github.com/artificial-intelligence-class/spherov2.py/commit/c33848f6a859359ee615b3e0a53e12331d57434e messed it up. @Cole1220 we need to revert it back I will actually do a review of the current implementation and then update it.

superfashi commented 2 years ago

should be fixed. can you try https://github.com/artificial-intelligence-class/spherov2.py/commit/2f11b4e68ab4829972ba4e84bf23844c141f2266 (the current main branch)?

berickson commented 2 years ago

I tested the latest main branch on my BB8 and this is fixed.