Smart Minotaur
 Alle Klassen Dateien Funktionen Variablen Seiten
nxt::Brick Klassenreferenz

Used for communication with a NXT brick. Mehr ...

#include <Brick.hpp>

Öffentliche Methoden

void connect (const int p_interface=0)
void disconnect ()
void startProgram (const std::string &p_fileName)
 Starts a program on the brick with the given name.
void stopProgram ()
 Stops the currently running program on the brick.
void playSoundFile (const uint8_t p_loop, const std::string &p_fileName)
 Plays a sound on the brick with the given name.
void playTone (const uint16_t p_frequency, const uint16_t p_durationMS)
 Plays a tone on the brick.
void setOutputState (const uint8_t p_port, const uint8_t p_power, const uint8_t p_motorMode, const uint8_t p_regulationMode, const uint8_t p_turnRatio, const uint8_t p_runState, const uint32_t p_tachoLimit)
 Allows to control the motor with the given port.
void setInputMode (const uint8_t p_port, const uint8_t p_type, const uint8_t p_mode)
 Sets type and mode of a sensor with the given port.
void resetInputScaledValue (const uint8_t p_port)
 Resets the scaled output value of a sensor with the given port.
void writeMessage (const uint8_t p_mailbox, const std::string &p_message)
 Sends a string message to the given mailbox of the brick.
void resetMotorPosition (const uint8_t p_port, const uint8_t p_relative)
 Resets the motor data e.g.
void stopSoundPlayback ()
 Stops the currently running sound.
void lsWrite (const uint8_t p_port, const uint8_t p_txDataLength, const uint8_t p_rxDataLength, const unsigned char *p_txData)
OutputState getOutputState (const uint8_t p_port)
 Reads the current state of the given motor.
InputValues getInputValues (const uint8_t p_port)
 Reads the current measured values of the given sensor.
BatteryLevel getBatteryLevel ()
 Reads the current battery level of the brick.
KeepAlive keepAlive ()
LSStatus lsGetStatus (const uint8_t p_port)
LSRead lsRead (const uint8_t p_port)
ProgramName getCurrentProgramName ()
 Reads the program name of the currently running program.
MailboxMessage readMessage (const uint8_t p_remoteMailbox, const uint8_t p_localMailbox, const uint8_t p_removeMessage)
 Reads the first message in the message queue of the given mailbox.

Ausführliche Beschreibung

Used for communication with a NXT brick.

This class is used to connect and communicate with a LEGO NXT Brick. Telegram messages are sent via USB to the Brick and responses can be received.

Dokumentation der Elementfunktionen

BatteryLevel nxt::Brick::getBatteryLevel ( )

Reads the current battery level of the brick.

The voltage is measured in millivolts.

Rückgabe
voltage level of the brick
ProgramName nxt::Brick::getCurrentProgramName ( )

Reads the program name of the currently running program.

Rückgabe
program name
InputValues nxt::Brick::getInputValues ( const uint8_t  p_port)

Reads the current measured values of the given sensor.

Parameter
p_portport of the sensor
Rückgabe
measured values of the sensor
OutputState nxt::Brick::getOutputState ( const uint8_t  p_port)

Reads the current state of the given motor.

Parameter
p_portport of the motor
Rückgabe
state of the motor
void nxt::Brick::playSoundFile ( const uint8_t  p_loop,
const std::string &  p_fileName 
)

Plays a sound on the brick with the given name.

Parameter
p_loopdetermines if sound should restart
p_fileNamename of the sound file
void nxt::Brick::playTone ( const uint16_t  p_frequency,
const uint16_t  p_durationMS 
)

Plays a tone on the brick.

Parameter
p_frequencyfrequency of the tone
p_durationMSduration of the tone
MailboxMessage nxt::Brick::readMessage ( const uint8_t  p_remoteMailbox,
const uint8_t  p_localMailbox,
const uint8_t  p_removeMessage 
)

Reads the first message in the message queue of the given mailbox.

Parameter
p_remoteMailboxmailbox on another connected brick
p_localMailboxmailbox on the current brick
p_removeMessagetrue if message should be deleted after reading
Rückgabe
message received from the mailbox
void nxt::Brick::resetInputScaledValue ( const uint8_t  p_port)

Resets the scaled output value of a sensor with the given port.

Parameter
p_portport of the sensor
void nxt::Brick::resetMotorPosition ( const uint8_t  p_port,
const uint8_t  p_relative 
)

Resets the motor data e.g.

tachoCount.

Parameter
p_portport of the motor
p_relativetrue: relative to last position. false: absolute position
void nxt::Brick::setInputMode ( const uint8_t  p_port,
const uint8_t  p_type,
const uint8_t  p_mode 
)

Sets type and mode of a sensor with the given port.

Parameter
p_portport of the sensor
p_typetype of the sensor
p_modeoperation mode of the sensor
void nxt::Brick::setOutputState ( const uint8_t  p_port,
const uint8_t  p_power,
const uint8_t  p_motorMode,
const uint8_t  p_regulationMode,
const uint8_t  p_turnRatio,
const uint8_t  p_runState,
const uint32_t  p_tachoLimit 
)

Allows to control the motor with the given port.

Parameter
p_portport of the motor
p_powerpower in percent [-100;100]
p_motorModeoperation mode of the motor
p_regulationModesets auto regulation mode of the motor (sync)
p_turnRation
p_runStatedetermines the running mode of the motor
p_tachoLimitsets the tacho limit
void nxt::Brick::startProgram ( const std::string &  p_fileName)

Starts a program on the brick with the given name.

Parameter
p_fileNamename of the program
void nxt::Brick::writeMessage ( const uint8_t  p_mailbox,
const std::string &  p_message 
)

Sends a string message to the given mailbox of the brick.

The maximum message length is 58 characters.

Parameter
p_mailboxnumber of the target mailbox
p_messagemessage to be sent to the mailbox

Die Dokumentation für diese Klasse wurde erzeugt aufgrund der Dateien: