Skip to content

Instantly share code, notes, and snippets.

@antonvh
antonvh / gist:8458252
Created January 16, 2014 16:38
Sending a motor command to mindstorms NXT using python and the jaraco library.
from jaraco.nxt import *
from jaraco.nxt.messages import *
conn = Connection('/dev/tty.NXT-DevB')
cmd = SetOutputState(
i,
motor_on=True,
set_power=motorpower,
run_state=RunState.running,
@antonvh
antonvh / gist:8455505
Created January 16, 2014 14:04
Getting joystick input in python
import sdl2
sdl2.SDL_Init(sdl2.SDL_INIT_JOYSTICK)
joystick = sdl2.SDL_JoystickOpen(0)
while True:
sdl2.SDL_PumpEvents()
#depending on the gamepad this gives you a value between -32768 and +32768
#or between 0 and 32768
joy_x = sdl2.SDL_JoystickGetAxis(joystick, 0)
@antonvh
antonvh / gist:7439560
Created November 12, 2013 22:01
Installation steps for lego robot sumo
sudo easy_install pip
pip install numpy
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
brew tap homebrew/science
brew install opencv
pip install jaraco.nxt
hg clone https://bitbucket.org/antonvh/robot-sumo robot-sumo
cd robot-sumo/blob_recog
python blob_recognition.py