r/KerbalSpaceProgram • Former Dev • Jan 26 '16

Dev Post Devnote Tuesday: A change of pace

Hello everyone!  
With an internal deadline behind us we’re winding down a little, allowing everyone to feel a bit more human again. This is temporary mind you, as we have many more milestones to cross in the near future! Regardless, this change of pace is a very welcome one indeed and almost everyone took a well-deserved day off last Friday.
 
That still leaves quite a few days in the week to code, model and converse of course, and Felipe (HarvesteR) has spent them by starting the QA process for the wheels. The ‘new‘ wheels, implemented half a year ago already, still had quite a few unresolved issues that had remained unaddressed… until now!
 
A wide range of issues was fixed this week: from initialization issues that were caused by oversights from six months ago to more bizarre bugs such as the one that caused parked wheels to start drifting. We never quite discovered the root cause of the issue, but Felipe devised a plan (a very cunning plan) and simply corrected the phantom torque with an equal and opposite torque. Newton would be proud. The wheels now stay in place, which means that vehicles continue to not move as they should.
 
Another wheel related issue we ran into was that the wheel friction seemed far too low in low-gravity environments. As it turns out, this wasn’t a bug but rather an accurate display of physics: in low-gravity environments the load that is exerted on the vehicle by the mass that is placed on the wheels decreases, as the parts weigh less in their current state. The perceived problem existed because the wheels never compensated for the amount of gravity they were experiencing, and the wheels would spin out at the slightest touch of the controls. The solution is of course traction control. This system will now automatically adjust the amount of torque the wheels produce based on the gravity of the planet or moon you’re located at. Best of all perhaps, Felipe wants to let players override this system, which could lead to a lot of fun.
 
The last change related to wheels we want to discuss here should be welcome to a lot of you, as this has been a source of much grief: the ‘old’ wheels had an impossibly high lateral friction value, which caused takeoffs to be jittery if the wheels were ever so slightly misaligned, and caused rovers to flip end over end at the slightest provocation. With the new wheel system it’s much more likely that the rover will spin out and perhaps enter a roll if the forces are great enough. This could, of course, lead to even more fun.
 
Steve (Squelch) and Mathew (sal_vager) have definitely proven that the new wheels are behaving better and better: both have put in many hours to test their functionality, or rather break it in true Danny2462 style.
 
On the topic of bugs and testing, Nathanael (NathanKell) continues doing what he does best: squash them with might and fury. The most notable one this week was caused by a change in the RCS thrust calculations: in certain situations the RCS thrusters would visually show a low-power output when the thrusters were in fact working at maximum capacity. In other news, in order to be able to easily track pitch during ascent, and have yaw/pitch/roll rate measurements for wheel testing, pitch/heading/roll output was added to the AeroGUI and AeroGUI has been made a debug option from the aerodynamics tab of the debug toolbar. AeroGUI was originally written to help 1.0 aero QA and it’s been helpful in every QA session since, so ‘stockification’ of this development tool is worth the effort.
 
The KSPedia is a new feature for 1.1, and after Dave (TriggerAu)’s design work Mike (Mu) is now working to get the backend system into a working state and into the main project, as well as continuing work on the new PartTools project. The new PartTools uses Unity AssetBundles rather than .mu files and will therefore allow every standard Unity object to be included in mods. Hopefully this will lead to new and interesting mods after the release of 1.1. The AssetBundles can be loaded as part of the main loading method or delayed and loaded & unloaded on-demand whilst the game is running. The old Mu files and loading methods will of course still be supported.
 
Bob (RoverDude) spent this week building and refining the user interface for the telemetry and antenna relay systems, the network graph in particular. This part will show your current communications path back to Kerbin the map view. Aside from that the usual necessary tasks have also taken up some time: code documentation, design notes and testing instructions for the QA team.
 
The biggest change in pace is no doubt for Ted, who has taken on the task of representing Kerbal Space Program in the mainstream UK media. As we mentioned a few weeks ago, space is all the rage in the UK with astronaut Tim Peake currently aboard the International Space Station. Ted is currently in London and preparing to record radio and TV interviews which will be aired throughout the UK in the next week. After that is done Ted will fly out to Paris to join Kasper (KasperVld) and head to the iGamer conference for educational games. Preparations for the conference are coming along, and there’s a lot of things to take care of: a system to demonstrate the game, printing posters and flyers and of course taking care of accommodations for the developers. If you’re in the Paris area this weekend then feel free to come and say hi!
 
Joe (Dr Turkey) sends his regards, some bad chicken has thoroughly ruined his day so he was unable to contribute to this week’s devnotes.
 
That’s it for this week, be sure to read the KSP forums, follow the KSP Twitter and Facebook accounts or follow us in any other place you can think of.

282 Upvotes

