Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to platform to allow it to control the positions of its sensors #177

Merged
merged 52 commits into from
Apr 27, 2020

Conversation

erogers-dstl
Copy link
Contributor

Update to platform to allow it to control the positions of its sensors rather than saving it to the sensor each time the platform moves.

As discussed with Rich Green (what seems like an age ago).

Also an add_sensor method and tests (as requested by the todo in the code).

Changes needed to Radar tests for the new platforms.

@sdhiscocks
Copy link
Member

One thing we could do to simplify things, is require that a sensor be mounted to a platform, and can't operate alone; and make the base Platform have sensors (having the option to set this to empty list).

The base platform could be stationary, and then have a subclass for a moving platform.

The position and velocity information should using mappings, such you have greater flexibility in models/dimensions that you use.

I think then you can also have position and velocity as an attribute that's dynamically returned (as appose to "get" methods) from the platform state using the position/velocity mappings on the platforms, and using the mappings and offsets on the sensor. Velocity can still be present on the base (stationary) platform, just returning StateVector of zeros in the same dimensions as position mapping.

On mounting offsets, we should just make this a list of StateVector, that must be same length as number of sensors (default could still create list of all zero state vectors). The current description and logic is confusing.

Also, I'm not clear on the role of add_sensor? Are we expecting to add (remove?) sensors during simulation? Could just be covered by adding a sensor and offset to the platform if required?

@erogers-dstl
Copy link
Contributor Author

One thing we could do to simplify things, is require that a sensor be mounted to a platform, and can't operate alone; and make the base Platform have sensors (having the option to set this to empty list).
The base platform could be stationary, and then have a subclass for a moving platform.

Intriguing. I don't see any reason it wouldn't work and I'd be happy to implement this if that is the consensus.

The position and velocity information should using mappings, such you have greater flexibility in models/dimensions that you use.

Agreed. I wondered about that, but it wasn't the approach used in the Platform originally, so I left as was. The original was less hacky, but when we needed velocity as well things got messy. I should have added a comment to the code that I thought my current approach was a bit of a hack.

I think then you can also have position and velocity as an attribute that's dynamically returned (as appose to "get" methods) from the platform state using the position/velocity mappings on the platforms, and using the mappings and offsets on the sensor. Velocity can still be present on the base (stationary) platform, just returning StateVector of zeros in the same dimensions as position mapping.

I think that should work. Overriding propertys is not quite trivial, as I recall, but I managed it elsewhere. Sorry, only getting access to the superclass's property was the tricky bit. Only (minor) reason not too is that propertys imply a cheap call, which is not necessarily true.

On mounting offsets, we should just make this a list of StateVector, that must be same length as number of sensors (default could still create list of all zero state vectors). The current description and logic is confusing.

Do you mean mounting mappings? Mounting offsets are implemented as you describe, but mappings are more complex. Assuming you do mean mappings, then yes, I can see the argument for simplifying this code. The tradeoff is more complicated client code slightly though, as I don't think zero defaults would work. The only sensible default I can see for mappings is [0::2] which is pretty much as bad as my (hacky) code for get_position.

Re-reading the comment, it also possible that you meant we should use List[StateVector] rather than nxN ndarray. In which case: Happy to go with that. It's always used by element anyway.

Also, I'm not clear on the role of add_sensor? Are we expecting to add (remove?) sensors during simulation? Could just be covered by adding a sensor and offset to the platform if required?

I have to say I added this because there was a TODO asking for it and it was easy when I was refactoring. The add_sensor code can be simplified if we have change mounting_mapping as described above.

Without the add_sensor() method you would need to append to the list of sensors and concatenate properly to both the mapping and offset arrays. The risk of internal inconsistency would be high... You could end up with many errors on read, which might be hard to diagnose. I would therefore argue for keeping it. It's implemented (and tested) now. The only argument against is YAGNI, which is valid, but not sure it's worth deleting it just for that. Happy to yield the point though if others feel strongly

@erogers-dstl
Copy link
Contributor Author

On reflection: I think that List[StateVector] or single StateVector would be the way to go for mounting_mappings and List[StateVector] defaulting to zeros for the mounting_offsets. That's easier to understand and would avoid the nasty default problem for mounting_mappings.

…s, rather than saving it to the sensor each time the platform moves.
- Create both fixed and moving sensor platforms
- Force a sensor to be mounted to a platform
- properties for position and orientation
- Use a mapping between state_vector and position
- Give Platform a state_vector property
- Force mappings to be sensible shape
- Update tests to match

Still needs some tidying and documentation
… all Sensors now require platforms.

Passive test failing, but will be addressed in the next commit.
@erogers-dstl
Copy link
Contributor Author

Still a WIP. Mostly needs documentation. Pushed to check the circle CI builds. I expected the docs not to build until #183 is merged.

Copy link
Member

@sdhiscocks sdhiscocks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looking great, just a few minor comments.

stonesoup/platform/base.py Outdated Show resolved Hide resolved
stonesoup/platform/base.py Outdated Show resolved Hide resolved
stonesoup/platform/base.py Outdated Show resolved Hide resolved
stonesoup/platform/base.py Show resolved Hide resolved
stonesoup/sensor/sensor.py Show resolved Hide resolved
Copy link
Contributor

@rjgreen-dstl rjgreen-dstl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy with this, really useful capability change

'default platform')

@property
def orientation(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def orientation(self):
def orientation(self) -> StateVector:

@erogers-dstl
Copy link
Contributor Author

Just adding a few more tests to improve coverage...

@erogers-dstl
Copy link
Contributor Author

Just adding a few more tests to improve coverage...

All done!

@sdhiscocks sdhiscocks merged commit 77061d4 into master Apr 27, 2020
@erogers-dstl erogers-dstl deleted the platform_extensions branch May 5, 2020 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants