|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.kernel.util.NamedObj
ptolemy.kernel.InstantiableNamedObj
ptolemy.kernel.Entity
ptolemy.kernel.ComponentEntity
ptolemy.actor.AtomicActor
ptolemy.actor.TypedAtomicActor
ptolemy.domains.wireless.lib.Triangulator
public class Triangulator
Given inputs that represent the location of a sensor and the time at which those sensors detect an event, this actor outputs the location of the source of the event. It uses the specified signalPropagationSpeed and triangulates.
The input is a record with two fields named "location" and "time". The location field is an array of doubles, and the time is a double. In the current implementation, the actor assumes a two-dimensional space, so the location field is assumed to be an array with two doubles, which represent the horizontal (east-west) and vertical (north-south) location of the sensor. The time field is assumed to be a double representing the time at which the event was detected by the sensor.
The triangulation algorithm requires three distinct sensor inputs
for the same event in order to be able to calculate the location
of the origin of the event. Suppose that the event occurred at
time t and location x. Suppose that three sensors
at locations y1, y2, and y3 have each detected
events at times t1, t2, and t3, respectively.
Then this actor looks for a solution for x and t
in the following equations:
distance(x, y1)/v = t1 - t,
where v is the value of propagationSpeed.
If such a solution is found, then the output x is produced.
distance(x, y2)/v = t2 - t,
distance(x, y3)/v = t3 - t,
Since three distinct observations are required, this actor will produce no output until it has received three distinct observations. The observations are distinct if the sensor locations are distinct. If the three observations yield no solution, then this actor will produce no output. However, it is possible for the three observations to come from distinct events, in which case the output may be erroneous. To guard against this, this actor provides a timeWindow parameter. The times of the three observations must be within the value of timeWindow, or no output will be produced. The output is an array of doubles, which in this implementation represent the X and Y locations of the event.
Red (ptolemy) |
Yellow (eal) |
Nested Class Summary |
---|
Nested classes/interfaces inherited from class ptolemy.kernel.Entity |
---|
Entity.ContainedObjectsIterator |
Field Summary | |
---|---|
private static double |
_EPSILON
|
private double[] |
_locationsX
|
private double[] |
_locationsY
|
private double[] |
_times
|
TypedIOPort |
input
The input port for an event detection, which is a record containing the location of a sensor that has detected the event and the time at which the sensor detected the event. |
TypedIOPort |
output
The output producing the calculated event location. |
Parameter |
signalPropagationSpeed
Speed of propagation of the signal to be used for triangulation. |
Parameter |
timeWindow
Time window within which observations are assumed to come from the same sound event. |
Fields inherited from class ptolemy.actor.AtomicActor |
---|
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested |
Fields inherited from class ptolemy.kernel.util.NamedObj |
---|
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
Fields inherited from interface ptolemy.actor.Executable |
---|
COMPLETED, NOT_READY, STOP_ITERATING |
Constructor Summary | |
---|---|
Triangulator(CompositeEntity container,
java.lang.String name)
Construct an actor with the given container and name. |
Method Summary | |
---|---|
private double |
_checkResult(double[] result,
double x1,
double y1,
double t1,
double x2,
double y2,
double t2,
double x3,
double y3,
double t3,
double v)
Check whether the calculated location and time of a sound event is consistent with the observations. |
private static double |
_distance(double x1,
double y1,
double x2,
double y2)
Return the Cartesian distance between (x1, y1) and (x2, y2). |
private double[] |
_locate(double x1,
double y1,
double t1,
double x2,
double y2,
double t2,
double x3,
double y3,
double t3,
double v)
Calculate the location and time of a sound event from the given observations of the event. |
java.lang.Object |
clone(Workspace workspace)
Clone this actor into the specified workspace. |
void |
fire()
Read all available input tokens and attempt to use them to triangulate the signal source. |
void |
initialize()
Override the base class to initialize the signal count. |
Methods inherited from class ptolemy.actor.TypedAtomicActor |
---|
_addPort, _fireAt, _fireAt, attributeTypeChanged, clone, newPort, typeConstraintList, typeConstraints |
Methods inherited from class ptolemy.kernel.ComponentEntity |
---|
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName |
Methods inherited from class ptolemy.kernel.Entity |
---|
_description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName |
Methods inherited from class ptolemy.kernel.InstantiableNamedObj |
---|
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface ptolemy.actor.Actor |
---|
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList |
Methods inherited from interface ptolemy.actor.Executable |
---|
isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate |
Methods inherited from interface ptolemy.actor.Initializable |
---|
addInitializable, preinitialize, removeInitializable, wrapup |
Methods inherited from interface ptolemy.kernel.util.Nameable |
---|
description, getContainer, getDisplayName, getFullName, getName, getName, setName |
Methods inherited from interface ptolemy.kernel.util.Derivable |
---|
getDerivedLevel, getDerivedList, propagateValue |
Field Detail |
---|
public TypedIOPort input
public TypedIOPort output
public Parameter signalPropagationSpeed
public Parameter timeWindow
private double[] _locationsX
private double[] _locationsY
private double[] _times
private static final double _EPSILON
Constructor Detail |
---|
public Triangulator(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
container
- The container.name
- The name of this actor.
IllegalActionException
- If the actor cannot be contained
by the proposed container.
NameDuplicationException
- If the container already has an
actor with this name.Method Detail |
---|
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class AtomicActor
workspace
- The workspace for the cloned object.
java.lang.CloneNotSupportedException
- If cloned ports cannot have
as their container the cloned entity (this should not occur), or
if one of the attributes cannot be cloned.NamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public void fire() throws IllegalActionException
fire
in interface Executable
fire
in class AtomicActor
IllegalActionException
- If there is no director,
or if the parameters cannot be evaluated.public void initialize() throws IllegalActionException
initialize
in interface Initializable
initialize
in class AtomicActor
IllegalActionException
- If the base class throws it.private double _checkResult(double[] result, double x1, double y1, double t1, double x2, double y2, double t2, double x3, double y3, double t3, double v)
result
- The calculated location and time of a sound event.x1
- The x-coordinate of the first observation.y1
- The y-coordinate of the first observation.t1
- The time of the first observation.x2
- The x-coordinate of the second observation.y2
- The y-coordinate of the second observation.t2
- The time of the second observation.x3
- The x-coordinate of the third observation.y3
- The y-coordinate of the third observation.t3
- The time of the third observation.v
- The speed of sound propagation.
private static double _distance(double x1, double y1, double x2, double y2)
x1
- The first x coordinate.y1
- The first y coordinate.x2
- The second x coordinate.y2
- The second y coordinate.
private double[] _locate(double x1, double y1, double t1, double x2, double y2, double t2, double x3, double y3, double t3, double v)
distance(x, y, x1, y1)/v = t1 - t distance(x, y, x2, y2)/v = t2 - t distance(x, y, x3, y3)/v = t3 - tIf there is no valid solution to these equations, possible when the observations are of different sound events, the returned values are all negative infinity (Double.NEGATIVE_INFINITY). It is also possible that a valid solution to the equations exists even though the observations are of different sound events. This algorithm does not rule out such false positives.
x1
- The x-coordinate of the first observation.y1
- The y-coordinate of the first observation.t1
- The time of the first observation.x2
- The x-coordinate of the second observation.y2
- The y-coordinate of the second observation.t2
- The time of the second observation.x3
- The x-coordinate of the third observation.y3
- The y-coordinate of the third observation.t3
- The time of the third observation.v
- The speed of sound propagation.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |