mintuz / BB8-Commander

A Node CLI Tool for the Sphero BB8 Robot every loves.
MIT License
70 stars 17 forks source link

[IDEA] - Crowd Source AI #5

Open mintuz opened 8 years ago

mintuz commented 8 years ago

Let someone else control your BB8 when you can't. We then AI! :trollface:

ShahNewazKhan commented 7 years ago

Hi @mintuz I am currently working on an idea to use a reinforcement learning algorithm ( https://github.com/karpathy/reinforcejs ) where we use the velocity, distance traveled and heading from BB8 as inputs. The output will be the actions roll forward, backwards, turn left or turn right and based on collision detection, feedback a reward to the RLA so that it can adjust to behaviors where it avoids collisions and hopefully maps out a room.

The issue I am facing is where OSX is unable to get a response back from BB8 once a command is issued:

Unhandled rejection Error: Command sync response was lost.
    at Sphero.handler (/Users/shah/projects/node/ai8/node_modules/sphero/lib/sphero.js:252:21)
From previous event:
    at Sphero.command (/Users/shah/projects/node/ai8/node_modules/sphero/lib/sphero.js:180:10)
    at Sphero.device.setRgbLed (/Users/shah/projects/node/ai8/node_modules/sphero/lib/devices/sphero.js:369:12)
    at Sphero.device.color (/Users/shah/projects/node/ai8/node_modules/sphero/lib/devices/custom.js:168:19)
    at file:///Users/shah/projects/node/ai8/js/orb.js:7:7

My current environment is:

ProductName:    Mac OS X
ProductVersion: 10.11.6
BuildVersion:   15G31

node -v
v6.9.5

npm -v 
3.10.10

system_profiler SPBluetoothDataType | sed -n "/Apple Bluetooth Software Version\:/,/Manufacturer\:/p" | tr -s "[\n]" "[ ]" | sed "s:.*Address\: ::g" | sed "s: Manufacturer\:.*::g" | grep "[[:graph:]]"

80-E6-50-1B-50-31 Bluetooth Low Energy Supported: Yes Handoff Supported: Yes Instant Hot Spot Supported: Yes

Do you have any inputs towards this?

mintuz commented 7 years ago

Hey this is a great idea, really look forward to see what you can achieve with it as for the issue you are seeing, I've not seen this before but can take a look for you at the weekend if you still haven't got anywhere with it by then.

My initial thoughts though may be a compatibility issue with the Sphero API and the version of node you are using as that's the only difference between your machine and mine. I am running node v4.2.4 at the moment.

It may also be to do with how you are running BB8 Commander, I haven't used it as a library in an external project for a while and it was a really basic project just to test the functionality. Maybe there's a bug in there somewhere.

I will certainly take a look at the weekend though if you haven't managed to figure it out. If you do find out if it's an issue with BB8-Commander itself please do raise a PR.

ShahNewazKhan commented 7 years ago

Thanks for looking into this, I actually have not tried this with the Commander module yet, I am having issues with the vanilla SpheroJs module. I will give it a try with the Commander module and let you know how it goes.

As for the reinforcement learning portion, I believe the temporal limitations of the DQN algorithm might limit BB8 from learning to map a room as the steps taken to get a negative reward will be too far in time between positive rewards.

In any event we will have to cross that bridge when we get there!

UPDATE:

I tried the BB8 Commander CLI module and received the following error:

$bb8 power

Getting battery Info

Beep Boop!! Something went wrong !
 Error: Command sync response was lost.
    at Sphero.cb (/usr/local/lib/node_modules/bb8-commander/node_modules/sphero/lib/sphero.js:243:21)
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
    at Timer.listOnTimeout (timers.js:207:5)