Platforms

class stonesoup.platform.base.Platform(movement_controller: Movable = None, sensors: MutableSequence[Sensor] = None, id: str = None, shape: Shape = None)[source]

Bases: Base

A platform that can carry a number of different sensors.

The location of platform mounted sensors will be maintained relative to the sensor position. Platforms move within a 2 or 3 dimensional rectangular cartesian space.

A simple platform is considered to always be aligned with its principle velocity. It does not take into account issues such as bank angle or body deformation (e.g. flex).

Movement is controlled by the Platform’s Platform.movement_controller, and access to attributes of the Platform is proxied to the movement controller, to allow the Platform to report its own position, orientation etc.

If a movement_controller argument is not supplied to the constructor, the Platform will try to construct one using unused arguments passed to the Platform’s constructor.

It is also possible to specify the Shape of a platform, in the event of it representing a vehicle with known geometry, by providing the optional property.

Note

This class is abstract and not intended to be instantiated. To get the behaviour of this class use a subclass which gives movement behaviours. Currently, these are FixedPlatform and MovingPlatform

Parameters:
  • movement_controller (Movable, optional) – Movable object to control the Platform’s movement. Default is None, but it can be constructed transparently by passing Movable’s constructor parameters to the Platform constructor.

  • sensors (collections.abc.MutableSequence, optional) – A list of N mounted sensors. Defaults to an empty list.

  • id (str, optional) – The unique platform ID. Default None where random UUID is generated.

  • shape (Shape, optional) – Optional Shape object defining the Platform shape.

id: str

The unique platform ID. Default None where random UUID is generated.

shape: Shape

Optional Shape object defining the Platform shape.

movement_controller: Movable

Movable object to control the Platform’s movement. Default is None, but it can be constructed transparently by passing Movable’s constructor parameters to the Platform constructor.

sensors: MutableSequence[Sensor]

A list of N mounted sensors. Defaults to an empty list.

add_sensor(sensor: Sensor) None[source]

Add a sensor to the platform.

Parameters:

sensor (BaseSensor) – The sensor object to add.

remove_sensor(sensor: Sensor) None[source]

Remove a sensor from the platform.

Parameters:

sensor (BaseSensor) – The sensor object to remove.

pop_sensor(index: int = -1)[source]

Remove and return a sensor from the platform by index. If no index is specified, remove and return the last sensor in self.sensors.

Parameters:

index (int) – The index of the sensor to remove. Defaults to the last item in the list.

property ground_truth_path: GroundTruthPath

Produce a GroundTruthPath with the same id and states as the platform.

The states property for the platform and ground_truth_path are dynamically linked: self.ground_truth_path.states is self.states

So after platform.move() the ground_truth_path will contain the new state. However, replacing the id, states or movement_controller variables in either the platform or ground truth path will not be reflected in the other object. platform_gtp = self.ground_truth_path platform_gtp.states = [] self.states is not platform_gtp.states

Platform.ground_truth_path produces a new GroundTruthPath on every instance. It is not an object that is updated self.ground_truth_path.states is not self.ground_truth_path.states

property vertices

Vertices are calculated by applying position and orientation to shape. If position or orientation changes, then vertices will reflect these changes. If shape specifies vertices that connect to more than two other vertices, then the vertex with more connections will be duplicated. This enables correct handling of complex non-convex shapes.

property relative_edges

Calculates the difference between connected vertices Cartesian coordinates. This is used by is_visible() of VisibilityInformed2DSensor when calculating the visibility of a state due to obstacles obstructing the line of sight to the target.

class stonesoup.platform.base.FixedPlatform(movement_controller: Movable = None, sensors: MutableSequence[Sensor] = None, id: str = None, shape: Shape = None)[source]

Bases: Platform

Parameters:
  • movement_controller (Movable, optional) – Movable object to control the Platform’s movement. Default is None, but it can be constructed transparently by passing Movable’s constructor parameters to the Platform constructor.

  • sensors (collections.abc.MutableSequence, optional) – A list of N mounted sensors. Defaults to an empty list.

  • id (str, optional) – The unique platform ID. Default None where random UUID is generated.

  • shape (Shape, optional) – Optional Shape object defining the Platform shape.

class stonesoup.platform.base.MovingPlatform(movement_controller: Movable = None, sensors: MutableSequence[Sensor] = None, id: str = None, shape: Shape = None)[source]

Bases: Platform

Parameters:
  • movement_controller (Movable, optional) – Movable object to control the Platform’s movement. Default is None, but it can be constructed transparently by passing Movable’s constructor parameters to the Platform constructor.

  • sensors (collections.abc.MutableSequence, optional) – A list of N mounted sensors. Defaults to an empty list.

  • id (str, optional) – The unique platform ID. Default None where random UUID is generated.

  • shape (Shape, optional) – Optional Shape object defining the Platform shape.

class stonesoup.platform.base.MultiTransitionMovingPlatform(movement_controller: Movable = None, sensors: MutableSequence[Sensor] = None, id: str = None, shape: Shape = None)[source]

Bases: Platform

Parameters:
  • movement_controller (Movable, optional) – Movable object to control the Platform’s movement. Default is None, but it can be constructed transparently by passing Movable’s constructor parameters to the Platform constructor.

  • sensors (collections.abc.MutableSequence, optional) – A list of N mounted sensors. Defaults to an empty list.

  • id (str, optional) – The unique platform ID. Default None where random UUID is generated.

  • shape (Shape, optional) – Optional Shape object defining the Platform shape.

class stonesoup.platform.base.PathBasedPlatform(path: GroundTruthPath, movement_controller: Movable = None, sensors: MutableSequence[Sensor] = None, id: str = None, shape: Shape = None)[source]

Bases: MovingPlatform

Parameters:
  • path (GroundTruthPath) – Ground truth path used for the platform. This is for use in cases when platform paths are imported from external data, e.g., from a CSV file

  • movement_controller (Movable, optional) – Movable object to control the Platform’s movement. Default is None, but it can be constructed transparently by passing Movable’s constructor parameters to the Platform constructor.

  • sensors (collections.abc.MutableSequence, optional) – A list of N mounted sensors. Defaults to an empty list.

  • id (str, optional) – The unique platform ID. Default None where random UUID is generated.

  • shape (Shape, optional) – Optional Shape object defining the Platform shape.

path: GroundTruthPath

Ground truth path used for the platform. This is for use in cases when platform paths are imported from external data, e.g., from a CSV file

class stonesoup.platform.base.Obstacle(movement_controller: Movable = None, sensors: MutableSequence[Sensor] = None, id: str = None, shape: Shape = None)[source]

Bases: Platform

A platform class representing obstacles in the environment that may block the line of sight to targets, preventing detection and measurement. This platform requires the user to define the shape property.

Parameters:
  • movement_controller (Movable, optional) – Movable object to control the Platform’s movement. Default is None, but it can be constructed transparently by passing Movable’s constructor parameters to the Platform constructor.

  • sensors (collections.abc.MutableSequence, optional) – A list of N mounted sensors. Defaults to an empty list.

  • id (str, optional) – The unique platform ID. Default None where random UUID is generated.

  • shape (Shape, optional) – Optional Shape object defining the Platform shape.

classmethod from_obstacle(obstacle: Obstacle, **kwargs) Obstacle[source]

Return a new obstacle instance by providing new properties to an existing obstacle. It is possible to overwrite any property of the original obstacle by defining the required keyword arguments. Any arguments that are undefined remain from the obstacle attribute. The utility of this method is to easily create new obstacles from a single base obstacle, where each will share the shape data of the original, but this is not the limit of its functionality.

Parameters:
  • obstacle (Obstacle) – Obstacle to use existing properties from.

  • **kwargs (Mapping) – New property names and associated values for use in newly created obstacle, replacing those extracted from the input obstacle.

class stonesoup.platform.shape.Shape(shape_data: StateVectors, simplices: Sequence[int] | ndarray = None, shape_mapping: Sequence[int] = (0, 1))[source]

Bases: Base

A class for handling shapes as polygons which can be subsequently passed to Platform when considering physical presence of the vehicle. This is also used when defining obstacles which require shape in order for simulated sensors to be affected.

Parameters:
  • shape_data (StateVectors) – Coordinates defining the vertices of the obstacle relativeto its centroid without any orientation.

  • simplices (Union[Sequence[int], numpy.ndarray], optional) – A Sequence or np.ndarray, describing the connectivity of vertices specified in shape_data. Should be constructed such that element i is the index of a vertex that i is connected to. For example, simplices for a four sided obstacle may be (1, 2, 3, 0) for consecutively defined vertices. Default assumes that shape_data is provided such that consecutive vertices are connected, such as the example above.

  • shape_mapping (Sequence[int], optional) – A mapping for shape_data dimensions to \(xy\) Cartesian position. Default value is (0,1).

shape_mapping: Sequence[int]

A mapping for shape_data dimensions to \(xy\) Cartesian position. Default value is (0,1).

shape_data: StateVectors

Coordinates defining the vertices of the obstacle relativeto its centroid without any orientation.

simplices: Sequence[int] | ndarray

A Sequence or np.ndarray, describing the connectivity of vertices specified in shape_data. Should be constructed such that element i is the index of a vertex that i is connected to. For example, simplices for a four sided obstacle may be (1, 2, 3, 0) for consecutively defined vertices. Default assumes that shape_data is provided such that consecutive vertices are connected, such as the example above.