![]() |
Smart Minotaur
|
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. |
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.
BatteryLevel nxt::Brick::getBatteryLevel | ( | ) |
Reads the current battery level of the brick.
The voltage is measured in millivolts.
ProgramName nxt::Brick::getCurrentProgramName | ( | ) |
Reads the program name of the currently running program.
InputValues nxt::Brick::getInputValues | ( | const uint8_t | p_port | ) |
Reads the current measured values of the given sensor.
p_port | port of the sensor |
OutputState nxt::Brick::getOutputState | ( | const uint8_t | p_port | ) |
Reads the current state of the given motor.
p_port | port 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.
p_loop | determines if sound should restart |
p_fileName | name of the sound file |
void nxt::Brick::playTone | ( | const uint16_t | p_frequency, |
const uint16_t | p_durationMS | ||
) |
Plays a tone on the brick.
p_frequency | frequency of the tone |
p_durationMS | duration 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.
p_remoteMailbox | mailbox on another connected brick |
p_localMailbox | mailbox on the current brick |
p_removeMessage | true if message should be deleted after reading |
void nxt::Brick::resetInputScaledValue | ( | const uint8_t | p_port | ) |
Resets the scaled output value of a sensor with the given port.
p_port | port of the sensor |
void nxt::Brick::resetMotorPosition | ( | const uint8_t | p_port, |
const uint8_t | p_relative | ||
) |
Resets the motor data e.g.
tachoCount.
p_port | port of the motor |
p_relative | true: 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.
p_port | port of the sensor |
p_type | type of the sensor |
p_mode | operation 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.
p_port | port of the motor |
p_power | power in percent [-100;100] |
p_motorMode | operation mode of the motor |
p_regulationMode | sets auto regulation mode of the motor (sync) |
p_turnRation | |
p_runState | determines the running mode of the motor |
p_tachoLimit | sets the tacho limit |
void nxt::Brick::startProgram | ( | const std::string & | p_fileName | ) |
Starts a program on the brick with the given name.
p_fileName | name 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.
p_mailbox | number of the target mailbox |
p_message | message to be sent to the mailbox |