Class rundown (v 1.1 and 1.1)

Bluetooth communication

The MindSqualls library connects to the NXT brick using Bluetooth.

When I figure out how to do it, I plan to add USB support as well.

The communication channel to the NXT brick is handled by the two classes:

Class Function
NxtCommunicationProtocol Implements the NXT protocol
NxtBluetoothConnection Implements the connection using Bluetooth.

If, and when, I implements the USB support, it will most likely be in the form of a class, NxtUsbConnection implementing the NxtCommunicationProtocol class.

If an error occurs, these classes may throw a NxtException or a NxtCommunicationProtocolException as well as ordinary .Net exceptions e.g. ArgumentException. You will find the definition of these in the NxtExceptions.cs file.

If you are only interested in communicating with your NXT brick, this means that you can make do with these three C# files: NxtCommunicationProtocol.cs, NxtBluetoothConnection.cs and NxtExceptions.cs.

The NXT brick

The NxtBrick implements the brick itself. The brick has a commLink for the Bluetooth connection.

It also has a mororArray of 3 motors and a sensorArray of 4 sensors.

Class Function
NxtBrick Implements the NXT brick.
NxtMotor Implements a NXT motor.
NxtSensor Implements a generic NXT sensor. This abstract class needs to be overridden for the specific types of NXT sensors.

The sensor class hierarchy

Both motors and sensors can be queried for information; The sensors can be polled for their sensor-readings (duh!), and the motor can be polled for their rotation count.

As a result the sensor class hierarchy starts with the NxtPollable classes and includes the NxtMotor class as well as the NxtSensor class and its derived classes:

Class Function
HiTechnicCompassSensor Implements the Compass sensor from HiTechnic.
HiTechnicColorSensor (v1.1) Implements the Color sensor from HiTechnic.
NxtPassiveSensor, and
According to the LEGO MINDSTORMS NXT Hardware Developer Kit p. 7 sensors is divided into three types: active sensors (e.g. Robotics Invention Systems sensors), passive sensors (e.g. the NXT touch, light, and sound sensors), and digital sensors (e.g. the NXT ultrasonic sensor and the HiTechnic compass sensor). The three abstract classes NxtActiveSensor, NxtPassiveSensor, and NxtDigitalSensor reflect this.

So far there is no classes implementing the NxtActiveSensor class. The NxtPassiveSensor class implements sensors that get their sensor-reading through the GetInputValues() method. The NxtDigitalSensor implements sensors that gets their sensor-reading through the LsWrite()-, LsGetStatus()- and LsRead()-methods using the I2C protocol.
NxtNoSensor (v1.1) Use this class if you need to blind a sensor port.
NxtLightSensor Implements the light sensor. The sensor may provide its own light, or it may measure the ambient light.
NxtMotor See above.
NxtPollable Implements a pollable device for the NXT brick. I.e. a device that can measurable something.

Looking at the class diagram, I'm tempted to move the brick field of the NxtMotor- and NxtSensor classes up to the NxtPollable class. Actually I did just that in v1.2 of the API.
NxtSensor See above.
NxtSoundSensor Implements the sound sensor. Readings may be in both the dB and dBA scales.
NxtTouchSensor Implements the touch sensor.
NxtUltrasonicSensor Implements the ultrasonic sensor. Readings is in cm units.

Synchronized motors

The NXT brick provides supports for synchronizing two motors. This is practical since it makes it possible to drive the robot on a straight line, without one motor overtaking the other.

The NxtMotorSync class handles this functionality.

Class Function
NxtMotorSync Establishes a relationship between two motors, allowing them to be synchronized.