USMakeSnapshot

Causes the ultrasonic sensor to send one snapshot ("ping") and record the echos

Contents

Syntax

USMakeSnapshot(port)

USMakeSnapshot(port, handle)

Description

Call USMakeSnapshot(port) to make the specific ultrasonic sensor connected to port send out one single signal (called "ping"). In contrast to the US sensor's continous mode (that is invoked by a normal OpenUltrasonic without the 'snapshot' parameter), the sensor will only send out ultrasonic signals when this function is called. Up to 8 multiple echos will be recorded, and the according distances stored in the sensor's internal memory. Use USGetSnapshotResults to retrieve those 8 readings in one step!

The last optional argument can be a valid NXT handle. If none is specified, the default handle will be used (call COM_SetDefaultNXT to set one).

Note: When the US sensor is opened in snapshot mode, the function GetUltrasonic does not work correctly!

Example

  port = SENSOR_4;
  OpenUltrasonic(port, 'snapshot');
  % send out the ping
  USMakeSnapshot(port);
  % wait some time for the sound to travel
  pause(0.1); % 100ms is probably too much, calculate using c_sound ;-)
  % retrieve all the echos in 1 step
  echos = USGetSnapshotResults(port);
  CloseSensor(SENSOR_4);
 % You should also try the file Example_4_NextGenerationUltrasound.m
 % from the demos-folder

See also

OpenUltrasonic, GetUltrasonic, USGetSnapshotResults, CloseSensor,

Signature