-
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
Something wrong with angular velocity #351
Comments
I see the same behaviour. The underlying Unity3d RigidBody.angularVelocity from which these are derived has the same noise, so I don't think this is really fixable :( Noise of ~0.1 degrees/s is pretty small though? You could maybe add some smoothing to mitigate the noise? |
May be this is a problem with threading or space transformations... 0.1 deg/s per frame (0.02 sec) is a very huge noise, because this is equal to 5 deg/s^2 of angular acceleration. This is acceleration produced by typical RCS. My attitude control system uses angular acceleration computed from the current and previous angular velocity and gets crazy because of this noise in some cases:( May be you can provide me with angular acceleration directly, and computation on the server side will be more accurate? Filtering is not an option, because it introduces a delays. This shifts attitude control responses and frequencies significanly lower. But while flying throught the atmosphere with 50kPa of dynamic pressure, even small delays with attitude correction will result a vessel crash... |
Whatever is causing it, I think it's within Unity so we have no control over it. Sounds like providing angular acceleration directly would be the solution. Unfortunately, angular acceleration isn't available from RigidBody, but we could probably compute it from the vessels MoI and current torque. I'll add an RPC to the server to do this. Also I noticed there is a vessel.AvailableTorque (the max available torque) but no vessel.CurrentTorque so I'll add that too as it could be useful. |
Thanks, this will be very helpful. But please care about space transformations. I need to get and angular acceleration in the vessel relative space. There is no way (or may be i do not understand something) to get angular speed in this way directly (and i can't get angular acceleratio if you add it in same way). I am getting an angular speed in surface_reference_frame then transfom it by the inverse of the vessel's attitude (vessel.rotation), and then getting an acceleration from this transformed angular velocity's. |
OK, will do! I will stick to the usual interface to keep things consistent, but will also try and get the "custom reference frames" feature implemented (issue #252). This should solve your transformation issue by allowing you to create your own reference frame (centered on the vessel, and orientated according to vessel.surface_reference_frame). Then the transformation would be done on the server, using the current interface for getting vector quantities. Would also allow you to set up a stream using the custom frame. And use any other arbitrary combination of reference frames for other use cases. I envisage the code would look something like this: frame = space_center.ReferenceFrame.create(origin=vessel.reference_frame, rotation=vessel.surface_reference_frame)
print vessel.angular_velocity(frame) |
vessel.angular_velocity(vessel.surface_reference_frame()) produces very noisy values.
Here is a dump of each time step (converted to degrees pre second).
+0.0259 -0.0927 -0.0454
-0.0321 +0.0886 +0.0606
+0.0389 -0.0746 +0.0160
-0.0368 +0.0915 -0.0532
+0.0240 -0.0892 -0.0383
-0.0245 +0.0714 +0.0914
+0.0250 -0.0681 -0.0048
+0.0383 +0.1184 -0.0344
+0.0020 -0.0675 +0.0503
+0.0042 +0.0303 -0.0442
-0.0701 +0.0114 +0.0242
+0.0383 -0.1100 +0.0288
+0.0287 +0.1560 +0.0414
+0.0124 -0.0588 +0.0582
-0.0075 +0.0537 -0.0900
+0.0210 -0.0718 +0.0456
-0.0739 +0.0340 -0.0080
+0.0301 -0.0381 -0.0292
-0.0415 +0.0994 -0.0343
+0.0440 -0.1154 +0.0404
But actual angular velocity is very close to zero. RCS, SAS and engines are disengaged.
For example, here is a dump of vessel.angular_velocity(vessel.orbit().body().non_rotating_reference_frame())
+0.0026 -0.0008 -0.0059
+0.0030 -0.0000 -0.0069
+0.0022 -0.0007 -0.0061
+0.0024 -0.0001 -0.0072
+0.0032 -0.0008 -0.0050
+0.0024 -0.0004 -0.0059
+0.0028 +0.0008 -0.0061
+0.0029 -0.0006 -0.0061
+0.0029 -0.0007 -0.0055
+0.0029 -0.0004 -0.0059
+0.0032 -0.0002 -0.0057
+0.0026 -0.0003 -0.0062
+0.0030 -0.0001 -0.0057
+0.0028 -0.0006 -0.0060
+0.0031 -0.0003 -0.0049
+0.0028 -0.0004 -0.0060
+0.0024 -0.0006 -0.0060
+0.0027 -0.0008 -0.0057
+0.0031 +0.0000 -0.0058
I am using kRPC 0.3.6, clean KSP install without mods and the Kerbal-X stock vessel on a circular 100x100 km orbit for this test.
The text was updated successfully, but these errors were encountered: