github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

janv / haskell-nxt

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 4
    • 0
  • Source
  • Commits
  • Network (0)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

A haskell library for controlling Lego Mindstorms NXT Bricks - ABANDONED, WILL NOT CONTINUE — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Num padding in debugByteString 
janv (author)
Sun Oct 05 13:56:09 -0700 2008
commit  c08209beb4a15098d850676296c7824c9ced6774
tree    558282d720bf6630d0ad111e013856e0452c23aa
parent  d700ae979a1f469c36f8bea15e1e71c0e68a0e90
haskell-nxt /
name age
history
message
file .gitignore Loading commit data...
file LICENSE
file README
directory src/
README
HASKELL-NXT
===========

Haskell-Nxt is a library to control Lego Mindstorms NXT Bricks from Haskell.

Since the nature of the communication with the Brick is stateful, the library
consists almost entirely of monads.

Haskell-NXT is my first piece of Haskell software and probably has a lot of
rough edges still so comments, tips, bug reports or patches are very much
appreciated. 

Architecture
============

I want to briefly explain the architecture of the Library here.

NXT
---
This module is used for setting up a NXTBrick and fiddling around with it.
Mainly for testing purposes

NXT.Codes
---------
Contains various Enums and Translations between NXT protocol bytecodes and
descriptive strings or haskell types.

NXT.Helpers
-----------
Various helper functions for converting bytestrings, converting little- to
big-endian integers, dissecting messages etc.

NXT.Comm
--------
Lowest level communication with NXT Bricks. Provides a wrapper around
System.IO calls to make top-level programs a little less noisy and basic
read/write commands

NXT.Commands
------------
Implementations of the most common Direct Commands in two parts each.
One function to assemble the message to send to the Brick, one action
to send the message to the Brick in the IO Monad
A custom class `Appendable` is used to more easily combine various data types
into NXT messages.

NXT.Motor
---------
High-level library on top of NXT.Commands to easily run and stop motors.

NXT.Sensor
----------
High-level library on top of NXT.Commands to easily read out the sensors.
Requires an initialization call after opening the connection to the Brick
and assumes that the sensors are plugged into their intended ports on the
brick.

NXT.Ultrasonic
--------------
Since the Ultrasonic sensor communicates with the NXT via I2C, controlling
it is a little more complicated. This module contains mainly a list of I2C
commands.


Usage Example
=============

    btBrick = NXTBrick Bluetooth "/dev/tty.NXT-DevB-1"

    main = do
      h <- nxtOpen btBrick
      playtone h 500 500
      setupDefaultSensors h
      s <- getDistance h
      putStrLn (show s)
      nxtClose h

This opens a NXT Brick located as a serial device at /dev/tty.NXT-DevB-1
in Bluetooth mode (as opposed to USB, which isn't implemented yet).
The brick is opened, plays a tone and reads the distance from
the distance sensor.

Usage restrictions
==================

- The library works only on POSIX systems currently.
- It was developed on Mac OSX 10.5 with GHC 6.8.3 and uses some
  GHC-extensions to the Haskell standard.
- Communication with Bricks via USB isn't implemented yet.

TODO
====

 - I2C delay
 - Implement USB interface
 - Implement the rest of the NXT Commands
 - Debugging helpers

Credits
=======

 - Reading Tony Busers Ruby-Nxt library has greatly helped understanding the
   NXT protocol, especially controlling the Ultrasonic Sensor
   <http://rubyforge.org/projects/ruby-nxt/>
 - The Lego Mindstorms Bluetooth Developer Kit nicely described the protocol
   <http://mindstorms.lego.com/Overview/NXTreme.aspx>
 - The Labview for NXT Advanced Programming Guide contained some hints that
   were missing from the Lego docs
   

Copyright (c) 2008 [Jan Varwig], released under the MIT license
<http://jan.varwig.org/>
Original and official version at <http://github.com/janv/haskell-nxt>
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server