Ants and Identifications
py_fort_myrmidon.Ant
- class py_fort_myrmidon.Ant
Ant are the main object of interest of an
Experiment
. They are identified from tags withIdentification
, have a virtual shape to perform collision and interaction detection, and holds user defined metadata.Ant can only be created from an
Experiment
withExperiment.CreateAnt()
.Ant are uniquely identified by an
ID
. By convention we use decimal notation with up to two0
prefix to display these AntID, as returned byFormatAntID()
.Instead of working directly with TagID fort-myrmidon uses
Identification
to relate a tag value to an Ant. An Ant could have different Identifications, allowing us to use different tag ID to refer to the same individual. One would useIdentifiedAt()
to obtain the tag ID that identifies an Ant at a givenTime
.Each Ant has an associated virtual shape that is used to compute instantaneous collision detection (
Query.CollideFrame()
), or timed ant interactions (Query.ComputeAntInteraction()
). These shapes can be defined manually in fort-studio or programmatically accessed and modified withCapsules
,AddCaspule()
,DeleteCapsule()
andClearCapsules()
.Basic visualization of Experiment data can be done through fort-studio. Ants are displayed according to their
DisplayStatus
andDisplayColor
.Ant can stores timed user defined metadata. These are modifiable using
SetValue()
andDeleteValue()
and accesible throughGetValue()
.- AddCapsule(self: py_fort_myrmidon.Ant, shapeTypeID: int, capsule: py_fort_myrmidon.Capsule) None
Adds a Capsule to the Ant virtual shape.
- Parameters:
- Raises:
ValueError – if shapeTypeID is not defined in the
Experiment
- ClearCapsules(self: py_fort_myrmidon.Ant) None
Removes all capsules for this Ant.
- DeleteCapsule(self: py_fort_myrmidon.Ant, index: int) None
Removes one of the shape
- Parameters:
- Raises:
IndexError – if
index >= len(self.Capsules())
- DeleteValue(self: py_fort_myrmidon.Ant, key: str, time: py_fort_myrmidon.Time) None
Clears a user defined timed metadata.
- Parameters:
- Raises:
IndexError – if key was not previously set for time with
SetValue()
.
- class DisplayState
Enumerates the possible display state for an Ant
Members:
VISIBLE : the Ant is visible
HIDDEN : the Ant is hidden
SOLO : the Ant is visible and all other non-solo ant are hidden
- property name
- property DisplayStatus
the DisplayState in fort-studio for this Ant
- Type:
- GetValue(self: py_fort_myrmidon.Ant, key: str, time: py_fort_myrmidon.Time) bool | int | float | str | py_fort_myrmidon.Time
Gets user defined timed metadata.
- Parameters:
- Returns:
the value for key at time, if defined, or the Experiment’s default value.
- Return type:
- Raises:
IndexError – if key is not defined in
Experiment
- GetValues(self: py_fort_myrmidon.Ant, key: str) List[Tuple[py_fort_myrmidon.Time, bool | int | float | str | py_fort_myrmidon.Time]]
Gets metadata key changes over time.
- Parameters:
key (str) – the key to list changes
- Raises:
IndexError – if key is not defined in
Experiment
- property Identifications
all Identification that target this Ant, ordered by validity time.
- Type:
List[Identification]
- IdentifiedAt(self: py_fort_myrmidon.Ant, time: py_fort_myrmidon.Time) int
Gets the TagID identifiying this Ant at a given time
- SetValue(self: py_fort_myrmidon.Ant, key: str, value: bool | int | float | str | py_fort_myrmidon.Time, time: py_fort_myrmidon.Time) None
Sets a user defined timed metadata
- Parameters:
- Raises:
IndexError – if key is not defined in the
Experiment
ValueError – if time is
Time.Forever()
RuntimeError – if value is not of the right type for key
py_fort_myrmidon.Identification
- class py_fort_myrmidon.Identification
Identifications relates tag to
Ant
withTime
and geometric data.Identification can only be created from an
Experiment
withExperiment.AddIdentification()
.Identifications are bounded in
Time
in the range [Start
,End
[. These attributes can respectively be set toTime.SinceEver()
andTime.Forever()
. Internally fort-myrmidon ensure the validity of all Identifications. It means that:Two Identifications using the same TagValue cannot overlap in Time.
Two Identifications using targeting the same
Ant
cannot overlap in Time.
If any modification through
Experiment.AddIdentification()
,Start
orEnd
would violate one of these conditions, anOverlappingIdentification
exception will be raised.Identifications also contains geometric informations on how the detected tag is related to the observed
Ant
. These are the translation and rotation of the Ant, expressed in the tag coordinate reference. Usually, this information is automatically generated from the manual measurement of typeExperiment.HEAD_TAIL_MEASUREMENT_TYPE
made in fort-studio. Alternatively, users can override this behavior by setting themselves this pose usingSetUserDefinedAntPose()
.ClearUserDefinedAntPose()
can be used to revert to the internally computed pose.Note
Any angle is measured in radians, with a standard mathematical convention. Since in image processing the y-axis is pointing from the top of the image to the bottom, positive angles appears clockwise.
Identifications also contains the information of the physical tag size used to identify the individual. It can be accessed and set with
TagSize
. The valueDEFAULT_TAG_SIZE
(i.e.0.0
) indicates that theExperiment.DefaultTagSize
should be used. Therefore, for most Ant, this field should be kept toDEFAULT_TAG_SIZE
, excepted for a few individuals, for examples, Queens.- DEFAULT_TAG_SIZE
a value of
0.0
that indicates that theExperiment.DefaultTagSize
should be used.- Type:
- property AntAngle
orientation difference between the ant orientation and its physical tag, expressed in radians.
- Type:
- property AntPosition
Ant center position relative to the tag center. (float64, size[2,1])
- Type:
- ClearUserDefinedAntPose(self: py_fort_myrmidon.Identification) None
Removes any user-defined ant-tag relative geometry data and re-enable the one computed from manual measurement made in fort-studio.
- property End
the first invalid Time fort this identification, it can be
Time.Forever()
- Type:
- HasDefaultTagSize(self: py_fort_myrmidon.Identification) bool
Indicates if the
Experiment.DefaultTagSize
is used- Returns:
True
if this Identification usesExperiment.DefaultTagSize
, i.e. whenTagSize
==DEFAULT_TAG_SIZE
- Return type:
- HasUserDefinedAntPose(self: py_fort_myrmidon.Identification) bool
Indicates if the user overrided the computed pose.
- Returns:
True
if the ant position relatively to the tag has been set by the user.- Return type:
- SetUserDefinedAntPose(self: py_fort_myrmidon.Identification, antPosition: numpy.ndarray[numpy.float64[2, 1]], antAngle: float) None
Sets an user defined ant position relatively to the tag, overiding the one computed from manual measurements.
To revert to the automatically computed ones, use
ClearUserDefinedAntPose()
- Parameters:
antPosition (numpy.ndarray[numpy.float64[2,1]]) – the position of the ant relatively to the tag center, in the tag reference frame
antAngle (float) – the ant angle relatively to the tag angle, in radians
- property Start
the first valid Time fort this identification, it can be
Time.SinceEver()
- Type:
- property TagSize
the Identification tag size in millimeters, could be
DEFAULT_TAG_SIZE
to useExperiment.DefaultTagSize
- Type: