NXT::Sensor Namespace Reference

Contains all the functions that have to do with a sensor. More...


Functions

void SetTouch (Comm::NXTComm *comm, int port)
 Sets a sensor in a specified port to a touch sensor.
void SetSound (Comm::NXTComm *comm, int port)
 Sets a sensor in a specified port to a sound sensor.
void SetLight (Comm::NXTComm *comm, int port, bool active)
 Sets a sensor in a specified port to a light sensor.
void SetSonar (Comm::NXTComm *comm, int port)
 Sets a sensor in a specified port to a sonar sensor.
void SetCmpsNx (Comm::NXTComm *comm, int port)
 Sets a sensor in a specified port to a Mind Sensors Compass sensor.
void SetDistNx (Comm::NXTComm *comm, int port)
 Sets a sensor in a specified port to a Mind Sensors Distance sensor.
void SetRaw (Comm::NXTComm *comm, int port)
 Sets a sensor to return a raw value (not formatted in any way).
void Set (Comm::NXTComm *comm, int port, SensorType type)
 Sets a sensor to a specified SensorType.
int GetValue (Comm::NXTComm *comm, int port)
 Retrieves the value of a sensor.
int GetAvgCmpsNxValue (Comm::NXTComm *comm, int port, int numValues, int waitTime)
 Retrieves multiple values of the Mindsensors Compass sensor and averages them.
int GetCmpsNxValue (Comm::NXTComm *comm, int port)
 Retrieves the value of the Mindsensors Compass sensor.
int GetDistNxValue (Comm::NXTComm *comm, int port)
 Retrieves the value of the Mindsensors Distance sensor.
int GetCleanDistNxValue (Comm::NXTComm *comm, int port)
 Retrieves multiple values of the Mindsensors Distance sensor and averages them.
int LSGetStatus (Comm::NXTComm *comm, int port)
 Gets the status of the lowspeed port.
int GetSonarValue (Comm::NXTComm *comm, int port)
 Retrieves the value for sonar sensors.
void SetSonarOff (Comm::NXTComm *comm, int port)
 Tells the sonar sensor to stop sending pulses.
void SetSonarSingleShot (Comm::NXTComm *comm, int port)
 Tells the sonar sensor to only send a pulse when you ask it what it's value is.
void SetSonarContinuous (Comm::NXTComm *comm, int port)
 Tells the sonar sensor to continuously send pulses.
void SetSonarContinuousInterval (Comm::NXTComm *comm, int port, int interval)
 Sets the interval at which the sonar sensor sends a pulse.
void writeI2C (Comm::NXTComm *comm, int port, ViUInt8 command[], int replySz, int tx_length)
 Writes the command to the I2C sensor.
ViUInt8 * readI2C (Comm::NXTComm *comm, int port)
 Reads the values from the registers of an I2C sensor.


Detailed Description

Contains all the functions that have to do with a sensor.

Function Documentation

int NXT::Sensor::GetAvgCmpsNxValue ( Comm::NXTComm *  comm,
int  port,
int  numValues,
int  waitTime 
)

Retrieves multiple values of the Mindsensors Compass sensor and averages them.

Parameters:
port The port that you wish to retrieve it's sensor's value from. Can be the numbers 0-3 or IN_1, IN_2, IN_3, or IN_4.
numValues The number of samples to average
waitTime The time in between samples
Returns:
The sensor's current value.

int NXT::Sensor::GetCleanDistNxValue ( Comm::NXTComm *  comm,
int  port 
)

Retrieves multiple values of the Mindsensors Distance sensor and averages them.

Parameters:
port The port that you wish to retrieve it's sensor's value from. Can be the numbers 0-3 or IN_1, IN_2, IN_3, or IN_4.
Returns:
The sensor's current value.

int NXT::Sensor::GetCmpsNxValue ( Comm::NXTComm *  comm,
int  port 
)

Retrieves the value of the Mindsensors Compass sensor.

Parameters:
port The port that you wish to retrieve it's sensor's value from. Can be the numbers 0-3 or IN_1, IN_2, IN_3, or IN_4.
Returns:
The sensor's current value.

int NXT::Sensor::GetDistNxValue ( Comm::NXTComm *  comm,
int  port 
)

Retrieves the value of the Mindsensors Distance sensor.

Parameters:
port The port that you wish to retrieve it's sensor's value from. Can be the numbers 0-3 or IN_1, IN_2, IN_3, or IN_4.
Returns:
The sensor's current value.

int NXT::Sensor::GetSonarValue ( Comm::NXTComm *  comm,
int  port 
)

Retrieves the value for sonar sensors.

Parameters:
port The port that contains the sonar sensor. Can be the numbers 0-3 or IN_1, IN_2, IN_3, or IN_4.
Returns:
The sonar sensor's current value in centimeters.

int NXT::Sensor::GetValue ( Comm::NXTComm *  comm,
int  port 
)

Retrieves the value of a sensor.

Does not work with the Sonar sensor.

Parameters:
port The port that you wish to retrieve it's sensor's value from. Can be the numbers 0-3 or IN_1, IN_2, IN_3, or IN_4.
Returns:
The sensor's current value.

int NXT::Sensor::LSGetStatus ( Comm::NXTComm *  comm,
int  port 
)

Gets the status of the lowspeed port.

Most users should not need to use this. The function does not get the value of the sensor. Not to be confused with GetSonarValue().

Parameters:
port The port that you wish to get the status of. Can be the numbers 0-3 or IN_1, IN_2, IN_3, or IN_4.
Returns:
The status of the specified port.

ViUInt8* NXT::Sensor::readI2C ( Comm::NXTComm *  comm,
int  port 
)

Reads the values from the registers of an I2C sensor.

Always returns an array of length 19. See GetDisNxValue for an example.

Parameters:
port port The port where the I2C sensor you wish to read from is. Can be the numbers 0-3 or IN_1, IN_2, IN_3, or IN_4.

void NXT::Sensor::Set ( Comm::NXTComm *  comm,
int  port,
SensorType  type 
)

Sets a sensor to a specified SensorType.

Parameters:
port The port that you wish perform this operation on. Can be the numbers 0-3 or IN_1, IN_2, IN_3, or IN_4.
type The SensorType that you wish to set the sensor to.

void NXT::Sensor::SetCmpsNx ( Comm::NXTComm *  comm,
int  port 
)

Sets a sensor in a specified port to a Mind Sensors Compass sensor.

Parameters:
port The port that you wish to set as a compass sensor. Can be the numbers 0-3 or IN_1, IN_2, IN_3, or IN_4.

void NXT::Sensor::SetDistNx ( Comm::NXTComm *  comm,
int  port 
)

Sets a sensor in a specified port to a Mind Sensors Distance sensor.

Parameters:
port The port that you wish to set as a distance sensor. Can be the numbers 0-3 or IN_1, IN_2, IN_3, or IN_4.

void NXT::Sensor::SetLight ( Comm::NXTComm *  comm,
int  port,
bool  active 
)

Sets a sensor in a specified port to a light sensor.

Parameters:
port The port that you wish to set as a light sensor. Can be the numbers 0-3 or IN_1, IN_2, IN_3, or IN_4.
active Whether or not you want the infrared light to be on.

void NXT::Sensor::SetRaw ( Comm::NXTComm *  comm,
int  port 
)

Sets a sensor to return a raw value (not formatted in any way).

Parameters:
port The port that you wish to set to return a raw value. Can be the numbers 0-3 or IN_1, IN_2, IN_3, or IN_4.

void NXT::Sensor::SetSonar ( Comm::NXTComm *  comm,
int  port 
)

Sets a sensor in a specified port to a sonar sensor.

Parameters:
port The port that you wish to set as a sonar sensor. Can be the numbers 0-3 or IN_1, IN_2, IN_3, or IN_4.

void NXT::Sensor::SetSonarContinuous ( Comm::NXTComm *  comm,
int  port 
)

Tells the sonar sensor to continuously send pulses.

Parameters:
port The port that contains the sonar sensor. Can be the numbers 0-3 or IN_1, IN_2, IN_3, or IN_4.

void NXT::Sensor::SetSonarContinuousInterval ( Comm::NXTComm *  comm,
int  port,
int  interval 
)

Sets the interval at which the sonar sensor sends a pulse.

Parameters:
port The port that contains the sonar sensor. Can be the numbers 0-3 or IN_1, IN_2, IN_3, or IN_4.
interval The interval at which the sonar sensor should send a pulse in miliseconds.

void NXT::Sensor::SetSonarOff ( Comm::NXTComm *  comm,
int  port 
)

Tells the sonar sensor to stop sending pulses.

Parameters:
port The port that contains the sonar sensor. Can be the numbers 0-3 or IN_1, IN_2, IN_3, or IN_4.

void NXT::Sensor::SetSonarSingleShot ( Comm::NXTComm *  comm,
int  port 
)

Tells the sonar sensor to only send a pulse when you ask it what it's value is.

Parameters:
port The port that contains the sonar sensor. Can be the numbers 0-3 or IN_1, IN_2, IN_3, or IN_4.

void NXT::Sensor::SetSound ( Comm::NXTComm *  comm,
int  port 
)

Sets a sensor in a specified port to a sound sensor.

Parameters:
port The port that you wish to set as a sound sensor. Can be the numbers 0-3 or IN_1, IN_2, IN_3, or IN_4.

void NXT::Sensor::SetTouch ( Comm::NXTComm *  comm,
int  port 
)

Sets a sensor in a specified port to a touch sensor.

Parameters:
port The port that you wish to set as a touch sensor. Can be the numbers 0-3 or IN_1, IN_2, IN_3, or IN_4.

void NXT::Sensor::writeI2C ( Comm::NXTComm *  comm,
int  port,
ViUInt8  command[],
int  replySz,
int  tx_length 
)

Writes the command to the I2C sensor.

See the GetDistNxValue() source for an example.

Parameters:
port The port where the I2C sensor you wish to write to is. Can be the numbers 0-3 or IN_1, IN_2, IN_3, or IN_4.
command The command you want to send, starting with the sensor address
replySz The size of the reply expected to be returned
tx_length The length of the message you are sending.

SourceForge.net Logo