igbopie / spherov2.js

Unofficial Sphero V2 api for new toys like Sphero Mini, Lighting McQueen
MIT License
87 stars 36 forks source link

Some commands for R2D2 #31

Closed dtzolov214 closed 3 years ago

dtzolov214 commented 5 years ago

Hello,

firt of all, great project! I analyzed the bluetooth packets for R2D2 and would like to share my findings. Since I am not skilled in Nodes I tried this with python and bluepy. I tried to adapt the commands for user-io.js accordingly, please have a look and take it over.

Thank you and regards

Dimi

// Set R2D2 main LED color based on RGB vales (each can range between 0 and 255) // same like front LED color setR2D2LEDColor: (r,g,b) => encode({ commandId: types_1.UserIOCommandIds.allLEDs, payload: [0x00, 0x77, r, g, b, r, g, b] }),

// Set R2D2 front LED color based on RGB vales (each can range between 0 and 255) // same like main LED color setR2D2FrontLEDColor: (r,g,b) => encode({ commandId: types_1.UserIOCommandIds.allLEDs, payload: [0x00, 0x07, r, g, b] }),

// Set R2D2 back LED color based on RGB vales (each can range between 0 and 255) setR2D2BackLEDcolor: (r,g,b) => encode({ commandId: types_1.UserIOCommandIds.allLEDs, payload: [0x00, 0x70, r, g, b] }),

// Set R2D2 the holo projector intensity based on 0-255 values
setR2D2HoloIntensity: (i) => encode({ commandId: types_1.UserIOCommandIds.allLEDs, payload: [0x00, 0x70, i]

// Set R2D2 the logic displays intensity based on 0-255 values setR2D2LogicDisplayIntensity: setR2D2HoloIntensity: (i) => encode({ commandId: types_1.UserIOCommandIds.allLEDs, payload: [0x00, 0x08, i]

// R2D2 Waddle // R2D2 waddles 3 = start waddle, 0 = stop waddle setR2D2Waddle: (waddle) => encodeAnimatronics({ commandId: types_1.AnimatronicsCommandIds.shoulderAction, payload: [waddle] }),

// R2D2 Animations
/ Animation codes in decimals: Action: Drive(11), Scan(22), Spin(20), Sleep(23), Idle: Idle1(25), Idle2(26), Idle3(27), Negative: Alarm(7), Angry(8), Annoyed(9), Sad(17), Scared(19), No(16), IonBlast(14), Patrol: Alarm(28), Hit(29), Patrolling(30), Positive: Chatty(10), Confident(18), Excited(12), Happy(13), Laugh(15), Surprised(24),Yes(21) /

playAnimation: (animation) => encodeAnimatronics({ commandId: types_1.AnimatronicsCommandIds.animationBundle, payload: [0x00, animation] })

// R2D2 Play sounds

playR2D2Sound: (sounds_array(i)) => encode({ commandId: types_1.userIO.playAudioFile, payload: [sounds_array(i).hex1, sounds_array(i).hex2, 0x00] })

// This is only an part of the available sounds //the sounds array must be created accordingly in java. I cannot find the logic behind. sounds_array = [ {"soundId":"accesspanels","hex1":"0x06",hex2:"0xA8"}, {"soundId":"annoyed","hex1":"0x07",hex2:"0x76"}, {"soundId":"burnout","hex1":"0x07",hex2:"0x7B"}, {"soundId":"engagehyperdrive","hex1":"0x0A",hex2:"0x1A"}, {"soundId":"fall","hex1":"0x06",hex2:"0x49"}, {"soundId":"headspin","hex1":"0x0A",hex2:"0xED"}, {"soundId":"motor","hex1":"0x0B",hex2:"0x9A"}, {"soundId":"scream","hex1":"0x0E",hex2:"0xD5"}, {"soundId":"scream2","hex1":"0x0E",hex2:"0xE2"}, {"soundId":"shortout","hex1":"0x0E",hex2:"0xF1"}, {"soundId":"hit1","hex1":"0x06",hex2:"0x57"}, {"soundId":"hit2","hex1":"0x06",hex2:"0x6A"}, {"soundId":"hit10","hex1":"0x06",hex2:"0x5C"}, {"soundId":"hit11","hex1":"0x06",hex2:"0x63"}, {"soundId":"step1","hex1":"0x06",hex2:"0x9A"}, {"soundId":"step2","hex1":"0x06",hex2:"0x9D"}, {"soundId":"step5","hex1":"0x06",hex2:"0xA4"}, {"soundId":"step6","hex1":"0x06",hex2:"0xA6"}, {"soundId":"alarm1","hex1":"0x06",hex2:"0xC9"}, {"soundId":"alarm2","hex1":"0x07",hex2:"0x11"}, {"soundId":"alarm10","hex1":"0x06",hex2:"0xD3"}, {"soundId":"alarm11","hex1":"0x06",hex2:"0xDC"}, {"soundId":"chatty1","hex1":"0x07",hex2:"0x9E"}, {"soundId":"chatty2","hex1":"0x08",hex2:"0x0D"}, {"soundId":"chatty61","hex1":"0x09",hex2:"0xEF"}, {"soundId":"chatty62","hex1":"0x09",hex2:"0xFA"}, {"soundId":"excited1","hex1":"0x0A",hex2:"0x28"}, {"soundId":"excited2","hex1":"0x0A",hex2:"0x94"}, {"soundId":"excited15","hex1":"0x0A",hex2:"0x78"}, {"soundId":"excited16","hex1":"0x0A",hex2:"0x83"}, {"soundId":"hey1","hex1":"0x0A",hex2:"0xFD"}, {"soundId":"hey2","hex1":"0x0B",hex2:"0x19"}, {"soundId":"hey11","hex1":"0x0B",hex2:"0x0C"}, {"soundId":"hey12","hex1":"0x0B",hex2:"0x11"}, {"soundId":"laugh1","hex1":"0x0B",hex2:"0x67"}, {"soundId":"laugh2","hex1":"0x0B",hex2:"0x77"}, {"soundId":"laugh3","hex1":"0x0B",hex2:"0x86"}, {"soundId":"laugh4","hex1":"0x0B",hex2:"0x8B"}, {"soundId":"negative1","hex1":"0x0C",hex2:"0x1D"}, {"soundId":"negative2","hex1":"0x0C",hex2:"0x64"}, {"soundId":"negative27","hex1":"0x0C",hex2:"0xA1"}, {"soundId":"negative28","hex1":"0x0C",hex2:"0xA9"}, {"soundId":"positive1","hex1":"0x0C",hex2:"0xE6"}, {"soundId":"positive2","hex1":"0x0D",hex2:"0x42"}, {"soundId":"positive22","hex1":"0x0D",hex2:"0x5E"}, {"soundId":"positive23","hex1":"0x0D",hex2:"0x6A"}, {"soundId":"sad1","hex1":"0x0D",hex2:"0x9C"}, {"soundId":"sad2","hex1":"0x0E",hex2:"0x18"}, {"soundId":"sad24","hex1":"0x0E",hex2:"0x41"}, {"soundId":"sad25","hex1":"0x0E",hex2:"0x4D"}]

igbopie commented 5 years ago

Thank you so much! I just bought a R2D2 (getting it tomorrow) and I can test those :)

dtzolov214 commented 5 years ago

Hi, good timig to buy it, since sphero stopped the production of all star war robots and also Lighting McQueen, and it is very likely that the prices will get higher: https://www.engadget.com/2018/12/18/sphero-discontinues-bb-8/?guccounter=1

igbopie commented 5 years ago

I know! amazon still sells it for $69

https://www.amazon.com/Sphero-R201ROW-R2-D2-App-Enabled-Droid/dp/B071KSR86B/ref=sr_1_3?keywords=r2d2&qid=1547767280&sr=8-3

cryptographicturk commented 5 years ago

@dtzolov214 Can you tell me more about how you did the packet analysis? I have R2Q5, BB8, R2D2, Sphero v2, and Ollie, and I want to help make all of these work. R2Q5 clearly has different audio and animation codes as I have this running with R2Q5 and the R2D2 test script doesn't do exactly the same thing.

dtzolov214 commented 5 years ago

Hi, cryptographicturk, sorry for the late reply. I installed sphero education app on Android, then enabled the bluetooth HCI log on the device. Then I run some commands from the app and examined the btsnoop_hci.log with wireshark. And this was indeed cumbersome work. Unfortunately the sounds and animations of R2Q5 are not documented in the sphero app. So for the animations I just did my own interpretation what they could be:

animation codes in decimals: (1) | No (2) | No (3) | Excited1 (4) | Excited2 (5) | Scan1 (6) | Scan2 (7) | Excited3 (8) | Excited4 (9) | ExcitesShort1 (10) | Excited5 (11) | ScanRoll (12) | ExcitesShort2 (13) | ScanRollLong (14) | IonBlast (15) | Laugh (16) | No (17) | Scared (18) | Yes? (19) | ExcitedShort3 (20) | ExcitedShort3 (21) | ExcitedShort2 (22) | Scan3 (23) | ExcitedShort3 (24) | ScanLong (25) | Idle1 (26) | Idle2 (27) | Idle3

ivesdebruycker commented 5 years ago

Full list of sounds (convert number to hex, e.g 2586=A1A=0x0A,0x1A) Btw, my R2 can also do all BB8/BB9E/R2Q5 sounds (but not BB9E_EXTRA).

TEST_1497HZ 1
TEST_200HZ 32
TEST_2517HZ 63
TEST_3581HZ 94
TEST_431HZ 125
TEST_6011HZ 156
TEST_853HZ 187
BB8_ALARM_1 218
BB8_ALARM_10 235
BB8_ALARM_11 254
BB8_ALARM_12 258
BB8_ALARM_2 264
BB8_ALARM_3 268
BB8_ALARM_4 272
BB8_ALARM_6 279
BB8_ALARM_7 288
BB8_ALARM_8 296
BB8_ALARM_9 301
BB8_BOOT_UP 309
BB8_BOOR_UP_2 330
BB8_CHATTY_1 352
BB8_CHATTY_10 356
BB8_CHATTY_11 360
BB8_CHATTY_12 368
BB8_CHATTY_13 375
BB8_CHATTY_14 381
BB8_CHATTY_15 390
BB8_CHATTY_16 397
BB8_CHATTY_17 404
BB8_CHATTY_18 410
BB8_CHATTY_19 417
BB8_CHATTY_2 430
BB8_CHATTY_20 464
BB8_CHATTY_22 471
BB8_CHATTY_23 479
BB8_CHATTY_24 492
BB8_CHATTY_25 518
BB8_CHATTY_26 525
BB8_CHATTY_27 537
BB8_CHATTY_3 544
BB8_CHATTY_4 557
BB8_CHATTY_5 570
BB8_CHATTY_6 577
BB8_CHATTY_7 581
BB8_CHATTY_8 587
BB8_CHATTY_9 599
BB8_DONT_KNOW 606
BB8_EXCITED_1 612
BB8_EXCITED_2 622
BB8_EXCITED_3 630
BB8_EXCITED_4 644
BB8_HEY_1 671
BB8_HEY_10 682
BB8_HEY_11 686
BB8_HEY_12 690
BB8_HEY_13 700
BB8_HEY_2 724
BB8_HEY_3 732
BB8_HEY_4 734
BB8_HEY_5 739
BB8_HEY_6 743
BB8_HEY_7 747
BB8_HEY_8 753
BB8_HEY_9 757
BB8_LAUGH_1 761
BB8_LAUGH_2 764
BB8_NEGATIVE_1 787
BB8_NEGATIVE_10 792
BB8_NEGATIVE_11 802
BB8_NEGATIVE_12 813
BB8_NEGATIVE_13 825
BB8_NEGATIVE_14 831
BB8_NEGATIVE_15 836
BB8_NEGATIVE_16 859
BB8_NEGATIVE_17 867
BB8_NEGATIVE_18 874
BB8_NEGATIVE_19 888
BB8_NEGATIVE_2 896
BB8_NEGATIVE_20 902
BB8_NEGATIVE_21 916
BB8_NEGATIVE_22 927
BB8_NEGATIVE_23 935
BB8_NEGATIVE_24 946
BB8_NEGATIVE_25 953
BB8_NEGATIVE_26 963
BB8_NEGATIVE_27 969
BB8_NEGATIVE_28 983
BB8_NEGATIVE_29 988
BB8_NEGATIVE_3 998
BB8_NEGATIVE_30 1003
BB8_NEGATIVE_4 1010
BB8_NEGATIVE_5 1020
BB8_NEGATIVE_6 1032
BB8_NEGATIVE_7 1040
BB8_NEGATIVE_8 1052
BB8_NEGATIVE_9 1064
BB8_POSITIVE_1 1077
BB8_POSITIVE_10 1082
BB8_POSITIVE_11 1087
BB8_POSITIVE_12 1092
BB8_POSITIVE_13 1096
BB8_POSITIVE_14 1102
BB8_POSITIVE_15 1109
BB8_POSITIVE_16 1113
BB8_POSITIVE_2 1118
BB8_POSITIVE_3 1123
BB8_POSITIVE_4 1130
BB8_POSITIVE_5 1135
BB8_POSITIVE_6 1138
BB8_POSITIVE_7 1147
BB8_POSITIVE_8 1150
BB8_POSITIVE_9 1157
BB8_SAD_1 1163
BB8_SAD_10 1170
BB8_SAD_11 1178
BB8_SAD_12 1186
BB8_SAD_13 1192
BB8_SAD_14 1199
BB8_SAD_15 1205
BB8_SAD_16 1213
BB8_SAD_17 1220
BB8_SAD_18 1230
BB8_SAD_2 1236
BB8_SAD_3 1240
BB8_SAD_4 1250
BB8_SAD_5 1268
BB8_SAD_6 1275
BB8_SAD_7 1281
BB8_SAD_8 1295
BB8_SAD_9 1303
BB8_SHORTCUT 1308
BB8_WOW_1 1324
BB9E_ALARM_1 1329
BB9E_ALARM_2 1347
BB9E_ALARM_3 1363
BB9E_ALARM_4 1375
BB9E_ALARM_5 1384
BB9E_CHATTY_1 1394
BB9E_CHATTY_2 1408
BB9E_EXCITED_1 1432
BB9E_EXCITED_2 1442
BB9E_EXCITED_3 1463
BB9E_HEY_1 1476
BB9E_HEY_2 1486
BB9E_NEGATIVE_1 1494
BB9E_NEGATIVE_2 1505
BB9E_NEGATIVE_3 1516
BB9E_NEGATIVE_4 1523
BB9E_POSITIVE_1 1531
BB9E_POSITIVE_2 1549
BB9E_POSITIVE_3 1558
BB9E_POSITIVE_4 1571
BB9E_POSITIVE_5 1583
BB9E_SAD_1 1592
BB9E_SAD_2 1600
R2_FALL 1609
R2_HIT_1 1623
R2_HIT_10 1628
R2_HIT_11 1635
R2_HIT_2 1642
R2_HIT_3 1647
R2_HIT_4 1653
R2_HIT_5 1659
R2_HIT_6 1664
R2_HIT_7 1669
R2_HIT_8 1676
R2_HIT_9 1684
R2_STEP_1 1690
R2_STEP_2 1693
R2_STEP_3 1696
R2_STEP_4 1698
R2_STEP_5 1700
R2_STEP_6 1702
R2_ACCESS_PANELS 1704
R2_ALARM_1 1737
R2_ALARM_10 1747
R2_ALARM_12 1756
R2_ALARM_13 1763
R2_ALARM_14 1771
R2_ALARM_15 1784
R2_ALARM_16 1791
R2_ALARM_2 1809
R2_ALARM_3 1821
R2_ALARM_4 1831
R2_ALARM_5 1835
R2_ALARM_6 1843
R2_ALARM_7 1858
R2_ALARM_8 1867
R2_ALARM_9 1893
R2_ANNOYED 1910
R2_BURNOUT 1915
R2_CHATTY_1 1950
R2_CHATTY_10 1959
R2_CHATTY_11 1966
R2_CHATTY_12 1977
R2_CHATTY_13 1987
R2_CHATTY_14 2002
R2_CHATTY_15 2007
R2_CHATTY_16 2010
R2_CHATTY_17 2019
R2_CHATTY_18 2028
R2_CHATTY_19 2039
R2_CHATTY_2 2061
R2_CHATTY_20 2072
R2_CHATTY_21 2080
R2_CHATTY_22 2085
R2_CHATTY_23 2095
R2_CHATTY_24 2105
R2_CHATTY_25 2121
R2_CHATTY_26 2132
R2_CHATTY_27 2143
R2_CHATTY_28 2157
R2_CHATTY_29 2170
R2_CHATTY_3 2174
R2_CHATTY_30 2184
R2_CHATTY_31 2188
R2_CHATTY_32 2198
R2_CHATTY_33 2202
R2_CHATTY_34 2211
R2_CHATTY_35 2221
R2_CHATTY_36 2232
R2_CHATTY_37 2241
R2_CHATTY_38 2253
R2_CHATTY_39 2264
R2_CHATTY_4 2276
R2_CHATTY_40 2285
R2_CHATTY_41 2292
R2_CHATTY_42 2307
R2_CHATTY_43 2322
R2_CHATTY_44 2332
R2_CHATTY_45 2344
R2_CHATTY_46 2357
R2_CHATTY_47 2368
R2_CHATTY_48 2377
R2_CHATTY_49 2387
R2_CHATTY_5 2399
R2_CHATTY_50 2413
R2_CHATTY_51 2424
R2_CHATTY_52 2439
R2_CHATTY_53 2452
R2_CHATTY_54 2457
R2_CHATTY_55 2463
R2_CHATTY_56 2474
R2_CHATTY_57 2492
R2_CHATTY_58 2509
R2_CHATTY_59 2519
R2_CHATTY_6 2524
R2_CHATTY_60 2535
R2_CHATTY_61 2543
R2_CHATTY_62 2554
R2_CHATTY_7 2562
R2_CHATTY_8 2572
R2_CHATTY_9 2579
R2_ENGAGE_HYPER_DRIVE 2586
R2_EXCITED_1 2600
R2_EXCITED_10 2615
R2_EXCITED_11 2633
R2_EXCITED_12 2644
R2_EXCITED_13 2654
R2_EXCITED_14 2662
R2_EXCITED_15 2680
R2_EXCITED_16 2691
R2_EXCITED_2 2708
R2_EXCITED_3 2726
R2_EXCITED_4 2730
R2_EXCITED_5 2736
R2_EXCITED_6 2753
R2_EXCITED_7 2767
R2_EXCITED_8 2777
R2_EXCITED_9 2787
R2_HEAD_SPIN 2797
R2_HEY_1 2813
R2_HEY_10 2824
R2_HEY_11 2828
R2_HEY_12 2833
R2_HEY_2 2841
R2_HEY_3 2856
R2_HEY_4 2861
R2_HEY_5 2882
R2_HEY_6 2893
R2_HEY_7 2898
R2_HEY_8 2904
R2_HEY_9 2912
R2_LAUGH_1 2919
R2_LAUGH_2 2935
R2_LAUGH_3 2950
R2_LAUGH_4 2955
R2_MOTOR 2970
R2_NEGATIVE_1 3101
R2_NEGATIVE_10 3111
R2_NEGATIVE_11 3115
R2_NEGATIVE_12 3121
R2_NEGATIVE_13 3132
R2_NEGATIVE_14 3136
R2_NEGATIVE_15 3148
R2_NEGATIVE_16 3152
R2_NEGATIVE_17 3157
R2_NEGATIVE_18 3164
R2_NEGATIVE_19 3167
R2_NEGATIVE_2 3172
R2_NEGATIVE_20 3178
R2_NEGATIVE_21 3191
R2_NEGATIVE_22 3200
R2_NEGATIVE_23 3213
R2_NEGATIVE_24 3219
R2_NEGATIVE_25 3226
R2_NEGATIVE_26 3230
R2_NEGATIVE_27 3233
R2_NEGATIVE_28 3241
R2_NEGATIVE_3 3251
R2_NEGATIVE_4 3258
R2_NEGATIVE_5 3263
R2_NEGATIVE_6 3268
R2_NEGATIVE_7 3274
R2_NEGATIVE_8 3282
R2_NEGATIVE_9 3291
R2_POSITIVE_1 3302
R2_POSITIVE_10 3309
R2_POSITIVE_11 3318
R2_POSITIVE_12 3326
R2_POSITIVE_13 3340
R2_POSITIVE_14 3353
R2_POSITIVE_15 3358
R2_POSITIVE_16 3364
R2_POSITIVE_17 3369
R2_POSITIVE_18 3375
R2_POSITIVE_19 3388
R2_POSITIVE_2 3394
R2_POSITIVE_20 3403
R2_POSITIVE_21 3410
R2_POSITIVE_22 3422
R2_POSITIVE_23 3434
R2_POSITIVE_3 3439
R2_POSITIVE_4 3446
R2_POSITIVE_5 3449
R2_POSITIVE_6 3454
R2_POSITIVE_7 3460
R2_POSITIVE_8 3471
R2_POSITIVE_9 3478
R2_SAD_1 3484
R2_SAD_10 3495
R2_SAD_11 3518
R2_SAD_12 3526
R2_SAD_13 3536
R2_SAD_14 3543
R2_SAD_15 3553
R2_SAD_16 3561
R2_SAD_17 3570
R2_SAD_18 3593
R2_SAD_19 3600
R2_SAD_2 3608
R2_SAD_20 3612
R2_SAD_21 3619
R2_SAD_22 3632
R2_SAD_23 3639
R2_SAD_24 3649
R2_SAD_25 3661
R2_SAD_3 3686
R2_SAD_4 3693
R2_SAD_5 3703
R2_SAD_6 3739
R2_SAD_7 3755
R2_SAD_8 3782
R2_SAD_9 3790
R2_SCREAM 3797
R2_SCREAM_2 3810
R2_SHORT_OUT 3825
R2Q5_ALARM_1 3864
R2Q5_ALARM_2 3869
R2Q5_CHATTY_1 3875
R2Q5_CHATTY_2 3891
R2Q5_HEY_1 3896
R2Q5_HEY_2 3901
R2Q5_NEGATIVE_1 3907
R2Q5_POSITIVE_1 3914
R2Q5_POSITIVE_2 3920
R2Q5_SAD_1 3925
R2Q5_SHUTDOWN 3929
BB9E_EXTRA_1 3941
BB9E_EXTRA_2 4021
BB9E_EXTRA_3 4246
BB9E_EXTRA_4 4568
BB9E_EXTRA_5 4929
BB9E_EXTRA_6 5156
BB9E_EXTRA_7 5315
BB9E_HEAD_TURN_1 5441
BB9E_HEAD_TURN_2 5483
BB9E_HEAD_TURN_3 5513
ivesdebruycker commented 5 years ago

Animations for R2D2: https://gist.github.com/ivesdebruycker/a31fcfd24d0cb554bf715a9d82c8be95 Animations for R2Q5: https://gist.github.com/ivesdebruycker/bf66a5fd43ec95fe82179dab52f2a7f9 Animations for BB9E: https://gist.github.com/ivesdebruycker/90c35e00334457f135b2dfb6c484149c

github-actions[bot] commented 3 years ago

Stale issue message