-
Notifications
You must be signed in to change notification settings - Fork 147
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
Serious error about position and velocity #752
Comments
I wonder if the |
Thanks for your suggestion. I just tried the way to use From the picture above, the most weird thing is that the position jumps from -12.9m to 4.8m when the game is switched from pausing to running; and jumps back to -12.8m when switched back to pausing, which should not happen if the problem is caused by a inappropriate choosing for Dt. I forgot an important detail: this issue happens in a large relative speed (300m/s in this case), If the relative speed is small, the values are right. |
Ok. I will see if I can reproduce.
Get Outlook for iOS<https://aka.ms/o0ukef>
…________________________________
From: LIAOTIANx ***@***.***>
Sent: Saturday, March 25, 2023 11:30:50 PM
To: krpc/krpc ***@***.***>
Cc: GDCosmo ***@***.***>; Comment ***@***.***>
Subject: Re: [krpc/krpc] Serious error about position and velocity (Issue #752)
I wonder if the time.sleep(DT) is causing issues? Is DT fixed? Being that it is accurate on pause makes me lean that direction. If DT is too large, it will likely produce error and is not reporting frequently enough to be accurate. If it is too small, you could run into system resource issues. Try adjusting DT and see if that increases or decreases error. Edit - time.sleep() can be problematic for real-time application (assuming it is not related to reference frame). Variable time methods that use elapsed_itme = current_time - previous_time for example may be worth exploring.
Thanks for your suggestion. I just tried the way to use elapsed_itme = current_time - previous_time. However, the problem is still existing.
In the codes before, Dt is fixed at 0.2s. Actually, I have tested a various of different Dt, but it not works.
From the picture above, the most weird thing is that the position jumps from -12.9m to 4.8m when the game is switched from pausing to running; and jumps back to -12.8m when switched back to pausing, which should not happen if the problem is caused by a inappropriate choosing for Dt.
I forgot a important detail: this issue happens in a large relative speed (300m/s in this case), If the relative speed is small, the values are right.
—
Reply to this email directly, view it on GitHub<#752 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AIOLF2LXMWVXJ4FBYENSPNDW56Z6VANCNFSM6AAAAAAWHQW42Y>.
You are receiving this because you commented.Message ID: ***@***.***>
|
Thanks for taking a look @GaryDeco I wonder if using streams would help. As this is stated to work at low relative speed, but breaks at higher relative speeds, server lag could be the cause of the inaccuraciesB By the time the client has executed all those RPC calls in the while loop body, the target vessel may have moved quite a long way. Using streams would significanlty reduce the lag getting the telemetry, i.e. set up streams, then read from them in the while loop. |
@LIAOTIANx. As stated above from @djungelorm , a stream is ideal for continuous data collection. There are of course limitations. I ran a simulation collecting speed and position relative to a fixed hybrid reference frame. The data seems accurate. Please review the following: Streaming Data: Python Client
Let us know if it worked out so we can either close this out or identify the root cause. |
@GaryDeco @djungelorm I really want to share my codes with you, but there are some external codes based on matlab procedure, which are too complicate to present here. I try to describe the scenario more accurate: From the picture above, the position jumps from -12.9m to 4.8m when the game is switched from pausing to running; and jumps back to -12.8m when switched back to pausing. Neither changing Dt nor using streams can solve this problem. |
@LIAOTIANx I will leave this open and run a test with varied sample rates and stream vs sleep methods. I want to rule out a reference frame issue. |
This could be related to #639 . Going to attempt to address the hybrid reference frame issues and hopefully this will be resolved. Removing triage. |
I appear to have inadvertently reproduced this problem while working on a very similar project in C#, so I'll add my own observations.
Sample data, from low kerbin orbit, surface reference frame: Sample data, vessels traveling straight upwards (normal to planet surface), surface reference frame: Red circles highlight inconsistent position data between game paused and running My best guess is that the data about the two vessels, or the vessel and reference frame, are being gathered at different physics ticks, causing one to catch up/run away from the other in between. Not sure why getting within 200m would fix that though. In case it's useful, the code is in the MissileControl project of this repo https://github.com/JacekCzupyt/ksp-krpc-projects |
I found the cause of the problem - the target object was not in physics range, causing its position to be inaccurate. In orbit, physics are only loaded when an object enters a 200m radius, which is why the issue suddenly disappeared at that range. I don't know enough about how KRPC and KSP works to tell whether this could be considered a bug, or an inevitable consequence of how the engine and mod work. For the time being, the easiest fix is to extend the physics range. There are mods that do that, or you manually edit the values at the bottom of the Physics.cfg file in the game directory (or GameData/ModuleManager.Physics if you use ModuleManager). |
@JacekCzupyt Excellent! Thanks very much for your careful works! The limitation of physics range indeed is a reasonable cause. I will try to fix it by your suggestion. |
@JacekCzupyt |
@JacekCzupyt @GaryDeco @djungelorm Maybe the reference frame issue #639 is also related to physics range? |
@LIAOTIANx @JacekCzupyt Great work in spotting that. I will work on a patch and see if it resolves some of these possibly related issues. |
What happened?
When I develope a guidance procedure, I found the position and velocity is inconsistent between game-pausing and game-running.
I want to design a intercept control procedure, that is, a missile aims to hit a spacecraft. But the missile always can't hit the target by the guidance law based on current state. When I debug and try to fix the problem, I find the value of position and velocity obtained by
(In a while loop)
are not right when game is running. However, their value is correct when the game is pausing (I have verified).
This problem has troubled me a lot of days.
How can someone else reproduce it?
Python scripts:
(RF_FarApproach : a aim reference frame)
What is your environment?
mod version 0.5.2
game version 1.12.5.3190
Anything else we need to know?
No response
The text was updated successfully, but these errors were encountered: