The MindSqualls library connects to the NXT brick using either Bluetooth or USB.
The communication channel to the NXT brick is handled by 3 classes:
Class | Function |
---|---|
NxtCommunicationProtocol
|
Implements the NXT protocol. |
NxtBluetoothConnection
|
Implements communicating with the NXT using Bluetooth. |
NxtUsbConnection
|
Implements communicating with the NXT using USB. (new in v2.0) |
If an error occurs, these classes may throw a NxtException
, NxtConnectionException
,
or a NxtCommunicationProtocolException
as well as ordinary .Net exceptions
like ArgumentException
. You will find the definition of these in the
NxtExceptions.cs
file.
If you are only interested in how to communicate with your NXT brick, it means that
you can make do with these 4-5 C# files: NxtCommunicationProtocol.cs
,
NxtCommunicationProtocolStructures.cs
, NxtBluetoothConnection.cs
/NxtUsbConnection.cs
and NxtExceptions.cs
.
The NxtBrick implements the brick itself. The brick has a commLink
for the Bluetooth/USB connection.
It also has a motorArray
of 3 motors and a sensorArray
of 4 sensors.
The NxtPollable
class has a brick
field and since NxtMotor
and NxtSensor
inherits this class, this provides the opposite relation.
Class | Function |
---|---|
NxtPollable
|
Implements common functionality for polling a sensor or a motor for sensor-input. |
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. |
Note: In previous versions of the API, the NxtMotor
and NxtSensor
each implemented a brick
field. In v1.2 this field has been moved to
the NxtPollable
class. If you are interested you can see the class-rundown
for v1.1 here.
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 |
---|---|
HiTechnicAccelerationSensor
|
(v1.2) Implements the Acceleration / Tilt Sensor sensor from HiTechnic. |
HiTechnicCompassSensor
|
Implements the Compass sensor from HiTechnic. |
HiTechnicColorSensor
|
(v1.1) Implements the Color sensor from HiTechnic. |
NxtActiveSensor ,NxtPassiveSensor , andNxtDigitalSensor
|
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.
|
Nxt2ColorSensor
|
(v2.0) Implements the new Color sensor in the NXT 2.0 set. |
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. |
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. |
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. |