From e7995b5f387a779b899842db6fc132e77d1fd847 Mon Sep 17 00:00:00 2001 From: Edward TF Rogers Date: Fri, 17 Apr 2020 11:56:59 +0100 Subject: [PATCH] Allow setting position of moving platforms, provided their transition model is not set. --- stonesoup/platform/base.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/stonesoup/platform/base.py b/stonesoup/platform/base.py index 25640a9d6..6f9a75a71 100644 --- a/stonesoup/platform/base.py +++ b/stonesoup/platform/base.py @@ -360,7 +360,15 @@ def is_moving(self) -> bool: return np.any(self.velocity != 0) def _set_position(self, value): - raise AttributeError('Cannot set the position of a moving platform') + # The logic below is this: if a moving platform is being built from (say) input + # real-world data then its transition model would not be set, and so it would be fine to + # set its position. However, if the transition model is set, then setting the position is + # both unexpected and may cause odd effects, so is forbidden + if self.transition_model is None: + self.state_vector[self.position_mapping, :] = value + else: + raise AttributeError('Cannot set the position of a moving platform with a ' + 'transition model') def move(self, timestamp=None, **kwargs) -> None: """Propagate the platform position using the :attr:`transition_model`.