Package org.ptolemy.ssm
Class Map
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,FiringsRecordable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Decorator
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class Map extends TypedAtomicActor implements Decorator
An occupancy grid map. The map input, which can come from an image file read by PGMReader, is a record with width, height, and grid fields. The width and height are positive integers, and the grid is an array of integer values for each position in the map. This actor decorates any entity in the model that implements the MapConstrained interface.- Since:
- Ptolemy II 11.0
- Version:
- $Id$
- Author:
- Ilge Akkaya
- See Also:
MapConstrained
,PGMReader
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Red (cxh)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<NamedObj>
_decoratedObjects
Cached list of decorated objects.protected long
_decoratedObjectsVersion
Version for _decoratedObjects.PortParameter
map
The occupancy grid map.Parameter
origin
A 2-d array denoting the map origin in x and y directions respectively.Parameter
resolution
Map resolution in meters/pixel.-
Fields inherited from class ptolemy.actor.TypedAtomicActor
_typesValid
-
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _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
Constructors Constructor Description Map(CompositeEntity container, java.lang.String name)
Construct a StateSpaceModel with a name and a container.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
attributeChanged(Attribute attribute)
Update the state accordingly.java.lang.Object
clone(Workspace workspace)
Clone the actor into the specified workspace.DecoratorAttributes
createDecoratorAttributes(NamedObj target)
Create and return the decorated attributes for the target NamedObj.java.util.List<NamedObj>
decoratedObjects()
Return the decorated objects.java.lang.String
description()
Return a full description of the object.void
fire()
Do nothing.int[][]
getOccupancyGrid()
Return the occupancy grid.double[]
getOrigin()
Return the origin.boolean
isGlobalDecorator()
Return true if this decorator should decorate objects across opaque hierarchy boundaries.boolean
withinValidMapArea(double xCoord, double yCoord)
Check if queried (x,y) position is within the valid map area.-
Methods inherited from class ptolemy.actor.TypedAtomicActor
_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
-
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, initialize, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate, wrapup
-
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
_addPort, _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 ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, decorators, deepContains, depthInHierarchy, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
-
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.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, initialize, preinitialize, removeInitializable, wrapup
-
Methods inherited from interface ptolemy.kernel.util.Nameable
getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
map
public PortParameter map
The occupancy grid map.
-
origin
public Parameter origin
A 2-d array denoting the map origin in x and y directions respectively.
-
resolution
public Parameter resolution
Map resolution in meters/pixel.
-
_decoratedObjects
protected java.util.List<NamedObj> _decoratedObjects
Cached list of decorated objects.
-
_decoratedObjectsVersion
protected long _decoratedObjectsVersion
Version for _decoratedObjects.
-
-
Constructor Detail
-
Map
public Map(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Construct a StateSpaceModel with a name and a container. The container argument must not be null, or a NullPointerException will be thrown. This actor will use the workspace of the container for synchronization and version counts. If the name argument is null, then the name is set to the empty string. Increment the version of the workspace.- Parameters:
container
- The container.name
- The name of this actor.- Throws:
IllegalActionException
- If the container is incompatible with this actor.NameDuplicationException
- If the name coincides with an actor already in the container.
-
-
Method Detail
-
attributeChanged
public void attributeChanged(Attribute attribute) throws IllegalActionException
Update the state accordingly.- Overrides:
attributeChanged
in classNamedObj
- Parameters:
attribute
- The attribute that changed.- Throws:
IllegalActionException
- If stateVariableNamest cannot be evaluated or cannot be converted to the output type, or if the superclass throws it.
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone the actor into the specified workspace.- Overrides:
clone
in classTypedAtomicActor
- Parameters:
workspace
- The workspace for the new object.- Returns:
- A new actor.
- Throws:
java.lang.CloneNotSupportedException
- If a derived class contains an attribute that cannot be cloned.- See Also:
NamedObj.exportMoML(Writer, int, String)
,NamedObj.setDeferringChangeRequests(boolean)
-
fire
public void fire() throws IllegalActionException
Description copied from class:AtomicActor
Do nothing. Derived classes override this method to define their primary run-time action.- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- Not thrown in this base class.
-
getOccupancyGrid
public int[][] getOccupancyGrid()
Return the occupancy grid.- Returns:
- the occupancy grid
-
getOrigin
public double[] getOrigin()
Return the origin.- Returns:
- the origin.
-
withinValidMapArea
public boolean withinValidMapArea(double xCoord, double yCoord)
Check if queried (x,y) position is within the valid map area.- Parameters:
xCoord
- The x coordinateyCoord
- The y coordinate- Returns:
- True if the position is within the valid map area.
-
description
public java.lang.String description() throws IllegalActionException
Description copied from class:NamedObj
Return a full description of the object. This is accomplished by calling the description method with an argument for full detail. This method read-synchronizes on the workspace.- Specified by:
description
in interfaceNameable
- Overrides:
description
in classNamedObj
- Returns:
- A description of the object.
- Throws:
IllegalActionException
- Not thrown in this base class, but derived classes could throw an exception if there is a problem accessing subcomponents of this object.- See Also:
NamedObj.exportMoML(Writer, int, String)
-
createDecoratorAttributes
public DecoratorAttributes createDecoratorAttributes(NamedObj target) throws IllegalActionException
Description copied from interface:Decorator
Create and return the decorated attributes for the target NamedObj. Implementations of this method should create an Attribute that implementsDecoratorAttributes
. Implementations should populate that attribute with parameters that have appropriate default values.This method is called if
NamedObj.getDecoratorAttribute(Decorator, String)
orNamedObj.getDecoratorAttributes(Decorator)
is called, and the specified target object does not already have decorated attributes for this decorator.The implementer of this method is responsible for ensuring consistency with the
Decorator.decoratedObjects()
method. Specifically, any object returned byDecorator.decoratedObjects()
, when passed as an argument to this method, should not result in a null returned value. And conversely, any object passed to this method that is not in the list returned by decoratedObjects() should result in a null returned value.- Specified by:
createDecoratorAttributes
in interfaceDecorator
- Parameters:
target
- The NamedObj that will be decorated.- Returns:
- The decorated attributes for the target NamedObj, or null if the specified NamedObj is not decorated by this decorator.
- Throws:
IllegalActionException
- If the target cannot be determined to be decorated or not (e.g., a parameter cannot be evaluated).
-
decoratedObjects
public java.util.List<NamedObj> decoratedObjects() throws IllegalActionException
Return the decorated objects.- Specified by:
decoratedObjects
in interfaceDecorator
- Returns:
- the decorated objects.
- Throws:
IllegalActionException
- If some object cannot be determined to be decorated or not (e.g., a parameter cannot be evaluated).
-
isGlobalDecorator
public boolean isGlobalDecorator() throws IllegalActionException
Description copied from interface:Decorator
Return true if this decorator should decorate objects across opaque hierarchy boundaries. That is, return true to make this decorator visible to objects even within opaque composites.- Specified by:
isGlobalDecorator
in interfaceDecorator
- Returns:
- True if decorator is global.
- Throws:
IllegalActionException
- If it cannot be determined whether this is global or not (e.g., a parameter cannot be evaluated).
-
-