home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Virtual Reality Homebrewer's Handbook
/
vr.iso
/
vroom
/
puma2.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-03-19
|
6KB
|
148 lines
program puma2;
uses vroom,crt,cyberman;
var base,waist,shoulder,elbow,wrist,hand,fing1,fing2 : file_object3d;
box1 : file_object3d;
contact_point : file_object3d;
correct_key, mouse, cyber, junk : boolean;
ch : char;
waist_ang, elb_ang, shoul_ang : real;
t : real;
c : integer;
{$F+}
function My_KeyCheck(key : char) : boolean;
var test : boolean;
begin
test:=true;
case key of
'w' : begin
waist.RotateZ(5);
waist_ang:=waist_ang+5;
end;
'W' : begin
waist.RotateZ(-5);
waist_ang:=waist_ang-5;
end;
'a' : begin
shoulder.RotateZ_About(-waist_ang,0,0,0);
shoulder.RotateX(5);
shoulder.RotateZ_About(waist_ang,0,0,0);
shoul_ang:=shoul_ang+5;
end;
'A' : begin
shoulder.RotateZ_About(-waist_ang,0,0,0);
shoulder.RotateX(-5);
shoulder.RotateZ_About(waist_ang,0,0,0);
shoul_ang:=shoul_ang-5;
end;
'e' : begin
elbow.RotateZ_About(-waist_ang,0,0,0);
elbow.RotateX(5);
elbow.RotateZ_About(waist_ang,0,0,0);
elb_ang:=elb_ang+5;
end;
'E' : begin
elbow.RotateZ_About(-waist_ang,0,0,0);
elbow.RotateX(-5);
elbow.RotateZ_About(waist_ang,0,0,0);
elb_ang:=elb_ang-5;
end;
'g' : begin
if (abs(contact_point.reference_point.x-box1.reference_point.x)<131072)
and (abs(contact_point.reference_point.y-box1.reference_point.y)<131072)
and (abs(contact_point.reference_point.z-box1.reference_point.z)<131072)
then contact_point.addchild(@box1)
else
begin
sound(220);
delay(200);
NoSound;
end;
end;
'r' : begin
contact_point.RemoveChild(@box1);
end
else
test:=false;
end;
My_KeyCheck:=test;
end;
{$F-}
begin
writeln('Welcome to the teleoperator demo by Robin Hollands');
writeln;
writeln('In this demo you will be controlling a simplified PUMA robot arm.');
writeln('You can rotate the arm''s waist using ''w'' and ''W'' (shift w),');
writeln('likewise the shoulder and elbow can be controlled using ''a'',''A'',''e'', and ''E''.');
writeln;
writeln('The object is to manoevre the small box on the end of the arm near to');
writeln('the small box on the floor. Press ''g'' to grab the box. If you are too');
writeln('far away you will hear a beep. Once the box has been grabbed it can be ');
writeln('repositioned using the arm. Press ''r'' to release the box.');
writeln;
writeln('Press ''q'' when you''ve had enough.');
writeln;
writeln('Press ENTER to continue');
readln;
writeln('If the graphical picture represented the true enviroment that the robot');
writeln('arm was in, and if the orientation of the arm in the picture was governed');
writeln('by data coming from the real arm''s sensors, then it would be possible to');
writeln('to accurately control the arm without needing to be in the same location.');
writeln('This aspect of remote control is called Teleoperation. If the computer');
writeln('generatated image was an accurate representation of the robot working area');
writeln('then this is called Teleprescence.');
writeln;
writeln('In this second version of the demo, you can also move around the ');
writeln('environment using the mouse or cyberman and keypad as usual.');
writeln;
writeln('Press ENTER to continue');
readln;
waist_ang:=0;
elb_ang:=0;
shoul_ang:=0;
mouse:=false;
cyber:=false;
if cyberman_available then cyber:=true else if mouse_available then mouse:=true;
Init_System;
Set_Ambient_Intensity(0.5);
Set_Light(0.75,0,-1,-0.75);
contact_point.Init('box.3d');
contact_point.Set_Reference_Point(5,5,5);
contact_point.Scale(0.1,0.1,0.1);
contact_point.MoveTo(-2.5,28.3,17.5);
base.Init('base.3d');
waist.Init('waist.3d');
base.AddChild(@waist);
shoulder.Init('shoulder.3d');
waist.AddChild(@shoulder);
elbow.Init('elbow.3d');
shoulder.AddChild(@elbow);
elbow.AddChild(@contact_point);
box1.Init('box.3d');
box1.Set_Reference_Point(5,5,5);
box1.Scale(0.1,0.1,0.1);
box1.MoveTo(15,15,0.5);
Set_View(600,5,25,0,0,0);
Set_Window(-20,-15,20,15);
Store_Settings;
User_KeyCheck_Proc(My_KeyCheck);
Redraw_Scene;
repeat
junk:=false;
if cyber then junk:=cyberman_check else if mouse then junk:=mouse_check;
if KeyBoard_Check or junk then redraw_scene;
until false;
end.