187 comments sorted by

View all comments

14

u/KSPoz Super Kerbalnaut Jan 26 '16

Oh, wheels again. ELI5 please why it's so hard to simulate wheel physics in Unity that it needs so much attention?

28

u/biosehnsucht Jan 26 '16

Wheels in Unity are so bad to begin with you have to go get a 3rd party add-on to Unity to get them even remotely usable.

Wheels are actually pretty complicated when you consider there is suspension (potentially with different bound/rebound and spring rates), traction (which can vary by surface, direction of motion relative to the tire's intended direction of motion, speed, weight, contact patch area (the area of the tire touching the ground, which is not normally a line but a rounded square or similar shaped area because of how tires deflect under load / contact with the ground), tire pressure and temperature, etc.

I'm not saying ALL of that is simulated for KSP, but wheels can be complicated.

98

u/KSP_HarvesteR Jan 26 '16 edited Jan 26 '16

All of that actually IS simulated in KSP, actually.

Wheels really are deceptively complicated things. We usually take them for granted, expecting them to 'just work ' straight away, but we don't normally stop to think about how complex a piece of engineering they are.

Wheels in KSP are no exception. The only simplification is that there is no drive train system involved. Powered wheels consume electricity and drive themselves, so at least there's no need to simulate transmissions and differentials and such. However, everything else: tire friction, suspension springs and dampers, steering, brakes, deployment and damage, all these need to be simulated properly, and there are added difficulties too.

Steering needs to be smart enough to know which way is left and right depending on where and how it's placed on the vessel. It might seem simple at first, but consider bizarre cases like a cylindrical vessel with wheels placed horizontally. All cases must work.

Motors also need to be smart, to figure out which way to rotate to drive forward and back. Also, add to that the requirement that the XL3 wheel (and likely other mods too) steers using differential drive. Then also add to that the notion that different celestial bodies have different gravity levels, which means the wheels have to tune themselves so they don't spin out when driven with the same torque while they're underloaded, being landed in a world with low gravity (or get hopelessly stuck at higher Gs).

Then, tire friction... VPP does an excellent job of simulating tire forces, but in KSP, we couldn't rely on several 'normal' assumptions, like which way is up, how the wheels are rotated in relation to the vessel and vertical axis, and so on. We also have to account for forces that come from other parts of the vessel, and are passed down to the wheels by the joints. If not handled properly, you'll find tons of cases where things wobble and oscillate themselves to pieces.

The suspension was probably the most complicated thing to figure out. We can set spring and damper values, sure, but what if you have a really heavy vessel, or a really light one? The suspension has to work regardless of how much mass we put on it, and because in KSP, vessels aren't single point masses, we can't even rely on the wheel raycast hit force that physx provides. We calculate the true wheel load by watching the suspension compress, then update the springs so the vessel weight is supported.

Damping was also complicated because it has to be dynamic as well, to match the dynamic springs. Damper values aren't expressed in the same units, though, so finding that relationship took a really long time, and required a LOT of testing.

Then we also have deployment and damage to think about, and more complicatedly, how those things affect everything else I mentioned already. A damaged wheel shouldn't be able to steer or drive, or simulate suspension. Retracted wheels shouldn't either. There are several ways to make individual wheel subsystems become in/operable, so these subcomponents actually need to be aware of each other, but without ever expecting them to actually be there.

There are other smaller, but nonetheless involved features we had to do. There are two landing gears which have multiple wheels. Those are mounted on a pivoting bogey. That same bogey module is also used for landing legs, which are also wheels, to orient their feet into the surface. Then there's lights and brake lights, and of course, engines need to consume resources, and all of it needs to lock down if the vessel isnt' controllable, and all the rest, like action groups, context menu options, readouts, the works.

All in all, the wheels are by far the most complex parts that you can add onto a ship. No other part has so many different combinations of behaviours or requires as much tuning.

Wheels really are deceptively complicated.

Cheers

31

u/Tortfeasor Jan 26 '16

Apart from the fact that I always really appreciate hearing directly from the devs, the most impressive thing about that reply is that it must've taken AGES to write.

I'm always so disappointed that the weekly devnote post doesn't get more upvotes, given the effort it takes from people who have to take time out of their work to do it.

So, thank you

20

u/KerbalEssences Master Kerbalnaut Jan 26 '16

When you know what you are talking about writing becomes very easy I think. I bet Harvester didn't even plan to write so much but at some point realised how much he just wrote and stopped :) That at least often happens to me when I try to explain something I spent really much time on. lol

2

u/space_is_hard Jan 27 '16

This is absolutely true. Even something simple like explaining my method for gravity turns ends up being many paragraphs, but I know it so well that I am always surprised by how long the post was after I click save.

10

u/Anakinss Jan 26 '16

All in all, the wheels are by far the most complex parts that you can add onto a ship. No other part has so many different combinations of behaviours or requires as much tuning.

That's quite a statement about a game like Kerbal SPACE Program.

18

u/[deleted] Jan 26 '16

Space is easy, physics at it's most straightforward.

31

u/KuntaStillSingle Jan 27 '16

Pretty much every ideal physics problem: assuming a vacuum...

5

u/alwaysready Jan 27 '16

assuming a vacuum...

and the rocket is a sphere.

6

u/mak10z Master Kerbalnaut Jan 26 '16 edited Jan 26 '16

Well aside from the fuel pumping system, rocket engines are relatively simple beasts.. a combustion chamber.

SRBs have been around in one form or another since Ancient China, and the internal mechanisms of Rocket motors in KSP aren't simulated nearly as much as the Wheels apparently are.

8

u/ElMenduko Jan 27 '16 edited Jan 27 '16

Because you can get away with simulating a rocket motor easily as it is done in KSP right now.

Simply, the Isp changes with air pressure, which in turn changes thrust. Thrust is applied from the engine and the exhaust is just for the looks. If it's a jet engine, it needs intake air, whose amount changes with different intakes and relative air speeds.

It works quite well, because rockets are simple, and just propel things in one direction.

Wheels ARE more complicated, and if, for example, don't simulate suspensions at all your rovers would drive like a plank at best and flip most of the time while turning. They simply don't work well without simulating them in this complicated fashion.

As anyone who was fooled and tried unity for the lols, and used wheels , the "default" Unity wheels are almost completely useless. Actually, I went with a simple sled game because I wasn't smart enough to make better wheels myself.

EDIT: Minor typo in first sentence

18

u/KSP_HarvesteR Jan 27 '16

Indeed. Wheels are so frequently seen in just about any game, and they're such a commonplace thing IRL, we tend to expect them to work perfectly by default, not putting much thought into how complex they are, until something doesn't work properly.

Cheers

13

u/Iamsodarncool Master Kerbalnaut Jan 27 '16

Mr Falanghe, while you're here I'd like to take the opportunity to thank you for making the best game I've ever played. It's so obvious you deeply care about KSP being awesome, and I really, truly appreciate that.

3

u/ElMenduko Jan 27 '16

Exactly.

Rocket science is WAY easier than (re)inventing the wheel.

Good thing to know you got the new wheels working well ;)

→ More replies (1)

2

u/[deleted] Jan 27 '16

Then again, liquid rockets can suffer from things like pogo oscillation and combustion instability which are quite complex.

4

u/Kasuha Super Kerbalnaut Jan 26 '16

The suspension was probably the most complicated thing to figure out. We can set spring and damper values, sure, but what if you have a really heavy vessel, or a really light one? The suspension has to work regardless of how much mass we put on it, and because in KSP, vessels aren't single point masses, we can't even rely on the wheel raycast hit force that physx provides. We calculate the true wheel load by watching the suspension compress, then update the springs so the vessel weight is supported.

I have a rebel thought. Since you figured out such a nice adaptive system for suspension (and you truly have my appreciation for it) maybe you could give the SAS another go? Because problems it suffers - inability to hold pitch on planes, oscillations on tiny probes, oscillations with direct modes such as prograde hold - sound rather close to problems you solved on suspensions.

4

u/space_is_hard Jan 27 '16

Adaptive suspension is much, much simpler than adaptive vehicle attitude control. The suspension adjustments are entirely behind-the-scenes and can be unrealistic because the player doesn't expect them to work realistically or within the limits of realistic suspensions; the game engine can adjust them as it sees fit with no regard for how real suspensions are tuned.

SAS is a different beast for many reasons, least of all being that it has to operate in three different axes of control (not just one) that are all intimately linked. The really tough part though is that it has to work within the bounds of the player's ship design. It can't adjust available torque beyond what the design is built for; if pointing directly at prograde requires more pitch torque than the ship is capable of giving, increasing the available torque in the same fashion that the wheel suspension will adjust stiffness (instantly and with no effect on other control systems) would be noticeably unrealistic and would result in some wonky manual controls (remember that we won't be able to adjust the wheel suspension settings manually and on-the-fly).

All-in-all, I'd say the present iteration of SAS does an outstanding job, especially in situations where aerodynamic control surfaces make up the majority of the control authority.

This is all coming from a first-hand attempt at creating a vehicle control system in kOS, and from watching /u/hvacengi create kOS's revamped steering code.

2

u/Kasuha Super Kerbalnaut Jan 27 '16 edited Jan 27 '16

I agree with you in many points. Yes, I understand that adaptive suspension is simpler than SAS. Yes, suspension can behave unrealistically time to time as long as it does not break ships. Actually the implemented adaptive suspension is 100% unrealistic, nothing like that exists in real world. And I agree that SAS is complex matter.

I however don't agree with your statement that "the present iteration of SAS does an outstanding job". It does good job in many situations but it fails in other situations. And ability to adapt to these situations is what it needs. Simlar to how the suspension needs to adapt to mass and forces affecting the wheel, SAS needs to adapt to forces the collective action of all control mechanisms can apply to the ship. It needs to tone it down when the ship reacts too fast, and to push harder if it reacts too slow, independent in each direction.

SAS problems known to me:

  • With an airplane, I can keep pitch easily from keyboard but as soon as I leave it up to SAS, it starts "from scratch" and slowly increases the action to hold the course while it gives up on holding the pitch at the same time. To make it keep 10 degree pitch, I need to push the nose to 40 degrees and let it "give up" all the way down to 10 degrees where it finally catches up. Trying that in hypersonic such as reentry is deadly. And yes, during rentry I can activate stability assist and it will raise the pitch steadily as the plane goes around the globe but as soon as I touch WASD I can say bye to whatever pitch it holds, it starts from scratch again and gives up 30 degrees of pitch easily.
  • Directed SAS modes (e.g. prograde) clearly use different mechanism than stability assist and it is ... is "jerky" the right word? It applies full impulse in one direction, then, before the ship even started moving, applies full impulse in opposite direction. Aerodynamic surfaces have slow response so they average it somewhat but gimbaled engines act like crazy and actually lose measurable dv to it. And where the effect is worst is reaction wheels since it drains electricity like crazy and it makes small ships shake noticably. On top of all that, again in situations like gravity turn where I can hold the heading in the center of the prograde marker with keyboard easily (and by easily I don't mean applying full force all the time), it fails to follow it again.
  • Even weak reaction wheels in probe cores are too strong for really small probes. Even stability assist then leads to the probe oscillating around the desired direction. Again, it drains batteries. And again, solution in such situation is to do it manually. And sorry, from keyboard I only have option to apply full force or no force, while SAS has proportional. It has an advantage!

Then there is the problem that I seem to be unable to hold planes horizontal. It almost feels like there is some "antihelper" that makes sure the plane is rolled either 3 degrees to the left or 3 degrees to the right but nothing in between. I'm not sure if it's the SAS to be blamed about it, though.

I'm ready to say that SAS does outstanding job if these issues are not there.

Edit: adding up to SAS issues (I remembered a few more):

  • When directional SAS mode (e.g. prograde) is engaged when the ship is heading in a significantly different direction (over 90 degrees), it often takes off in a direction perpendicular to where the desired direction is. I have seen it to complete three full circles before it started acting reasonably.
  • Again in directional SAS mode when it actually points (almost?) exactly in the center, it often starts to vibrate the ship. Again, applying full impulse in one direction and next frame full impulse in the opposite direction. For some reason, it even starts to roll.

2

u/space_is_hard Jan 27 '16

I suppose I should have added a qualifier to my statement: The current iteration of SAS is outstanding given the difficulty of developing control systems for stuff like this, especially stuff that uses primarily aerodynamic control surfaces. It's the point I was trying to get across and it's totally my fault for not stating it clearly.

Control systems are an entire engineering discipline unto themselves and I can't blame HarvesteR for not giving us a perfect implementation. There are people that study stuff that does what SAS tries to do as a full time job. It's all incredibly complex.

→ More replies (5)
→ More replies (9)

4

u/Assault_Rains Jan 27 '16

So the suspension value being calculated and applied results in the "bopping" of wheels slightly after the craft is loaded?

As example if I put out an spaceplane out of my SPH the suspension picks up slightly later after loading, bopping the plane up.

15

u/KSP_HarvesteR Jan 27 '16

That's just the physics kicking in. The craft is spawned as close as possible to the surface, but there's no way to get it exactly right, especially with moving contact points, like wheels and suspensions.

The 'boink' happens when the vessel first settles under its own weight. Sometimes it drops a bit if the initial position was high, other times it pops up, if it was low.

Considering the editor and the launchpad aren't even rotated towards the same direction ('up' is a very relative thing), if all you get is a 'boink', that's pretty much all we can ask for. :)

Cheers

2

u/Assault_Rains Jan 27 '16

Thanks for clarification!

I was interested in this because with ridiculously heavy stuff this boink can kill the launchpad/landing strip in a fiery hell. Kerbal Foundries has more in-depth spring and dampening settings which usually seem to get me around this.

4

u/SneakyB4stardSword Jan 27 '16

bizarre cases like a cylindrical vessel with wheels placed horizontally

You mean like literally all of my rovers?

2

u/AristaeusTukom Jan 27 '16

I propose you call 1.1 "Wheel simulator 2016".

→ More replies (2)