home *** CD-ROM | disk | FTP | other *** search
/ Virtual Reality Homebrewer's Handbook / vr.iso / vroom / puma.pas < prev    next >
Pascal/Delphi Source File  |  1996-03-19  |  6KB  |  152 lines

  1. program puma;
  2.  
  3. uses vroom,crt;
  4.  
  5. var base,waist,shoulder,elbow,wrist,hand,fing1,fing2 : file_object3d;
  6.     box1 : file_object3d;
  7.     contact_point : file_object3d;
  8.     correct_key : boolean;
  9.     ch : char;
  10.     waist_ang, elb_ang, shoul_ang : real;
  11.     t : real;
  12.     c : integer;
  13.  
  14. begin
  15.      writeln('Welcome to the teleoperator demo by Robin Hollands');
  16.      writeln;
  17.      writeln('In this demo you will be controlling a simplified PUMA robot arm.');
  18.      writeln('You can rotate the arm''s waist using ''w'' and ''W'' (shift w),');
  19.      writeln('likewise the shoulder and elbow can be controlled using ''s'',''S'',''e'', and ''E''.');
  20.      writeln;
  21.      writeln('The object is to manoevre the small box on the end of the arm near to');
  22.      writeln('the small box on the floor. Press ''g'' to grab the box. If you are too');
  23.      writeln('far away you will hear a beep. Once the box has been grabbed it can be ');
  24.      writeln('repositioned using the arm. Press ''r'' to release the box.');
  25.      writeln;
  26.      writeln('Press ''q'' when you''ve had enough.');
  27.      writeln;
  28.      writeln('Press ENTER to continue');
  29.      readln;
  30.      writeln('If the graphical picture represented the true enviroment that the robot');
  31.      writeln('arm was in, and if the orientation of the arm in the picture was governed');
  32.      writeln('by data coming from the real arm''s sensors, then it would be possible to');
  33.      writeln('to accurately control the arm without needing to be in the same location.');
  34.      writeln('This aspect of remote control is called Teleoperation. If the computer');
  35.      writeln('generatated image was an accurate representation of the robot working area');
  36.      writeln('then this is called Teleprescence.');
  37.      writeln;
  38.      writeln('The demo has been written using some software still under construction');
  39.      writeln('so the graphics are still a bit quirky. The final software will be much');
  40.      writeln('more powerful, allowing the viewer to move around in the virtual environment');
  41.      writeln('that the arm is in.');
  42.      writeln;
  43.      writeln('Press ENTER to continue');
  44.      readln;
  45.      waist_ang:=0;
  46.      elb_ang:=0;
  47.      shoul_ang:=0;
  48.  
  49.      Init_System;
  50.  
  51.      Set_Ambient_Intensity(0.5);
  52.      Set_Light(0.75,0,-1,-0.75);
  53.  
  54.      contact_point.Init('box.3d');
  55.      contact_point.Set_Reference_Point(5,5,5);
  56.      contact_point.Scale(0.1,0.1,0.1);
  57.      contact_point.MoveTo(-2.5,28.3,17.5);
  58.  
  59.      base.Init('base.3d');
  60.      waist.Init('waist.3d');
  61.      base.AddChild(@waist);
  62.      shoulder.Init('shoulder.3d');
  63.      waist.AddChild(@shoulder);
  64.      elbow.Init('elbow.3d');
  65.      shoulder.AddChild(@elbow);
  66.      elbow.AddChild(@contact_point);
  67.  
  68.      box1.Init('box.3d');
  69.      box1.Set_Reference_Point(5,5,5);
  70.      box1.Scale(0.1,0.1,0.1);
  71.      box1.MoveTo(15,15,0.5);
  72.  
  73.      Set_View(600,5,25,0,0,0);
  74.      Set_Window(-20,-15,20,15);
  75.  
  76.  
  77.      Redraw_Scene;
  78.  
  79.      repeat
  80.            correct_key:=true;
  81.            ch:=ReadKey;
  82.            case ch of
  83.                 'w' : begin
  84.                            waist.RotateZ(5);
  85.                            waist_ang:=waist_ang+5;
  86.                       end;
  87.                 'W' : begin
  88.                            waist.RotateZ(-5);
  89.                            waist_ang:=waist_ang-5;
  90.                       end;
  91.                 's' : begin
  92.                            shoulder.RotateZ_About(-waist_ang,0,0,0);
  93.                            shoulder.RotateX(5);
  94.                            shoulder.RotateZ_About(waist_ang,0,0,0);
  95.                            shoul_ang:=shoul_ang+5;
  96.                       end;
  97.                 'S' : begin
  98.                            shoulder.RotateZ_About(-waist_ang,0,0,0);
  99.                            shoulder.RotateX(-5);
  100.                            shoulder.RotateZ_About(waist_ang,0,0,0);
  101.                            shoul_ang:=shoul_ang-5;
  102.                       end;
  103.                 'e' : begin
  104.                            elbow.RotateZ_About(-waist_ang,0,0,0);
  105.                            elbow.RotateX(5);
  106.                            elbow.RotateZ_About(waist_ang,0,0,0);
  107.                            elb_ang:=elb_ang+5;
  108.                       end;
  109.                 'E' : begin
  110.                            elbow.RotateZ_About(-waist_ang,0,0,0);
  111.                            elbow.RotateX(-5);
  112.                            elbow.RotateZ_About(waist_ang,0,0,0);
  113.                            elb_ang:=elb_ang-5;
  114.                       end;
  115.                 'g' : begin
  116.                            if (abs(contact_point.reference_point.x-box1.reference_point.x)<131072)
  117.                            and (abs(contact_point.reference_point.y-box1.reference_point.y)<131072)
  118.                            and (abs(contact_point.reference_point.z-box1.reference_point.z)<131072)
  119.                            then contact_point.addchild(@box1)
  120.                            else
  121.                            begin
  122.                                 sound(220);
  123.                                 delay(200);
  124.                                 NoSound;
  125.                            end;
  126.                       end;
  127.                 'r' : begin
  128.                            contact_point.RemoveChild(@box1);
  129.                       end;
  130.                 'p' : begin
  131.                            Send_Screen_to_PCX('puma.pcx');
  132.                       end;
  133.            else
  134.                correct_key:=false;
  135.            end;
  136.            if correct_key then redraw_scene;
  137.      until ch='q';
  138.      stop_graphics;
  139.      writeln('Thank you for viewing the demo.');
  140.      writeln;
  141.      writeln('For more information contact Dr. Neil Mort or Robin Hollands');
  142.      writeln('The Department of Automatic Control & Systems Engineering');
  143.      writeln('University of Sheffield');
  144.      writeln('PO Box 600');
  145.      writeln('Mappin Street');
  146.      writeln('Sheffield');
  147.      writeln('S1 4DU');
  148.      writeln;
  149.      writeln('Tel: 0742 768555  x5559');
  150.      writeln('e-mail r.hollands@sheffield.ac.uk');
  151. end.
  152.