File : sonar.ads


-- Description     : user interface for sonars
-- Author          : Christfried Webers
-- Created On      : Mon Nov  8 20:47:28 1999
-- Last Modified By: Christfried Webers
-- Last Modified On: .
-- Update Count    : 0
-- Status          : Experimental
-------------------------------------------------------------------

-- The sonar data are returned in polar coordinates (Distance, Angle)
-- where the center of the robot is the origin of the coordinate system.
-- An angle of 0 degrees points in the direction of the robot front.
-- If the distance to the next object is too far away or the sonar
-- data are otherwise disturbed the flag Valid is set to False.

with Ada.Real_Time; use Ada.Real_Time;

with Metrics; use Metrics;

package Sonar is

   ----------------------------------------------------------------
   --
   -- Types
   --
   ----------------------------------------------------------------

   type Reading is record
      Distance : mm;
      Angle    : Degrees;
      Valid    : Boolean;
   end record;

   type Index is range -8 .. 8;
   type Readings is array (Index) of Reading;

   type Status is record
      Sonar     : Readings;
      TimeStamp : Time;
   end record;

   ----------------------------------------------------------------
   --
   -- Init and Shutdown
   --
   ----------------------------------------------------------------

   procedure Init;       -- There should be exeactly ONE
   procedure Shutdown;   -- Init and Shutdown

   ----------------------------------------------------------------
   --
   -- Reading data from the sonar system
   --
   ----------------------------------------------------------------

   procedure GetCurrentStatus (SonarStatus : out Status);
   -- potentialy blocking if no sonar data have been received at all

   procedure WaitForNewData;
   -- potentially blocking until new sonar data arrive

   ----------------------------------------------------------------
   --
   -- Sending commands to the sonar system
   --
   ----------------------------------------------------------------
   procedure SuspendReading;
   procedure ResumeReading;

end Sonar;