Index of NXT Control Center
1. General
The NXT Control Center is implemented for Windows XP using the Visual Component Library from RAD Studio C++ Builder. The robot itself must be equipped with the LeJOS system.
The following chapter explains how to operate with the control center. Of course you can download the source code from the download site.
Image: main screen of the control center
2. How to run NXT Control Center
2.1 Setup NXT Robot
Before we can run the control center we have to connect to the NXT Robot. Turn on the robot and go to the bluetooth menu. Make sure the robot shows following status:
Status on vis
2.2 Setup Computer
Activate the bluetooth device on your computer. Then add a new bluetooth device.
Click on Add and search for new devices. If the NXT robot is in range it will appear in the assistent.
Finally add the communication key used to communicate with the NXT. The NXT has a predefined communication key:
1234
After a successfull installation the assistent shows following screen:
The assistent also installs two COM-Ports which can be used to communicate using TSerialConnection class from the Zeus-Framework.
2.3 Start application
Start the NXT Control Center on your computer and click on Connect
. Following dialog appears:
Input the name of the bluetooth device you've just added. Normaly the name is set to NXT
. As an alternative you can also input the bluetooth address directly.
2.4 Adding Sensors
The control center allows to add various sensors:
- Sound Sensor: catches the sound of the environment
- Touch Sensor: catches the touching of the robot with other objects
- Sonar Sensor: measures the distance from robot to other objects
- Light Sensor: measures the light intensity
The sensor panel shows the value reading.
2.5 Control motors
The side panel is used to control the motors. The first control stears the robot in a joystick manner. The second one opens and closes the claw.
3. Code Insight
This chapter shows how the example is coded and gives some ideas about the Zeus-Robot library. The focus will be mainly on controlling and reading values than on GUI programming.
3.1 Connect to the robot
The connection can be established using the TNXTConnection
class. The connection class returns a connected bluetooth socked, which must be passed to a TNXTRobot
object.
#include <zeusrobot/Nxt/NXTConnection.h>
#include <zeusrobot/Nxt/NXTRobot.h>
#include <zeusbase/Net/Bluetooth/BluetoothSocket.h>
...
TAutoPtr<TBluetoothSocket> ptrSocket;
TString strName(L"NXT");
if (NXTConnection.connectOverBluetooth(strName, TString(L""), ptrSocket) == RET_NOERROR)
{
TAutoPtr<TNXTRobot> ptrRobot = new TNXTRobot(*ptrSocket, *ptrSocket);
...
}
3.2 Create a sensor
Each sensor class needs an input and an output stream. They are used to exchange data with the robot. Use the read-method to get the value from the sensor.
#include <zeusrobot/Nxt/NXTLightSensor.h>
...
TAutoPtr<TNXTLightSensor> ptrSensor = new TNXTLightSensor(TNXTSensor::etChannel1,
ptrRobot->getInStream(),
ptrRobot->getOutStream());
//Read the current value
Int iValue = ptrSensor->read();
3.3 Control the motor
The motors can be created in a similar way like sensors or established using the robot class.
#include <zeusrobot/Nxt/NXTRobot.h>
#include <zeusrobot/Nxt/NXTMotor.h>
TAutoPtr<TNXTMotor> ptrMotorA;
if (ptrRobot->getMotor(TNXTMotor::etMotorA, ptrMotorA) == RET_NOERROR)
{
ptrMotorA->start(100);
...
ptrMotorA->stop();
}
4. Useful links
Some useful links around robotics:
- LeJOS, Java for Lego Mindstorms
http://lejos.sourceforge.net - Lego Mindstorm Robot
http://mindstorms.lego.com/en-us/default.aspx
Following links contains the complete specification of the bluetooth interface and hardware.
Communication Protocol:
- MINDSTORMS NXT Communication protocol
- MINDSTORMS NXT Direct commands
- MINDSTORMS NXT ARM7 Bluetooth Interface specification
- MINDSTORMS NXT Bluetooth Developer Kit
Hardware specification:
- MINDSTORMS NXT hardware schematic
- MINDSTORMS NXT Keypad schematic
- MINDSTORMS NXT Light Sensor hardware schematic
- MINDSTORMS NXT Sound Sensor hardware schematic
- MINDSTORMS NXT Touch Sensor hardware schematic
- MINDSTORMS NXT Ultrasonic Sensor hardware schematic
- MINDSTORMS NXT Ultrasonic Sensor I2C communication protocol
- MINDSTORMS NXT ARM7 Bluetooth Interface specification
- MINDSTORMS NXT Hardware Developer Kit