Difference between revisions of "Robotics-2010"

From Earlham CS Department
Jump to navigation Jump to search
(nxt.compass)
(nxt.compass)
Line 51: Line 51:
  
 
* Objects  
 
* Objects  
**UltrasonicSensor
+
**CompassSensor
The compass sensor is a digital sensor, and can be interfaced as if it were another digital sensor, such as the Ultrasonic sensor. .
 
  
 
* Methods  
 
* Methods  
**UltrasonicSensor(bot,port)
+
**CompassSensor(bot,port)
**get_sample() returns a value between zero and 180 depending on the heading of the sensor. There is a one-to-two ratio between degrees from due North and get_sample() values.
+
**get_sample() returns a value between zero and 180 depending on the heading of the sensor. There is a one-to-two ratio between degrees from due North and get_sample() values. At the moment this generally returns an error.
 +
**Methods to add
 +
***begin_calibration() tells the sensor to go into calibration mode.
 +
***end_calibration() tells the sensor to leave calibration mode
 +
[http://www.hitechnic.com/cgi-bin/commerce.cgi?preadd=action&key=NMC1034 Compass Sensor hardware info]
  
 
* Example
 
* Example
Line 63: Line 66:
  
 
* Notes
 
* Notes
** This is not recommended as a long-term solution.
+
** The sensor gives errors and fails to register almost all of the time. The reasoning for this is under investigation.
** Known bugs include an unacceptably frequent traceback when the sensor is in use.
 
** A more stable CompassSensor class is in the compass.py module.
 
*** It will replace this documentation shortly
 
  
 
=== Scripts ===
 
=== Scripts ===

Revision as of 16:20, 18 February 2010

NXT-Python Documentation

Largely a work in-progress, please add/edit as you learn the details. Note that this page is documenting the NXT-Python v1.1 release (http://code.google.com/p/nxt-python/), not the NXT_Python v0.7 release which appears to have gone dormant (note hyphen vs underscore).

nxt.locator

The function of this module is to locate NXT brick(s). Returns an nxt.bluesock.BlueSock object for robots connected by Bluetooth and a nxt.usbsock.USBSock object for robot connected by USB, and throws nxt.locator.BrickNotFoundError if none can be found.

  • Status: incomplete as of 2010-02-14
  • Objects
    • nxt.bluesock.BlueSock - The object returned by find_one_brick() when a brick is found on a Bluetooth connection.
  • Methods
    • connect() - Try to connect to the brick.
    • close() - Close connection to brick.
    • host - Returns the address of the brick.
    • generator object find_bricks()
      • next() - Find the next brick in the sequence, returns the same thing as find_one_brick().
    • find_one_brick()
    • find_bricks(host=None, name=None) - Find all the bricks in the area, returns a generator object find_bricks.
  • Example
import nxt.locator 
sock = nxt.locator.find_one_brick() 
brick = sock.connect() 
print brick.host 
brick.close()

nxt.motor

  • Status: incomplete as of 2010-02-14
  • Objects
  • Methods
  • Example

nxt.sensor

  • Status: incomplete as of 2010-02-14
  • Objects
  • Methods
  • Example

nxt.compass

  • Status: incomplete as of 2010-02-14
  • Objects
    • CompassSensor
  • Methods
    • CompassSensor(bot,port)
    • get_sample() returns a value between zero and 180 depending on the heading of the sensor. There is a one-to-two ratio between degrees from due North and get_sample() values. At the moment this generally returns an error.
    • Methods to add
      • begin_calibration() tells the sensor to go into calibration mode.
      • end_calibration() tells the sensor to leave calibration mode

Compass Sensor hardware info

  • Example
compass = UltrasonicSensor(bot, PORT_1) #declare the sensor plugged into port 1 "compass"
heading = compass.get_sample()*2 # get the current heading in degrees from due north
  • Notes
    • The sensor gives errors and fails to register almost all of the time. The reasoning for this is under investigation.

Scripts

Located in $DISTRIBUTION/scripts.

  • nxt_filer
  • nxt_push
  • nxt_test

Server Mode and nxt.server