Movables
- class stonesoup.movable.movable.Movable(states: MutableSequence[State], position_mapping: Sequence[int], velocity_mapping: Sequence[int] | None = None)[source]
Bases:
StateMutableSequence,Actionable,ABC- Parameters:
states (
MutableSequence[State]) – A list of States which enables the platform’s history to be accessed in simulators and for plotting. Initiated as a state, for a static platform, this would usually contain its position coordinates in the form[x, y, z]. For a moving platform it would contain position and velocity interleaved:[x, vx, y, vy, z, vz]position_mapping (
Sequence[int]) – Mapping between platform position and state vector. For a position-only 3d platform this might be[0, 1, 2]. For a position and velocity platform:[0, 2, 4]velocity_mapping (
Optional[Sequence[int]], optional) – Mapping between platform velocity and state dims. If not set, it will default to[m+1 for m in position_mapping]
- states: MutableSequence[State]
A list of States which enables the platform’s history to be accessed in simulators and for plotting. Initiated as a state, for a static platform, this would usually contain its position coordinates in the form
[x, y, z]. For a moving platform it would contain position and velocity interleaved:[x, vx, y, vy, z, vz]
- position_mapping: Sequence[int]
Mapping between platform position and state vector. For a position-only 3d platform this might be
[0, 1, 2]. For a position and velocity platform:[0, 2, 4]
- velocity_mapping: Sequence[int] | None
Mapping between platform velocity and state dims. If not set, it will default to
[m+1 for m in position_mapping]
- validate_timestamp()[source]
Method to validate the timestamp of the actionable.
- Returns:
True if timestamp is valid, False otherwise.
- Return type:
- property position: StateVector
Return the position of the platform.
Extracted from the state vector of the platform using the platform’s
position_mapping. This property is settable for fixed platforms, but not for movable ones, where the position must be set by moving the model with a transition model.
- property ndim: int
Convenience property to return the number of dimensions in which the platform operates.
Given by the length of the
position_mapping
- abstract property orientation: StateVector
Return the orientation of the platform.
Implementation is case dependent and left to the Fixed/Moving subclasses
- abstract property velocity: StateVector
Return the velocity of the platform.
Implementation is case dependent and left to the Fixed/Moving subclasses
- abstract move(timestamp: datetime, noise: bool = True, **kwargs) None[source]
Update the platform position using the
transition_model.- Parameters:
timestamp (
datetime.datetime) – A timestamp signifying when the end of the maneuver
Notes
This methods updates the value of
position.Any provided
kwargsare forwarded to thetransition_model.If
transition_modelortimestampisNone, the method has no effect, but will return successfully.
- class stonesoup.movable.movable.FixedMovable(states: MutableSequence[State], position_mapping: Sequence[int], velocity_mapping: Sequence[int] | None = None, orientation: StateVector = None)[source]
Bases:
MovableFixed platform base class
A platform represents a random object defined as a
StateMutableSequencewith fixed (but settable) position and orientation.Note
Position and orientation are read/write properties in this class.
- Parameters:
states (
MutableSequence[State]) – A list of States which enables the platform’s history to be accessed in simulators and for plotting. Initiated as a state, for a static platform, this would usually contain its position coordinates in the form[x, y, z]. For a moving platform it would contain position and velocity interleaved:[x, vx, y, vy, z, vz]position_mapping (
Sequence[int]) – Mapping between platform position and state vector. For a position-only 3d platform this might be[0, 1, 2]. For a position and velocity platform:[0, 2, 4]velocity_mapping (
Optional[Sequence[int]], optional) – Mapping between platform velocity and state dims. If not set, it will default to[m+1 for m in position_mapping]orientation (
StateVector, optional) – A fixed orientation of the static platform. Defaults to the zero vector
- orientation: StateVector
A fixed orientation of the static platform. Defaults to the zero vector
- property velocity: StateVector
Return the velocity of the platform.
For a fixed platform this is always a zero vector of length
ndim.
- class stonesoup.movable.movable.MovingMovable(states: MutableSequence[State], position_mapping: Sequence[int], transition_model: TransitionModel, velocity_mapping: Sequence[int] | None = None)[source]
Bases:
MovableMoving platform base class
A platform represents a random object defined as a
Statethat moves according to a givenTransitionModel.Note
Position and orientation are a read only properties in this class.
- Parameters:
states (
MutableSequence[State]) – A list of States which enables the platform’s history to be accessed in simulators and for plotting. Initiated as a state, for a static platform, this would usually contain its position coordinates in the form[x, y, z]. For a moving platform it would contain position and velocity interleaved:[x, vx, y, vy, z, vz]position_mapping (
Sequence[int]) – Mapping between platform position and state vector. For a position-only 3d platform this might be[0, 1, 2]. For a position and velocity platform:[0, 2, 4]transition_model (
TransitionModel) – Transition modelvelocity_mapping (
Optional[Sequence[int]], optional) – Mapping between platform velocity and state dims. If not set, it will default to[m+1 for m in position_mapping]
- transition_model: TransitionModel
Transition model
- property velocity: StateVector
Return the velocity of the platform.
Extracted from the state vector of the platform using the platform’s
velocity_mapping. If the state vector is too short and does not contain the elements specified in thevelocity_mappingthis raises anAttributeError
- property orientation: StateVector
Return the orientation of the platform.
This is defined as a 3x1 StateVector of angles (rad), specifying the sensor orientation in terms of the counter-clockwise rotation around each Cartesian axis in the order \(x,y,z\). The x and z rotation angles are positive if the rotation is in the counter-clockwise direction when viewed by an observer looking along the respective rotation axis, towards the origin. The y rotation angle is the opposite (matching ‘elevation’).
The orientation of this platform is defined as along the direction of its velocity, with roll always set to zero (as this is the angle the platform is rotated about the velocity axis, which is not defined in this approximation).
Notes
A non-moving platform (
self.is_moving == False) does not have a defined orientation in this approximations and so raises anAttributeError
- property is_moving: bool
Return the
Trueif the platform is moving,Falseotherwise.Equivalent (for this class) to
all(v == 0 for v in self.velocity)
- move(timestamp=None, noise=True, **kwargs) None[source]
Propagate the platform position using the
transition_model.- Parameters:
timestamp (
datetime.datetime, optional) – A timestamp signifying when the end of the maneuver (the default isNone)
Notes
This methods updates the value of
position.Any provided
kwargsare forwarded to thetransition_model.If timestamp` is
None, the method has no effect, but will return successfully.
- class stonesoup.movable.movable.MultiTransitionMovable(states: MutableSequence[State], position_mapping: Sequence[int], transition_models: Sequence[TransitionModel], transition_times: Sequence[timedelta], velocity_mapping: Sequence[int] | None = None)[source]
Bases:
MovingMovableMoving platform with multiple transition models
A list of transition models are given with corresponding transition times, dictating the movement behaviour of the platform for given durations.
- Parameters:
states (
MutableSequence[State]) – A list of States which enables the platform’s history to be accessed in simulators and for plotting. Initiated as a state, for a static platform, this would usually contain its position coordinates in the form[x, y, z]. For a moving platform it would contain position and velocity interleaved:[x, vx, y, vy, z, vz]position_mapping (
Sequence[int]) – Mapping between platform position and state vector. For a position-only 3d platform this might be[0, 1, 2]. For a position and velocity platform:[0, 2, 4]transition_models (
Sequence[TransitionModel]) – List of transition modelstransition_times (
Sequence[datetime.timedelta]) – Durations for each listed transition modelvelocity_mapping (
Optional[Sequence[int]], optional) – Mapping between platform velocity and state dims. If not set, it will default to[m+1 for m in position_mapping]
- transition_models: Sequence[TransitionModel]
List of transition models
- property transition_model
Transition model
- move(timestamp=None, noise=True, **kwargs) None[source]
Propagate the platform position using the
transition_model.- Parameters:
timestamp (
datetime.datetime, optional) – A timestamp signifying the end of the maneuver (the default isNone)
Notes
This methods updates the value of
position.Any provided
kwargsare forwarded to thetransition_model.If
transition_modelortimestampisNone, the method has no effect, but will return successfully.This method updates
transition_model,transition_indexandcurrent_interval: If the timestamp provided gives a time delta greater thancurrent_intervalthetransition_modelis called for the rest of its corresponding duration, and the move method is called again on the next transition model (by incrementingtransition_index) intransition_modelswith the residue time delta. If the time delta is less thancurrent_intervalthetransition_modelis called for that duration andcurrent_intervalis reduced accordingly.
Grid-based Movables
- class stonesoup.movable.grid.NStepDirectionalGridMovable(states: MutableSequence[State], position_mapping: Sequence[int], velocity_mapping: Sequence[int] | None = None, orientation: StateVector = None, action_space: ndarray = None, action_mapping: Sequence[int] = (0, 1), resolution: float = 1, n_steps: int = 1, step_size: int = 1)[source]
Bases:
_GridActionableMovableThis is a movable that enables movement in a grid like fashion according to a number of steps and step sizes. Actions are applied symmetrically on the action space allowing for movement in both positive and negative directions of each axis. This movable implements the
NStepDirectionalGridActionGenerator- Parameters:
states (
MutableSequence[State]) – A list of States which enables the platform’s history to be accessed in simulators and for plotting. Initiated as a state, for a static platform, this would usually contain its position coordinates in the form[x, y, z]. For a moving platform it would contain position and velocity interleaved:[x, vx, y, vy, z, vz]position_mapping (
Sequence[int]) – Mapping between platform position and state vector. For a position-only 3d platform this might be[0, 1, 2]. For a position and velocity platform:[0, 2, 4]velocity_mapping (
Optional[Sequence[int]], optional) – Mapping between platform velocity and state dims. If not set, it will default to[m+1 for m in position_mapping]orientation (
StateVector, optional) – A fixed orientation of the static platform. Defaults to the zero vectoraction_space (
numpy.ndarray, optional) – The bounds of the action space that should not be exceeded. Of shape (ndim, 2) where ndim is the length of the action_mapping. For example,np.array([[xmin, xmax], [ymin, ymax]]).action_mapping (
Sequence[int], optional) – The state dimensions that actions are applied to.resolution (
float, optional) – The size of each grid cell. Cells are assumed square.n_steps (
int, optional) – The number of steps that can be moved in either direction along specified dimensionsstep_size (
int, optional) – The number of grid cells per step
- generator
alias of
NStepDirectionalGridActionGenerator