Created
October 23, 2014 20:06
-
-
Save jpjacobs/63292d6d5b7ac34ceba3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NB. Listen to UDP stream (phone IMU eg.) | |
load'socket' | |
load'graph' | |
(;:'jsocket jdefs z') copath 'base' | |
sk =: 0 pick sdcheck sdsocket AF_INET_jdefs_,SOCK_DGRAM_jdefs_,0 | |
sdcheck sdbind sk;AF_INET;'';5555 | |
NB. sensor_number check socket | |
check =: 4 : 0 | |
if. sk e. 2 pick sdselect '' do. | |
it =: 1 pick sdcheck sdrecvfrom (sk ; 1000 ; 0) | |
NB. IMU+GPS stream format: | |
NB. timestamp, 4-tuples: id x y z | |
r=: _4 ]\ }. ". ;. _2 it,',' | |
G=: }. (x = {."1 r) # r | |
else. | |
G=: 5 5 5 | |
end. | |
G | |
) | |
3 check sk |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment