From: Markus R. <rol...@us...> - 2006-02-24 10:40:47
|
Update of /cvsroot/simspark/simspark/simulations/parts/rsg/agent In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15792/agent Added Files: ball.rsg buggy.rsg flag.rsg leggedsphere.rsg simspark.rsg soccer.rsg soccerplayer.rsg Log Message: - added rsg and RoSiML demo files --- NEW FILE: ball.rsg --- ; -*- mode: lisp; -*- (RubySceneGraph 0 1) ( (define $Radius (eval Soccer.BallRadius)) (define $Material matOrange) (define $Density (eval Soccer.BallDensity)) (node Ball (setLocalPos 0 0 0.5) (setName Ball) (node Sphere (setRadius $Radius) (setMaterial $Material) ) (node Body (setName physics) (setSphere $Density $Radius) (node DragController (setAngularDrag 0.2) (setLinearDrag 0.4) ) ) (node SphereCollider (setName geometry) (setRadius $Radius) (node ContactJointHandler (setContactBounceMode false) (setContactSlipMode true) (setContactSlip 0.1 0.1) (setContactSoftERPMode true) (setContactSoftERP 0.5) (setContactSoftCFM true) (setContactSoftCFM 0.3) ) ) (node ObjectState (setPerceptName Ball) ) ) ) --- NEW FILE: soccer.rsg --- ; -*- mode: lisp; -*- (RubySceneGraph 0 1) ( ; ; define constants, copy values from the ScriptServer Soccer namespace ; (define $FieldLength (eval Soccer.FieldLength)) (define $FieldWidth (eval Soccer.FieldWidth)) (define $BorderExt (eval Soccer.BorderSize)) (define $GoalWidth (eval Soccer.GoalWidth)) (define $GoalDepth (eval Soccer.GoalDepth)) (define $GoalHeight (eval Soccer.GoalHeight)) ; height of the field ground plane (define $FieldBaseHeight 4) ; with of the side boundary (define $SideExt 2) ; height of the side boundary (define $SideHeight 1) ; height of a field line (define $LineHeight 0.2) (define $FieldMaterial matGreen) (define $BorderMaterial matYellow) (define $SideMaterial matGrey) (define $LineMaterial matWhite) (define $GoalMaterial matWhite) ; calc some helper vars (define $FieldBase (eval -1 * $FieldBaseHeight / 2.0)) (define $LineBase 0) (define $FieldHalfLength (eval $FieldLength / 2.0)) (define $FieldHalfWidth (eval $FieldWidth / 2.0)) (define $GoalHalfWidth (eval $GoalWidth / 2.0)) (define $GoalHalfHeight (eval $GoalHeight / 2.0)) (define $GoalHalfDepth (eval $GoalDepth / 2.0)) (define $HalfBorderExt (eval $BorderExt / 2.0)) (define $BorderLength (eval $FieldHalfLength + $HalfBorderExt)) (define $BorderWidth (eval $FieldHalfWidth + $HalfBorderExt)) (define $SideLength (eval $FieldHalfLength + $BorderExt)) (define $SideWidth (eval $FieldHalfWidth + $BorderExt)) (define $LineWidth (eval $FieldWidth - $LineHeight)) (define $BarDiameter $LineHeight) (define $BarRadius (eval $BarDiameter / 2.0)) ; ; construct playing field ; ; add lights (node Transform (setLocalPos -10 10 10) (node Light (setDiffuse 1.0 1.0 1.0 1.0) (setSpecular 0.1 0.1 0.1 1.0) (setAmbient 0.8 0.8 0.8 1.0) ) ) ; add lights (node Transform (setLocalPos 10 -10 10) (node Light (setDiffuse 1.0 1.0 1.0 1.0) (setSpecular 0.1 0.1 0.1 1.0) (setAmbient 0.0 0.0 0.0 1.0) ) ) ; create the base plane (node Transform (setLocalPos 0 0 $FieldBase) (node Box (setMaterial $FieldMaterial) (setExtents $FieldLength $FieldWidth $FieldBaseHeight) ) (node PlaneCollider (setParams 0 0 1.0 0) (node ContactJointHandler (setContactBounceMode false) ) ) ) ; create the left goal (node Transform (setName GoalBoxL) (setLocalPos (eval -1 * (eval $FieldHalfLength + $GoalHalfDepth)) 0 $GoalHalfHeight) (node BoxCollider (setBoxLengths $GoalDepth $GoalWidth $GoalHeight) (node ContactJointHandler (setContactBounceMode false) ) ) (node RecorderHandler (setName recorder) ) ) ; create the goal bar on top of the goal (left goal) (node Transform (setLocalPos (eval -1 * (eval $FieldHalfLength + $GoalHalfDepth) + $LineHeight) 0 (eval $GoalHeight + $BarRadius) ) (node Box (setExtents $GoalDepth (eval $GoalWidth - 0.1) $BarDiameter) (setMaterial $GoalMaterial) ) (node BoxCollider (setBoxLengths $GoalDepth (eval $GoalWidth - 0.1) $BarDiameter) ) ) ; create the left goal post (left goal) (node Transform (setLocalPos (eval -1 * (eval $FieldHalfLength + $GoalHalfDepth) + $LineHeight) (eval -1 * (eval $GoalHalfWidth + $BarRadius)) (eval $GoalHalfHeight + $BarRadius) ) (node Box (setExtents $GoalDepth $BarDiameter $GoalHeight) (setMaterial $GoalMaterial) ) (node BoxCollider (setBoxLengths $GoalDepth $BarDiameter $GoalHeight) ) ) ; create the right goal post (left goal) (node Transform (setLocalPos (eval -1 * (eval $FieldHalfLength + $GoalHalfDepth) + $LineHeight) (eval $GoalHalfWidth + $BarRadius) (eval $GoalHalfHeight + $BarRadius) ) (node Box (setExtents $GoalDepth $BarDiameter $GoalHeight) (setMaterial $GoalMaterial) ) (node BoxCollider (setBoxLengths $GoalDepth $BarDiameter $GoalHeight) ) ) ; create the right goal (node Transform (setName GoalBoxR) (setLocalPos (eval $FieldHalfLength + $GoalHalfDepth) 0 $GoalHalfHeight) (node BoxCollider (setBoxLengths $GoalDepth $GoalWidth $GoalHeight) (node ContactJointHandler (setContactBounceMode false) ) ) (node RecorderHandler (setName recorder) ) ) ; create the goal bar on top of the goal (right goal) (node Transform (setLocalPos (eval (eval $FieldHalfLength + $GoalHalfDepth) - $LineHeight) 0 (eval $GoalHeight + $BarRadius) ) (node Box (setExtents $GoalDepth (eval $GoalWidth - 0.1) $BarDiameter) (setMaterial $GoalMaterial) ) (node BoxCollider (setBoxLengths $GoalDepth (eval $GoalWidth - 0.1) $BarDiameter) ) ) ; create the left goal post (right goal) (node Transform (setLocalPos (eval (eval $FieldHalfLength + $GoalHalfDepth) - $LineHeight) (eval -1 * (eval $GoalHalfWidth + $BarRadius)) (eval $GoalHalfHeight + $BarRadius) ) (node Box (setExtents $GoalDepth $BarDiameter $GoalHeight) (setMaterial $GoalMaterial) ) (node BoxCollider (setBoxLengths $GoalDepth $BarDiameter $GoalHeight) ) ) ; create the right goal post (right goal) (node Transform (setLocalPos (eval (eval $FieldHalfLength + $GoalHalfDepth) - $LineHeight) (eval $GoalHalfWidth + $BarRadius) (eval $GoalHalfHeight + $BarRadius) ) (node Box (setExtents $GoalDepth $BarDiameter $GoalHeight) (setMaterial $GoalMaterial) ) (node BoxCollider (setBoxLengths $GoalDepth $BarDiameter $GoalHeight) ) ) ; create left side (node Transform (setLocalPos (eval -1 * $SideLength) 0 0) (node Box (setMaterial $SideMaterial) (setExtents $SideHeight (eval $FieldWidth + 2 * $BorderExt) $SideExt) ) (node PlaneCollider (setParams 1.0 0 0 (eval -1 * $SideLength)) ) ) ; create right side (node Transform (setLocalPos $SideLength 0 0) (node Box (setMaterial $SideMaterial) (setExtents $SideHeight (eval $FieldWidth + 2 * $BorderExt) $SideExt) ) (node PlaneCollider (setParams -1.0 0 0 (eval -1 * $SideLength)) ) ) ; create back side (node Transform (setLocalPos 0 $SideWidth 0) (node Box (setMaterial $SideMaterial) (setExtents (eval $FieldLength + 2 * $BorderExt) $SideHeight $SideExt) ) (node PlaneCollider (setParams 0 -1.0 0 (eval -1 * $SideWidth)) ) ) ; create front side (node Transform (setLocalPos 0 (eval -1 * $SideWidth) 0) (node Box (setMaterial $SideMaterial) (setExtents (eval $FieldLength + 2 * $BorderExt) $SideHeight $SideExt) ) (node PlaneCollider (setParams 0 1.0 0 (eval -1 * $SideWidth)) ) ) ; create middle line (node Transform (setLocalPos 0 0 $LineBase) (node Box (setExtents $LineHeight $LineWidth $LineHeight) (setMaterial $LineMaterial) ) ) ; create front line (node Transform (setLocalPos 0 (eval -1 * $FieldHalfWidth) $LineBase) (node Box (setExtents $FieldLength $LineHeight $LineHeight) (setMaterial $LineMaterial) ) ) ; create back line (node Transform (setLocalPos 0 $FieldHalfWidth $LineBase) (node Box (setExtents $FieldLength $LineHeight $LineHeight) (setMaterial $LineMaterial) ) ) ; create left line (node Transform (setLocalPos (eval -1 * $FieldHalfLength) 0 $LineBase) (node Box (setExtents $LineHeight $LineWidth $LineHeight) (setMaterial $LineMaterial) ) ) ; create right line (node Transform (setLocalPos $FieldHalfLength 0 $LineBase) (node Box (setExtents $LineHeight $LineWidth $LineHeight) (setMaterial $LineMaterial) ) ) ; create left outer field (node Transform (setLocalPos (eval -1 * $BorderLength) 0 $FieldBase) (node Box (setMaterial $BorderMaterial) (setExtents $BorderExt $FieldWidth $FieldBaseHeight) ) ) ; create right outer field (node Transform (setLocalPos $BorderLength 0 $FieldBase) (node Box (setMaterial $BorderMaterial) (setExtents $BorderExt $FieldWidth $FieldBaseHeight) ) ) ; create front outer field (node Transform (setLocalPos 0 (eval -1 * $BorderWidth) $FieldBase) (node Box (setMaterial $BorderMaterial) (setExtents (eval $FieldLength + 2 * $BorderExt) $BorderExt $FieldBaseHeight) ) ) ; create back outer field (node Transform (setLocalPos 0 $BorderWidth $FieldBase) (node Box (setMaterial $BorderMaterial) (setExtents (eval $FieldLength + 2 * $BorderExt) $BorderExt $FieldBaseHeight) ) ) ;; ;; add flags ;; ; mark the soccer field with 4 field flags (importScene rsg/agent/flag.rsg (eval -1 * $FieldHalfLength) $FieldHalfWidth 0 Flag_1_l matRed ) (importScene rsg/agent/flag.rsg (eval -1 * $FieldHalfLength) (eval -1 * $FieldHalfWidth) 0 Flag_2_l matRed ) (importScene rsg/agent/flag.rsg $FieldHalfLength $FieldHalfWidth 0 Flag_1_r matBlue ) (importScene rsg/agent/flag.rsg $FieldHalfLength (eval -1 * $FieldHalfWidth) 0 Flag_2_r matBlue ) ; mark the left goal (importScene rsg/agent/flag.rsg (eval -1 * $FieldHalfLength) (eval -1 * $GoalHalfWidth) 0 Goal_1_l matRed ) (importScene rsg/agent/flag.rsg (eval -1 * $FieldHalfLength) $GoalHalfWidth 0 Goal_2_l matRed ) ; mark the right goal (importScene rsg/agent/flag.rsg $FieldHalfLength (eval -1 * $GoalHalfWidth) 0 Goal_1_r matBlue ) (importScene rsg/agent/flag.rsg $FieldHalfLength $GoalHalfWidth 0 Goal_2_r matBlue ) ;; ;; add the ball ;; (importScene rsg/agent/ball.rsg) ) --- NEW FILE: simspark.rsg --- ; -*- mode: lisp; -*- (RubySceneGraph 0 1) ( ; add lights (node Transform (setLocalPos -10 10 10) (node Light (setDiffuse 1.0 1.0 1.0 1.0) (setSpecular 0.1 0.1 0.1 1.0) (setAmbient 0.5 0.5 0.5 1.0) ) ) ; create the arena (node Transform (setLocalPos 0 0 -2) (importScene rsg/boxspheres/arena.rsg) ) ) --- NEW FILE: soccerplayer.rsg --- ; -*- mode: lisp; -*- (RubySceneGraph 0 1) ( ; create the torso (node AgentAspect (setName torso) (setLocalPos 0 0 0.5) (importScene rsg/boxspheres/box.rsg 1.3 1 1 5 matRed) ; install a perceptor to receive the current simulation time (node TimePerceptor) ; install a node holding agent state data (node AgentState (setName AgentState) ) ; install a perceptor to receive info about ball and player positions (node VisionPerceptor (setSenseMyPos false) (setStaticSenseAxis false) (addNoise false) ) ; install a kick effector (node KickEffector (setKickMargin 2) (setForceFactor 0.7) (setTorqueFactor 0.1) (setNoiseParams 0.4 0.02 0.9 4.5) (setSteps 10) (setMaxPower 100.0) (setAngleRange 0.0 50.0) ) ; install a beam effector (node BeamEffector) (node Transform (setLocalPos 0 0.5 0.6) (node Box (setMaterial matBlue) (setExtents 1 0.1 0.2) ) ) (node Transform (setLocalPos 0 0.1 0.6) (node Box (setMaterial matBlue) (setExtents 0.1 0.8 0.2) ) ) ) ; install the left tire (node Transform (setName leftTire) (setLocalPos -0.6 0.5 0.5) (importScene rsg/boxspheres/sphere.rsg 0.51 2 matWhite) (node Transform (setLocalRotation 0 0 180) ; install the joint (node Hinge2Joint (attach ../../sphereBody ../../../torso/boxBody) (setAnchor 0 0 0) ; enable the joint motor (setMaxMotorForce 1 4000) ; install a perceptor to measure the tire movement (node Hinge2Perceptor (setName ltp) ) ; install an effector to control the joint motor (node Hinge2Effector (setName lte) ) ) ; add some boxes to visualize the tire spin (node Box (setExtents 1.1 0.1 0.1) (setMaterial matBlue) ) (node Box (setExtents 0.1 1.1 0.1) (setMaterial matRed) ) (node Box (setExtents 0.1 0.1 1.1) (setMaterial matYellow) ) ) ) ; install the right tire (node Transform (setName rightTire) (setLocalPos 0.6 0.5 0.5) (importScene rsg/boxspheres/sphere.rsg 0.51 2 matWhite) (node Transform (setLocalRotation 0 0 180) ; install the joint (node Hinge2Joint (attach ../../sphereBody ../../../torso/boxBody) (setAnchor 0 0 0) ; enable the joint motor (setMaxMotorForce 1 4000) ; install a perceptor to measure the tire movement (node Hinge2Perceptor (setName rtp) ) ; install an effector to control the joint motor (node Hinge2Effector (setName rte) ) ) ; add some boxes to visualize the tire spin (node Box (setExtents 1.1 0.1 0.1) (setMaterial matBlue) ) (node Box (setExtents 0.1 1.1 0.1) (setMaterial matRed) ) (node Box (setExtents 0.1 0.1 1.1) (setMaterial matYellow) ) ) ) ; install passive back tire (node Transform (setName backTire) (setLocalPos 0 -0.55 0.5) (importScene rsg/boxspheres/sphere.rsg 0.51 2 matGrey) ; install the joint (node Hinge2Joint (attach ../sphereBody ../../torso/boxBody) (setAnchor 0 0 0) ) ) ) --- NEW FILE: leggedsphere.rsg --- ; -*- mode: lisp; -*- ; ; sphere with two legs (5DOF/leg) ; (RubySceneGraph 0 1) ( ; create the sphere (node Transform (setName body) (setLocalPos 0 0 3) (importScene rsg/boxspheres/sphere.rsg 1.25 0.75 matRed) ) ; attach left thigh (node Transform (setName leftthigh) (setLocalPos 1.25 0 2.25) (importScene rsg/boxspheres/box.rsg 0.5 0.5 1.0 1.0 matGrey) ; install the joint to connect to the body (node UniversalJoint (attach ../boxBody ../../body/sphereBody) (setAnchor 0 0 0) (setAxis1 1.0 0.0 0.0) ; move around the x-axis (setAxis2 0.0 1.0 0.0) ; move around the y-axis ; enable the joint motors (setMaxMotorForce 0 100) (setMaxMotorForce 1 100) ; install a perceptor (node UniversalJointPerceptor (setName lefthip) ) ; install an effector to control the joint motors (node UniversalJointEffector (setName lhe) ) ) ) ; attach left shank (node Transform (setName leftshank) (setLocalPos 1.25 0 1) (importScene rsg/boxspheres/box.rsg 0.5 0.5 1.0 1.0 matGrey) ; install the joint to connect to the body (node HingeJoint (attach ../boxBody ../../leftthigh/boxBody) (setAnchor 0 0 0) (setAxis 0) ; move around the x-axis ; enable the joint motor (setMaxMotorForce 0 100) ; install a perceptor (node HingePerceptor (setName leftknee) ) ; install an effector to control the joint motor (node HingeEffector (setName lke) ) ) ) ; attach left foot (node Transform (setName leftfoot) (setLocalPos 1.25 0 0.125) (importScene rsg/boxspheres/box.rsg 1.0 1.25 0.25 1.0 matGrey) ; install the joint to connect to the body (node UniversalJoint (attach ../boxBody ../../leftshank/boxBody) (setAnchor 0 0 0) (setAxis1 1.0 0.0 0.0) ; move around the x-axis (setAxis2 0.0 1.0 0.0) ; move around the y-axis ; enable the joint motors (setMaxMotorForce 0 100) (setMaxMotorForce 1 100) ; install a perceptor (node UniversalJointPerceptor (setName leftankle) ) ; install an effector to control the joint motors (node UniversalJointEffector (setName lae) ) ) ) ; attach right thigh (node Transform (setName rightthigh) (setLocalPos -1.25 0 2.25) (importScene rsg/boxspheres/box.rsg 0.5 0.5 1.0 1.0 matGrey) (node UniversalJoint (attach ../boxBody ../../body/sphereBody) (setAnchor 0 0 0) (setAxis1 1.0 0.0 0.0) ; move around the x-axis (setAxis2 0.0 1.0 0.0) ; move around the y-axis ; enable the joint motors (setMaxMotorForce 0 100) (setMaxMotorForce 1 100) ; install a perceptor (node UniversalJointPerceptor (setName righthip) ) ; install an effector to control the joint motors (node UniversalJointEffector (setName rhe) ) ) ) ; attach right shank (node Transform (setName rightshank) (setLocalPos -1.25 0 1) (importScene rsg/boxspheres/box.rsg 0.5 0.5 1.0 1.0 matGrey) ; install the joint to connect to the body (node HingeJoint (attach ../boxBody ../../rightthigh/boxBody) (setAnchor 0 0 0) (setAxis 0) ; move around the x-axis ; enable the joint motor (setMaxMotorForce 0 100) ; install a perceptor (node HingePerceptor (setName rightknee) ) ; install an effector to control the joint motor (node HingeEffector (setName rke) ) ) ) ; attach right foot (node Transform (setName rightfoot) (setLocalPos -1.25 0 0.125) (importScene rsg/boxspheres/box.rsg 1.0 1.25 0.25 1.0 matGrey) ; install the joint to connect to the body (node UniversalJoint (attach ../boxBody ../../rightshank/boxBody) (setAnchor 0 0 0) (setAxis1 1.0 0.0 0.0) ; move around the x-axis (setAxis2 0.0 1.0 0.0) ; move around the y-axis ; enable the joint motors (setMaxMotorForce 0 100) (setMaxMotorForce 1 100) ; install a perceptor (node UniversalJointPerceptor (setName rightankle) ) ; install an effector to control the joint motors (node UniversalJointEffector (setName rae) ) ) ) ) --- NEW FILE: buggy.rsg --- ; -*- mode: lisp; -*- ; ; this file constructs a simple buggy, the connected agent controlls ; one joint motor ; (RubySceneGraph 0 1) ( ; install a perceptor to receive the current simulation time (node TimePerceptor) ; create the char chassis (node Transform (setName chassis) (setLocalPos 0 0 0.5) (importScene rsg/boxspheres/box.rsg 1 3 0.8 10 matRed) (node Transform (setLocalPos 0 1.3 0.55) (node Box (setMaterial matBlue) (setExtents 1 0.1 0.3) ) ) ) ; install the left back tire, this tire is used to accelerate (node Transform (setName leftBack) (setLocalPos -0.5 -1.5 0) (importScene rsg/boxspheres/sphere.rsg 0.4 2 matWhite) (node Transform (setLocalRotation 0 180 0) ; install the joint (node Hinge2Joint (attach ../../sphereBody ../../../chassis/boxBody) (setAnchor 0 0 0) ; enable the joint motor (setMaxMotorForce 1 4000) ; install a perceptor to measure the tire movement (node Hinge2Perceptor (setName lb) ) ; install an effector to control the joint motor (node Hinge2Effector) ) ; add some boxes to visualize the tire spin (node Box (setExtents 1 0.1 0.1) (setMaterial matBlue) ) (node Box (setExtents 0.1 1 0.1) (setMaterial matRed) ) (node Box (setExtents 0.1 0.1 1) (setMaterial matYellow) ) ) ) ; install remaining passive wheels (node Transform (setName leftFront) (setLocalPos -0.5 +1.5 0) (importScene rsg/boxspheres/sphere.rsg 0.4 2 matWhite) (node Hinge2Joint (attach ../sphereBody ../../chassis/boxBody) (setAnchor 0 0 0) ) ) (node Transform (setName rightBack) (setLocalPos 0.5 -1.5 0) (importScene rsg/boxspheres/sphere.rsg 0.4 2 matWhite) (node Transform (setLocalRotation 0 180 0) (node Hinge2Joint (attach ../../sphereBody ../../../chassis/boxBody) (setAnchor 0 0 0) ) ) ) (node Transform (setName rightFront) (setLocalPos 0.5 +1.5 0) (importScene rsg/boxspheres/sphere.rsg 0.4 2 matWhite) (node Hinge2Joint (attach ../sphereBody ../../chassis/boxBody) (setAnchor 0 0 0) ) ) ) --- NEW FILE: flag.rsg --- ; -*- mode: lisp; -*- ; ; create a field flag at ($PosX $PosY $PosZ) named $Name with the ; given $Material ; (RubySceneGraph 0 1) ( (template $PosX $PosY $PosZ $Name $Material) (node Transform (setLocalPos $PosX $PosY $PosZ) (importScene rsg/boxspheres/staticsphere.rsg 1 $Material) (node ObjectState (setPerceptName $Name) ) ) ) |