EM2019WSP01/Implementierungsdetails

Aus Verteilte Systeme - Wiki
Zur Navigation springen Zur Suche springen

Information

Die Codebeispiele sollen einen Einblick in die Verwendung von gnatmindstorms2011, insbesondere dem Verzeichnis gnatmindstorms2011/lib/gcc/arm-eabi/4.5.3/rts-ravenscar-sfp/drivers, geben. Hier sind keine genauen Ausführungen des Projekts zu finden. Dafür wird auf das Gitlab Repository verwiesen.

Motoren

with Ada.Real_Time;       use Ada.Real_Time;
with NXT;                 use NXT;
with NXT.Motor_Controls;  use NXT.Motor_Controls;

LeftMotor  : constant Motor_ID := Motor_A;
RightMotor : constant Motor_ID := Motor_C;

procedure Forward is 
begin
  Control_Motor(LeftMotor, 50, Forward);
  Control_Motor(RightMotor, 50, Forward);
end Forward;

procedure TurnRight is 
begin
  Control_Motor(LeftMotor, 50, Forward);
  Control_Motor(RightMotor, 50, Backward);
end TurnRight;

procedure BrakeAndStop is 
begin
  Control_Motor(LeftMotor, 0, Brake);
  Control_Motor(RightMotor, 0, Brake);
end BrakeAndStop;
 <\nowiki>

= Ultraschallsensor =

 <nowiki>
with Ada.Real_Time;                 use Ada.Real_Time;
with NXT;                           use NXT;
with NXT.Ultrasonic_Sensors;        use NXT.Ultrasonic_Sensors;
with NXT.Ultrasonic_Sensors.Ctors;  use NXT.Ultrasonic_Sensors.Ctors;

-- create instance for the front ultrasonic sensor
FrontUltrasonicSensor : Ultrasonic_Sensor := Make (Sensor_3);

-- variable distance
distance : Integer := 1;

-- measure distance to obstacles in front of the robot
Get_Distance(FrontUltrasonicSensor, distance);

-- measuring requires a little delay
delay until Clock + Milliseconds (100);
 

Farbsensor