#VRML V2.0 utf8 # Name: ANH LE # SID: 13291487 # CS 184 Fall 98 # Section: 104 # Lab 4 # Due date: 9/24/98 # Developed on WinNT computer in 330 lab # I use java to do this lab # The java class is in recorder.java # Files submitted are: this (lab4.wrl), recorder.java and its class (recorder.class) # Features: My robot has two little fingers that can rotate toward each other # like grabing manner, all of its movements: rotation and translation can be recorded and # played back. The play back also makes the Control Levers move according to the movements # of the robot. # I only play back once when the button is clicked, i.e all positions recorded so far will # be played back once. Then the play back stops to wait for another time. # (I don't want to use another stop button, that's why) # I found some bugs at last minute, that made me 1 hr late Transform { rotation 1 0 0 -1.5708 children [ # the whole robot DEF robot Transform { rotation 1 0 0 1.5708 children [ Transform { translation 2 -2.95 0 scale 2.5 0.15 2.5 children [ DEF rod Shape { appearance DEF rodCl Appearance { material Material { diffuseColor 0.8 0.8 0.8 specularColor 0.2 0.4 0.3 shininess 0.6 }} geometry Cylinder { height 5 radius 0.5 }}] } DEF waistSensor Transform { translation 2 0 0 children [ DEF waist Shape { # the waist appearance DEF waistCl Appearance { material Material { diffuseColor 0.2 0.9 0.9 specularColor 0.4 1 0.2 shininess 1 }} geometry Cylinder { height 5 radius 0.5 } } Transform { translation 0 -2.5 0 scale 2 0.05 2 children [USE waist] } Transform { translation 1.5 2 0 rotation 0 0 1 1.5708 scale 0.6 1 0.6 children [ USE rod ] } Transform { translation -0.5 2 0 rotation 0 0 1 1.5708 children [ DEF my_bolt Shape { appearance DEF boltCl Appearance { material Material { diffuseColor 0.5 0.2 0.2 }} geometry Cylinder { height 0.15 radius 0.35 } }] } Transform { translation 0.5 2 0 rotation 0 0 1 1.5708 children [USE my_bolt] } Transform { rotation 0 0 1 -1.5708 children [ DEF shoulderSensor Transform { center -2 4.5 0 children [ Transform { rotation 0 0 1 1.5708 children [ Transform { translation 2.5 1.5 0 # rotation 1 0 0 2.5 children [ DEF shoulder Shape { # shoulder appearance DEF shoulderCl Appearance { material Material { diffuseColor 0.5765 0.4392 0.868824 }} geometry Box { size 0.35 2.5 0.8 } } ] } Transform { translation 3.4 1.5 0 # rotation 1 0 0 2.5 children [ USE shoulder] } Transform { translation 3 0.8 0 rotation 0 0 1 1.5708 scale 0.4 0.35 0.4 children [USE rod] } Transform { translation 2.3 0.8 0 rotation 0 0 1 1.5708 scale 0.8 0.8 0.8 children [USE my_bolt] } Transform { translation 3.6 0.8 0 rotation 0 0 1 1.5708 scale 0.8 0.8 0.8 children [USE my_bolt] } Transform { rotation 0 0 1 -1.5708 children [ DEF elbowSensor Transform { center -0.8 2.95 0 children [ Transform { rotation 0 0 1 1.5708 children [ Transform { translation 2.95 0 0 children [ DEF elbow Shape { # elbow appearance DEF elbowCl Appearance { material Material { diffuseColor 1.0 0.2 0.5 }} geometry Box { size 0.4 2.5 0.8 } } ] } DEF wristSensor Transform { translation 3 -1.5 0 children [ DEF wrist Transform { scale 0.2 0.2 0.2 children [ Shape { appearance DEF wristCl Appearance { material Material { diffuseColor 0 0 1 specularColor 0.2 0.4 0.4 shininess 0.8 }} geometry Cylinder { height 5 radius 0.5 } } ] } Transform { translation 0 -0.3 0 scale 0.1 0.3 0.1 rotation 0 0 1 1.5708 children [ USE rod] } Transform { translation -0.35 -0.3 0 scale 0.35 0.07 0.35 rotation 0 0 1 1.5708 children [ DEF hand Shape { appearance DEF handCl Appearance { material Material { diffuseColor 1 0 0 specularColor 1 0.4 0 shininess 0.6 }} geometry Cylinder { height 5 radius 0.5 }} ] } Transform { translation 0.35 -0.3 0 scale 0.35 0.07 0.35 rotation 0 0 1 1.5708 children [ USE hand] } Transform { rotation 0 0 1 -1.5708 children [ DEF handSensor Transform { center 0.3 0 0 children [ Transform { rotation 0 0 1 1.5708 children [ Transform { translation -0.58 -0.5 0 scale 0.3 0.3 0.3 children [ DEF upperfinger Shape { appearance USE handCl geometry Box { size 0.35 2.5 0.8 } } ] } Transform { translation 0.58 -0.5 0 scale 0.3 0.3 0.3 children [ USE upperfinger] } # Two fingers (left, right side) can rotate toward # each other in a picking manner Transform { rotation 1 0 0 -1.5708 children [ DEF rightfingerSensor Transform { center 0.45 0 -0.8 #rotation 0 1 0 0.9 children [ Transform { rotation 1 0 0 1.5708 children [ Transform { translation 0.58 -1.1 0 scale 0.35 0.3 0.06 children [ DEF lowfinger Shape { appearance DEF fingerCl Appearance { material Material { diffuseColor 0 1 0 specularColor 0.2 0.4 0.3 shininess 0.6 }} geometry Box { size 0.35 3 0.8 } }] } ] } ] } ] } Transform { rotation 1 0 0 1.5708 children [ DEF leftfingerSensor Transform { center -0.45 0 0.8 children [ Transform { rotation 1 0 0 -1.5708 children [ Transform { translation -0.58 -1.1 0 scale 0.35 0.3 0.06 children [ DEF lowfinger Shape { appearance DEF fingerCl Appearance { material Material { diffuseColor 0 1 0 specularColor 0.2 0.4 0.3 shininess 0.6 }} geometry Box { size 0.35 3 0.8 } }] } # Transform { # translation 0.58 -1 0 # scale 0.35 0.3 0.06 # # children [ USE lowfinger] # } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } # Nodes for Control Levers DEF waistLever Transform { translation -5.5 4 0 children [ DEF waistControl CylinderSensor { minAngle -1.5 maxAngle 1.5 } Group { children [ Transform { rotation 1 0 0 1.5708 children [ Transform { translation 0 1.5 0 children [ Shape { appearance USE waistCl geometry Sphere { radius 0.25 } }] } Transform { translation 0 0.7 0 children [ Shape { appearance USE waistCl geometry Cylinder { radius 0.15 height 1.5 } } ] } ] } ] } ] } Transform { translation -6.5 1.9 0 rotation 0 0 1 -1.5708 children [ DEF shoulderLever Transform { rotation 0 0 1 -1.5708 children [ DEF shoulderControl CylinderSensor { minAngle -1.5 maxAngle 1.5 } Group { children [ Transform { rotation 1 0 0 1.5708 children [ Transform { translation 0 1.5 0 children [ Shape { appearance USE shoulderCl geometry Sphere { radius 0.25 } }] } Transform { translation 0 0.7 0 children [ Shape { appearance USE shoulderCl geometry Cylinder { radius 0.15 height 1.5 } } ] } ] } ] } ] } ] } Transform { translation -4.5 1.9 0 rotation 0 0 1 -1.5708 children [ DEF elbowLever Transform { rotation 0 0 1 -1.5708 children [ DEF elbowControl CylinderSensor { minAngle -0.785 maxAngle 0.785 } Group { children [ Transform { rotation 1 0 0 1.5708 children [ Transform { translation 0 1.5 0 children [ Shape { appearance USE elbowCl geometry Sphere { radius 0.25 } }] } Transform { translation 0 0.7 0 children [ Shape { appearance USE elbowCl geometry Cylinder { radius 0.15 height 1.5 } } ] } ] } ] } ] } ] } DEF wristLever Transform { translation -6.5 -0.2 0 children [ DEF wristControl CylinderSensor { minAngle -1.5 maxAngle 1.5 } Group { children [ Transform { rotation 1 0 0 1.5708 children [ Transform { translation 0 2 0 children [ Shape { appearance USE wristCl geometry Sphere { radius 0.25 } }] } Transform { translation 0 1 0 children [ Shape { appearance USE wristCl geometry Cylinder { radius 0.15 height 2 } } ] } ] } ] } ] } Transform { translation -3.5 -0.2 0 rotation 0 0 1 -1.5708 children [ DEF handLever Transform { rotation 0 0 1 -1.5708 children [ DEF handControl CylinderSensor { minAngle -0.9 maxAngle 0.9 } Group { children [ Transform { rotation 1 0 0 1.5708 children [ Transform { translation 0 1.5 0 children [ Shape { appearance USE handCl geometry Sphere { radius 0.25 } }] } Transform { translation 0 0.7 0 children [ Shape { appearance USE handCl geometry Cylinder { radius 0.15 height 1.5 } } ] } ] } ] } ] } ] } DEF fingerLever Transform { translation -6.5 -1.6 0 children [ DEF fingerControl CylinderSensor { minAngle 0 maxAngle 0.6 } Group { children [ Transform { rotation 1 0 0 1.5708 children [ Transform { translation 0 2 0 children [ Shape { appearance USE fingerCl geometry Sphere { radius 0.25 } }] } Transform { translation 0 1 0 children [ Shape { appearance USE fingerCl geometry Cylinder { radius 0.15 height 2 } } ] } ] } ] } ] } Transform { translation -5.5 4 0 rotation 1 0 0 1.5708 children [ DEF base Shape { appearance USE rodCl geometry Extrusion { crossSection [ 1.0000 0.0000 # Coordinates of a unit CCW circle 0.8090 -0.5878 0.3090 -0.9511 -0.3090 -0.9511 -0.8090 -0.5878 -1.0000 0.0000 -0.8090 0.5878 -0.3090 0.9511 0.3090 0.9511 0.8090 0.5878 1.0000 0.0000 ] spine [ 0 0 -0.05 0 0 0.05 ] scale [0.5 0.5] endCap TRUE beginCap TRUE solid FALSE convex FALSE } } ] } # base of shoulderLever Transform { translation -6.5 1.9 0 rotation 0 1 0 -1.5708 children [USE base] } # base of elbowLever Transform { translation -4.5 1.9 0 rotation 0 1 0 -1.5708 children [USE base] } # base of wristLever Transform { rotation 1 0 0 1.5708 translation -6.5 -0.2 0 children [USE base] } # base of handLever Transform { translation -3.5 -0.2 0 rotation 0 1 0 -1.5708 children [USE base] } # base of fingerLever Transform { translation -6.5 -1.6 0 rotation 1 0 0 1.5708 children [USE base] } Transform { translation -5.5 -0.8 -0.5 children [ Shape { appearance DEF panelCl Appearance { material Material { diffuseColor 0.8 0.6 0.5 }} geometry Box { size 5 11 0.5 } } ] } Transform { translation -5.3 -4.5 0 children [ Shape { appearance DEF sliderpanelCl Appearance { material Material { diffuseColor 1 0.5 0.2 }} geometry Box { size 4.1 2.8 1 } } ] } Transform { translation -5.5 -4.5 0.75 children [ DEF panel Transform { children [ DEF sliderControl PlaneSensor { minPosition -1.2 -1 maxPosition 1.6 1 } Shape { appearance DEF sliderCl Appearance { material Material { diffuseColor 1 1 0 }} geometry Box { size 0.5 0.5 0.5 } } ] }] } # Buttons: Record Next, Step back, Step forward, Play back, Reset Group { children [ Transform { translation 2.8 -5 -0.3 scale 5.5 1 0.2 children [ Shape { appearance Appearance { material Material { diffuseColor 0.65 0.5 0.3 } } geometry Box{} }] }, Transform { # Record next translation -1.5 -5.2 0 children [ Transform { scale 0.5 0.5 0.08 children [ Shape { appearance DEF buttonCl Appearance { material Material { diffuseColor 0.7 0.7 0.7 specularColor 1 0.2 1 shininess 0.1 } } geometry Sphere {} }] }, Transform { translation -1 0.7 0 scale 0.4 0.4 2 children [ Shape { appearance DEF textCl Appearance { material Material { diffuseColor 1 1 1 } } geometry Text { string "Record Next" fontStyle FontStyle { family "HELVETICA" } } } ]}, DEF recordNextSensor TouchSensor {} ] } Transform { # step back translation 0.5 -5.2 0 children [ Transform { scale 0.5 0.5 0.08 children [ Shape { appearance USE buttonCl geometry Sphere {} }] }, Transform { translation -0.5 0.7 0 scale 0.4 0.4 2 children [ Shape { appearance USE textCl geometry Text { string "Step Back" fontStyle FontStyle { family "HELVETICA" } } } ]}, DEF stepBackSensor TouchSensor {} ] } Transform { # step forward translation 2.5 -5.2 0 children [ Transform { scale 0.5 0.5 0.08 children [ Shape { appearance USE buttonCl geometry Sphere {} }] }, Transform { translation -0.5 0.7 0 scale 0.4 0.4 2 children [ Shape { appearance USE textCl geometry Text { string "Step Forward" fontStyle FontStyle { family "HELVETICA" } } } ]}, DEF stepForwardSensor TouchSensor {} ] } Transform { # play back translation 5 -5.2 0 children [ Transform { scale 0.5 0.5 0.08 children [ Shape { appearance USE buttonCl geometry Sphere {} }] }, Transform { translation -0.5 0.7 0 scale 0.4 0.4 2 children [ Shape { appearance USE textCl geometry Text { string "Play back" fontStyle FontStyle { family "HELVETICA" } } } ]}, DEF playBackSensor TouchSensor {} ] } Transform { # reset translation 7 -5.2 0 children [ Transform { scale 0.5 0.5 0.08 children [ Shape { appearance USE buttonCl geometry Sphere {} }] }, Transform { translation -0.5 0.7 0 scale 0.4 0.4 2 children [ Shape { appearance USE textCl geometry Text { string "Reset" fontStyle FontStyle { family "HELVETICA" } } } ]}, DEF resetSensor TouchSensor {} ] } ] } DEF robotRecorder Script { url "recorder.class" field SFString nodename "robot" field SFRotation current_rotation 0 1 0 0 field SFVec3f current_translation 0 0 0 eventIn SFRotation set_rotation eventIn SFVec3f set_translation eventIn SFBool record_next eventIn SFBool step_back eventIn SFBool reset eventIn SFBool step_forward eventIn SFBool play_back eventIn SFFloat set_fraction eventOut SFRotation rotation_changed eventOut SFVec3f translation_changed } DEF waistRecorder Script { url "recorder.class" field SFString nodename "waist" field SFRotation current_rotation 0 1 0 0 field SFVec3f current_translation 0 0 0 eventIn SFRotation set_rotation eventIn SFVec3f set_translation eventIn SFBool record_next eventIn SFBool step_back eventIn SFBool reset eventIn SFBool step_forward eventIn SFBool play_back eventIn SFFloat set_fraction eventOut SFRotation rotation_changed eventOut SFVec3f translation_changed } DEF shoulderRecorder Script { url "recorder.class" field SFString nodename "shoulder" field SFRotation current_rotation 0 1 0 0 field SFVec3f current_translation 0 0 0 eventIn SFRotation set_rotation eventIn SFVec3f set_translation eventIn SFBool record_next eventIn SFBool step_back eventIn SFBool reset eventIn SFBool step_forward eventIn SFBool play_back eventIn SFFloat set_fraction eventOut SFRotation rotation_changed eventOut SFVec3f translation_changed } DEF elbowRecorder Script { url "recorder.class" field SFString nodename "elbow" field SFRotation current_rotation 0 1 0 0 field SFVec3f current_translation 0 0 0 eventIn SFRotation set_rotation eventIn SFVec3f set_translation eventIn SFBool record_next eventIn SFBool step_back eventIn SFBool reset eventIn SFBool step_forward eventIn SFBool play_back eventIn SFFloat set_fraction eventOut SFRotation rotation_changed eventOut SFVec3f translation_changed } DEF wristRecorder Script { url "recorder.class" field SFString nodename "wrist" field SFRotation current_rotation 0 1 0 0 field SFVec3f current_translation 0 0 0 eventIn SFRotation set_rotation eventIn SFVec3f set_translation eventIn SFBool record_next eventIn SFBool step_back eventIn SFBool reset eventIn SFBool step_forward eventIn SFBool play_back eventIn SFFloat set_fraction eventOut SFRotation rotation_changed eventOut SFVec3f translation_changed } DEF handRecorder Script { url "recorder.class" field SFString nodename "hand" field SFRotation current_rotation 0 1 0 0 field SFVec3f current_translation 0 0 0 eventIn SFRotation set_rotation eventIn SFVec3f set_translation eventIn SFBool record_next eventIn SFBool reset eventIn SFBool step_back eventIn SFBool step_forward eventIn SFBool play_back eventIn SFFloat set_fraction eventOut SFRotation rotation_changed eventOut SFVec3f translation_changed } DEF leftfingerRecorder Script { url "recorder.class" field SFString nodename "leftfinger" field SFRotation current_rotation 0 1 0 0 field SFVec3f current_translation 0 0 0 eventIn SFRotation set_rotation eventIn SFVec3f set_translation eventIn SFBool record_next eventIn SFBool step_back eventIn SFBool reset eventIn SFBool step_forward eventIn SFBool play_back eventIn SFFloat set_fraction eventOut SFRotation rotation_changed eventOut SFVec3f translation_changed } DEF rightfingerRecorder Script { url "recorder.class" field SFString nodename "rightfinger" field SFRotation current_rotation 0 1 0 0 field SFVec3f current_translation 0 0 0 eventIn SFRotation set_rotation eventIn SFVec3f set_translation eventIn SFBool record_next eventIn SFBool step_back eventIn SFBool reset eventIn SFBool step_forward eventIn SFBool play_back eventIn SFFloat set_fraction eventOut SFRotation rotation_changed eventOut SFVec3f translation_changed } DEF MainClock TimeSensor { cycleInterval 2 loop TRUE } # ROUTING ROUTE waistControl.rotation_changed TO waistLever.set_rotation #ROUTE waistControl.rotation_changed TO waistSensor.set_rotation ROUTE waistControl.rotation_changed TO waistRecorder.set_rotation ROUTE waistRecorder.rotation_changed TO waistSensor.set_rotation ROUTE waistRecorder.rotation_changed TO waistLever.set_rotation ROUTE shoulderControl.rotation_changed TO shoulderLever.set_rotation #ROUTE shoulderControl.rotation_changed TO shoulderSensor.set_rotation ROUTE shoulderControl.rotation_changed TO shoulderRecorder.set_rotation ROUTE shoulderRecorder.rotation_changed TO shoulderSensor.set_rotation ROUTE shoulderRecorder.rotation_changed TO shoulderLever.set_rotation ROUTE elbowControl.rotation_changed TO elbowLever.set_rotation #ROUTE elbowControl.rotation_changed TO elbowSensor.set_rotation ROUTE elbowControl.rotation_changed TO elbowRecorder.set_rotation ROUTE elbowRecorder.rotation_changed TO elbowSensor.set_rotation ROUTE elbowRecorder.rotation_changed TO elbowLever.set_rotation ROUTE wristControl.rotation_changed TO wristLever.set_rotation #ROUTE wristControl.rotation_changed TO wristSensor.set_rotation ROUTE wristControl.rotation_changed TO wristRecorder.set_rotation ROUTE wristRecorder.rotation_changed TO wristSensor.set_rotation ROUTE wristRecorder.rotation_changed TO wristLever.set_rotation ROUTE handControl.rotation_changed TO handLever.set_rotation #ROUTE handControl.rotation_changed TO handSensor.set_rotation ROUTE handControl.rotation_changed TO handRecorder.set_rotation ROUTE handRecorder.rotation_changed TO handSensor.set_rotation ROUTE handRecorder.rotation_changed TO handLever.set_rotation ROUTE fingerControl.rotation_changed TO fingerLever.set_rotation #ROUTE fingerControl.rotation_changed TO leftfingerSensor.set_rotation #ROUTE fingerControl.rotation_changed TO rightfingerSensor.set_rotation ROUTE leftfingerRecorder.rotation_changed TO fingerLever.set_rotation ROUTE rightfingerRecorder.rotation_changed TO fingerLever.set_rotation ROUTE fingerControl.rotation_changed TO leftfingerRecorder.set_rotation ROUTE leftfingerRecorder.rotation_changed TO leftfingerSensor.set_rotation ROUTE fingerControl.rotation_changed TO rightfingerRecorder.set_rotation ROUTE rightfingerRecorder.rotation_changed TO rightfingerSensor.set_rotation ROUTE sliderControl.translation_changed TO panel.set_translation #ROUTE sliderControl.translation_changed TO robot.set_translation #ROUTE sliderControl.translation_changed TO robotRecorder.set_translation ROUTE panel.translation_changed TO robotRecorder.set_translation ROUTE robotRecorder.translation_changed TO robot.set_translation ROUTE robotRecorder.translation_changed TO panel.set_translation ROUTE recordNextSensor.isActive TO waistRecorder.record_next ROUTE stepBackSensor.isActive TO waistRecorder.step_back ROUTE stepForwardSensor.isActive TO waistRecorder.step_forward ROUTE playBackSensor.isActive TO waistRecorder.play_back ROUTE resetSensor.isActive TO waistRecorder.reset ROUTE MainClock.fraction_changed TO waistRecorder.set_fraction ROUTE recordNextSensor.isActive TO shoulderRecorder.record_next ROUTE stepBackSensor.isActive TO shoulderRecorder.step_back ROUTE stepForwardSensor.isActive TO shoulderRecorder.step_forward ROUTE playBackSensor.isActive TO shoulderRecorder.play_back ROUTE resetSensor.isActive TO shoulderRecorder.reset ROUTE MainClock.fraction_changed TO shoulderRecorder.set_fraction ROUTE recordNextSensor.isActive TO elbowRecorder.record_next ROUTE stepBackSensor.isActive TO elbowRecorder.step_back ROUTE stepForwardSensor.isActive TO elbowRecorder.step_forward ROUTE playBackSensor.isActive TO elbowRecorder.play_back ROUTE resetSensor.isActive TO elbowRecorder.reset ROUTE MainClock.fraction_changed TO elbowRecorder.set_fraction ROUTE recordNextSensor.isActive TO wristRecorder.record_next ROUTE stepBackSensor.isActive TO wristRecorder.step_back ROUTE stepForwardSensor.isActive TO wristRecorder.step_forward ROUTE playBackSensor.isActive TO wristRecorder.play_back ROUTE resetSensor.isActive TO wristRecorder.reset ROUTE MainClock.fraction_changed TO wristRecorder.set_fraction ROUTE recordNextSensor.isActive TO handRecorder.record_next ROUTE stepBackSensor.isActive TO handRecorder.step_back ROUTE stepForwardSensor.isActive TO handRecorder.step_forward ROUTE playBackSensor.isActive TO handRecorder.play_back ROUTE resetSensor.isActive TO handRecorder.reset ROUTE MainClock.fraction_changed TO handRecorder.set_fraction ROUTE recordNextSensor.isActive TO leftfingerRecorder.record_next ROUTE stepBackSensor.isActive TO leftfingerRecorder.step_back ROUTE stepForwardSensor.isActive TO leftfingerRecorder.step_forward ROUTE playBackSensor.isActive TO leftfingerRecorder.play_back ROUTE resetSensor.isActive TO leftfingerRecorder.reset ROUTE MainClock.fraction_changed TO leftfingerRecorder.set_fraction ROUTE recordNextSensor.isActive TO rightfingerRecorder.record_next ROUTE stepBackSensor.isActive TO rightfingerRecorder.step_back ROUTE stepForwardSensor.isActive TO rightfingerRecorder.step_forward ROUTE playBackSensor.isActive TO rightfingerRecorder.play_back ROUTE resetSensor.isActive TO rightfingerRecorder.reset ROUTE MainClock.fraction_changed TO rightfingerRecorder.set_fraction ROUTE recordNextSensor.isActive TO robotRecorder.record_next ROUTE stepBackSensor.isActive TO robotRecorder.step_back ROUTE stepForwardSensor.isActive TO robotRecorder.step_forward ROUTE playBackSensor.isActive TO robotRecorder.play_back ROUTE resetSensor.isActive TO robotRecorder.reset ROUTE MainClock.fraction_changed TO robotRecorder.set_fraction Viewpoint { position -1 0 15 description "Front" } NavigationInfo { type "EXAMINE" }