|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsimbad.sim.BaseObject
simbad.sim.SimpleAgent
public class SimpleAgent
This is the base class for all kinds of physical agents.
Implementation note : the agent doesnt have synchronized methods.
All thread refering to the agent should do explicit synchronization with synchronized(agent){...}..
Field Summary | |
---|---|
private java.util.ArrayList |
actuators
The agent's actuators |
protected javax.vecmath.Vector3d |
angularAcceleration
Current angular acceleration about the center of mass. |
protected javax.vecmath.Vector3d |
angularVelocity
Current angular velocity about the center of mass. |
protected javax.media.j3d.Node |
body
|
private javax.media.j3d.BoundingSphere |
collisionBounds
|
private javax.vecmath.Point3d |
collisionBoundsCenter
|
(package private) boolean |
collisionDetected
Collision flag |
protected double[] |
collisionDistance
Used for collision picking |
private javax.media.j3d.PickBounds |
collisionPickBounds
Bounds for collision detection |
protected double |
collisionRadius
|
private int |
counter
Counter incremented on each simulation step |
protected float |
dynamicFrictionCoefficient
|
protected float |
height
Agent's Height in meters |
protected javax.vecmath.Vector3d |
instantRotation
Current rotation step. |
protected javax.vecmath.Vector3d |
instantTranslation
Current translation step. |
private java.util.ArrayList |
interactingAgents
List of currently interacting agent |
(package private) boolean |
interactionDetected
Interagent interaction indicator |
private double |
lifetime
Lifetime in seconds since last reset |
protected javax.vecmath.Vector3d |
linearAcceleration
Current linear acceleration of the center of mass. |
protected javax.vecmath.Vector3d |
linearVelocity
Current linear velocity of the center of mass. |
protected float |
mass
Agent's mass in kilogram |
protected java.lang.String |
name
Agent's printable name |
protected double |
odometer
|
protected boolean |
positionChanged
Position has changed between two steps. |
protected float |
radius
Agent's radius in meters |
private java.util.ArrayList |
sensors
The agent's sensors |
private Simulator |
simulator
Parent simulator. |
private javax.vecmath.Vector3d |
startPosition
Start and restart position of the agent |
protected float |
staticFrictionCoefficient
Agent's static friction coefficient - 0 = no friction |
protected javax.media.j3d.Transform3D |
t3d1
|
protected javax.media.j3d.Transform3D |
t3d2
|
protected javax.media.j3d.Transform3D |
t3d3
|
protected javax.vecmath.Vector3d |
v1
for intermediate computations and to minimize Gargabe collection |
private javax.vecmath.Vector3d |
v2
|
(package private) SimpleAgent |
veryNearAgent
Keeps track of agent in physical contact with this agent. |
Fields inherited from class simbad.sim.BaseObject |
---|
black, branchGroup, canBeTraversed, compilable, detachedFromSceneGraph, group, localBounds, material, rotation, rotationGroup, translation, translationGroup, white, world |
Constructor Summary | |
---|---|
SimpleAgent(javax.vecmath.Vector3d pos,
java.lang.String name)
Constructs a SimpleAgent. |
Method Summary | |
---|---|
protected int |
addActuatorDevice(ActuatorDevice ad,
javax.vecmath.Vector3d position,
double angle)
Adds a actuator device to the agent. |
protected int |
addSensorDevice(SensorDevice sd,
javax.vecmath.Vector3d position,
double angle)
Adds a sensor device to the agent. |
boolean |
anOtherAgentIsVeryNear()
Returns true if this agent is in physical contact with an other SimpleAgent. |
java.lang.String |
asString()
Returns printable description of the agent. |
protected void |
checkCollision(javax.media.j3d.BranchGroup pickableSceneBranch,
boolean checkGeometry)
Checks for 3D geometrical collisions Note : this is used in case PhysicalEngine is disabled. |
protected void |
clearVeryNear()
called back by simulator to clear physical interaction other agent. |
boolean |
collisionDetected()
Returns the state of the geometric collision indicator. |
protected void |
create()
Creation phase - called once by the simulator. |
protected void |
create3D()
|
protected void |
dispose()
Dispose all resources |
protected double |
distanceToGround()
returns the distance from agent base to ground . |
ActuatorDevice |
getActuatorDevice(int num)
Returns the actuator device designated by num. |
java.util.ArrayList |
getActuatorList()
|
void |
getCoords(javax.vecmath.Point3d coord)
Return agents coordinates. |
void |
getCoords(javax.vecmath.Vector3d coord)
Return agents coordinates. |
int |
getCounter()
Returns the agent counter. |
float |
getHeight()
Returns the agent's height in meters. |
double |
getLifeTime()
Returns the agent total lifetime since last reset (in seconds). |
float |
getMass()
Gets the agent's mass. |
java.lang.String |
getName()
Returns the agent's name. |
float |
getRadius()
Returns the agent's radius in meters. |
SensorDevice |
getSensorDevice(int num)
Returns the sensor device designated by num. |
java.util.ArrayList |
getSensorList()
|
SimpleAgent |
getVeryNearAgent()
Returns the currently touched agent - null if no agent near. |
protected void |
initBehavior()
called by simulator init |
protected void |
initPreBehavior()
called by simulator init |
protected void |
integratesPositionChange(double dt)
Perform velocities integration step .¬ |
protected void |
integratesVelocities(double dt)
Perform acceleration integration step . |
boolean |
interactionDetected()
Returns true if an interaction has been detected. |
void |
moveToPosition(double x,
double z)
Go to given XZ position. |
void |
moveToPosition(javax.vecmath.Vector3d position)
Go to given position. |
void |
moveToStartPosition()
Go to the start position of the agent. |
protected void |
performBehavior()
called by simulator loop |
protected void |
performPreBehavior()
called by simulator loop |
protected void |
reset()
Resets agent variables and position |
protected void |
resetDevices()
Resets all devices |
protected void |
resetPosition()
|
protected void |
resetPositionAt(javax.vecmath.Vector3d newPosition)
|
protected void |
setMotorsAcceleration(double dt)
set acceleration applied by motors . |
protected void |
setSimulator(Simulator simulator)
Sets the simulator in charge of this agent. |
protected void |
updateActuators(double elapsedSecond)
Update actuators phase - called on each simulation step. |
protected void |
updateCounters(double elapsedSecond)
Update all counters on each step. |
protected void |
updatePosition()
Update the agent's position with instantTranslation and instantRotation |
protected void |
updateSensors(double elapsedSecond,
javax.media.j3d.BranchGroup pickableSceneBranch)
Update sensor phase - called on each simulation step. |
protected void |
veryNear(SimpleAgent a)
called back by simulator when a physical interaction as occurred with an other agent. |
Methods inherited from class simbad.sim.BaseObject |
---|
addChild, addChild, attach, compile, create3D, detach, getBounds, getCanBeTraversed, getGroup, getNode, getRotationTransform, getRotationTransformGroup, getTranslation, getTranslationTransform, getTranslationTransform, resetTransforms, rotateY, setBounds, setCanBeTraversed, setColor, setWorld, translateTo |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.String name
boolean collisionDetected
boolean interactionDetected
SimpleAgent veryNearAgent
private Simulator simulator
private java.util.ArrayList sensors
private java.util.ArrayList actuators
private javax.media.j3d.PickBounds collisionPickBounds
private javax.media.j3d.BoundingSphere collisionBounds
private javax.vecmath.Point3d collisionBoundsCenter
protected javax.vecmath.Vector3d v1
private javax.vecmath.Vector3d v2
protected javax.media.j3d.Transform3D t3d1
protected javax.media.j3d.Transform3D t3d2
protected javax.media.j3d.Transform3D t3d3
private java.util.ArrayList interactingAgents
private javax.vecmath.Vector3d startPosition
private int counter
private double lifetime
protected double odometer
protected boolean positionChanged
protected javax.media.j3d.Node body
protected float height
protected float radius
protected float mass
protected float staticFrictionCoefficient
protected float dynamicFrictionCoefficient
protected javax.vecmath.Vector3d linearAcceleration
protected javax.vecmath.Vector3d angularAcceleration
protected javax.vecmath.Vector3d linearVelocity
protected javax.vecmath.Vector3d angularVelocity
protected javax.vecmath.Vector3d instantTranslation
protected javax.vecmath.Vector3d instantRotation
protected double[] collisionDistance
protected double collisionRadius
Constructor Detail |
---|
public SimpleAgent(javax.vecmath.Vector3d pos, java.lang.String name)
pos
- the starting position.name
- the name of the agent.Method Detail |
---|
protected void create3D()
protected void create()
protected void reset()
protected void resetPosition()
protected void resetPositionAt(javax.vecmath.Vector3d newPosition)
protected void resetDevices()
protected void updateSensors(double elapsedSecond, javax.media.j3d.BranchGroup pickableSceneBranch)
protected void updateActuators(double elapsedSecond)
protected void setMotorsAcceleration(double dt)
protected void integratesVelocities(double dt)
protected void integratesPositionChange(double dt)
protected double distanceToGround()
protected void updatePosition()
protected void checkCollision(javax.media.j3d.BranchGroup pickableSceneBranch, boolean checkGeometry)
pickableSceneBranch
- The scene branch containing all collidable objects.protected void updateCounters(double elapsedSecond)
protected void initPreBehavior()
protected void initBehavior()
protected void performPreBehavior()
protected void performBehavior()
public boolean collisionDetected()
public boolean interactionDetected()
public void moveToStartPosition()
public void moveToPosition(javax.vecmath.Vector3d position)
position
- - the new position.public void moveToPosition(double x, double z)
position
- - the new position.protected int addSensorDevice(SensorDevice sd, javax.vecmath.Vector3d position, double angle)
num
- - the requested position in the sensor list.sd
- - the device.position
- - its position relative to agent's center.angle
- - its angle in the XZ plane.
protected int addActuatorDevice(ActuatorDevice ad, javax.vecmath.Vector3d position, double angle)
num
- - the requested position in the sensor list.sd
- - the device.position
- - its position relative to agent's center.angle
- - its angle in the XZ plane.
protected void dispose()
public java.lang.String asString()
protected void setSimulator(Simulator simulator)
public java.util.ArrayList getSensorList()
public java.util.ArrayList getActuatorList()
public double getLifeTime()
public void getCoords(javax.vecmath.Point3d coord)
public void getCoords(javax.vecmath.Vector3d coord)
public int getCounter()
public java.lang.String getName()
public float getMass()
public float getRadius()
public float getHeight()
public SensorDevice getSensorDevice(int num)
public ActuatorDevice getActuatorDevice(int num)
protected void clearVeryNear()
protected void veryNear(SimpleAgent a)
public boolean anOtherAgentIsVeryNear()
public SimpleAgent getVeryNearAgent()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |