是否有方法(Cylon.js)用Cylon Sphero获取Accelerometer和GyroScope数据?我想使用Sphero作为控制器,locator
事件不会返回有用的信息。这就是我目前正在做的locator
数据(咖啡脚本)
Cylon = require 'cylon'
connectionDefaults =
name : 'sphero'
adaptor : 'sphero'
port : '/dev/tty.Sphero-WYW-AMP-SPP'
deviceDefaults =
name : 'sphero'
driver : 'sphero'
spheroDoWork = ( robot )->
SPHERO = robot.sphero
DATA = {}
sampleRateHz = 420
intN = 20
intM = 1
packetCount = 20
mask = 21
mask2 = packetCount * 2
velMin = 50
distance = 0
timeBetweenData = intN / sampleRateHz
handleConnect =->
console.log '== SPHERO READY...'
SPHERO.setDataStreaming( intN, intM, mask, packetCount, mask2 )
SPHERO.detectLocator()
SPHERO.stop()
handleLocator =( data )->
raw =
yDist : data[0]
xDist : data[1]
accel : data[2]
yVel : data[3]
xVel : data[4]
DATA.prev = DATA.curr
DATA.curr = raw
console.log '=== PREV DATA', DATA.prev
console.log '=== CURR DATA', DATA.curr
SPHERO.on 'connect', handleConnect
SPHERO.on 'locator', handleLocator
Cylon.robot
connection : connectionDefaults
device : deviceDefaults
work : spheroDoWork
.start()
答案 0 :(得分:1)
在使用hybrid
小组处理setDataStreaming
更新cylon.js
后,现在可以通过git https://github.com/hybridgroup/cylon-sphero