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

Minor fix in CartesianToElevationBearingRangeRate inverse_function. #285

Closed

Conversation

gawebb-dstl
Copy link
Contributor

An extra test with a platform to test the fix

@sdhiscocks sdhiscocks added the bug label Aug 3, 2020
Comment on lines +569 to +579
import datetime

# Import from Stone Soup
from stonesoup.types.state import State
from stonesoup.types.array import StateVector, CovarianceMatrix
from stonesoup.models.transition.linear import (
ConstantVelocity,
CombinedLinearGaussianTransitionModel
)
from stonesoup.platform.base import MovingPlatform
from stonesoup.sensor.radar.radar import RadarRangeRateBearingElevation
Copy link
Member

Choose a reason for hiding this comment

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

Imports should ideally be at the top of the file.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any need to use platforms and sensors here? Would be cleaner to just create the measurement model directly and then use measurement_model.function(Target_State) to obtain a measurement of a moving target.

If we want to test with a moving sensor and target then we should have a separate method which has moving for both platforms.

@@ -562,3 +562,58 @@ def test_inverse_function():
assert approx(inv_measure_state[3], 0.02) == 17.10
assert approx(inv_measure_state[4], 0.02) == 1736.48
assert approx(inv_measure_state[5], 0.02) == 17.36


def test_rangerate_with_platform():
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest parameterize this to test a number of different situations rather than just a single orientation. Suggest platforms state is an input parameter, and that it test both closing and opening motion. I would also make situations where the sensor platform does not move directly towards target, and also avoid specific 45deg increments.

Comment on lines +569 to +579
import datetime

# Import from Stone Soup
from stonesoup.types.state import State
from stonesoup.types.array import StateVector, CovarianceMatrix
from stonesoup.models.transition.linear import (
ConstantVelocity,
CombinedLinearGaussianTransitionModel
)
from stonesoup.platform.base import MovingPlatform
from stonesoup.sensor.radar.radar import RadarRangeRateBearingElevation
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any need to use platforms and sensors here? Would be cleaner to just create the measurement model directly and then use measurement_model.function(Target_State) to obtain a measurement of a moving target.

If we want to test with a moving sensor and target then we should have a separate method which has moving for both platforms.


np.testing.assert_almost_equal(cart_value, np.zeros((6, 1)), 3)

np.testing.assert_almost_equal(measurement_pol_1.state_vector[3], # range rate
Copy link
Contributor

Choose a reason for hiding this comment

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

This line should be set up to test all returned values to ensure it is inverting correctly (where appropriate).

@oharrald-Dstl
Copy link
Contributor

Is this model invertible? Inverting range rate back to state space leads to incorrect velocities in some instances. Would it be better to make an inheritance of 'semi-invertible' measurement models, whereby we can extract a subset of state-space elements?

x_rate = np.cos(phi) * np.cos(theta) * rho_rate
y_rate = np.cos(phi) * np.sin(theta) * rho_rate
z_rate = np.sin(phi) * rho_rate
x_rate = np.cos(theta) * np.cos(phi) * rho_rate
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
x_rate = np.cos(theta) * np.cos(phi) * rho_rate
x_rate, y_rate, z_rate = sphere2cart(rho_rate, phi, theta)

sdhiscocks added a commit that referenced this pull request Nov 6, 2020
Changes required to move target platform from CV to CA model:
 - Change sensors to work with target state space that includes
 acceleration
 - Change target transition models to CA, but for CT (which is pos/vel
 only), include RW for acceleration. This requires CT Sandwich as well,
 as the x acceleration is between x pos/vel and y pos/vel coordinates
 the normal CT model expects back to back.
 - Update tracker to use CA models, including the prior for
 initialisation.
 - Update plotting, as now target/tracks have different state space
 (also hit a bug with inverse function, which I worked around for now,
 due to discussions in #285 if this should even have a inverse method).

[ci skip]
Base automatically changed from master to main March 1, 2021 10:09
@sdhiscocks sdhiscocks requested a review from a team as a code owner March 1, 2021 10:09
@sdhiscocks sdhiscocks requested review from nperree-dstl and svidal-dstl and removed request for a team March 1, 2021 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants