Shadowmage

[1.7.x] KSPWheel - Physics Based Alternate Wheel Collider [API Only]

Recommended Posts

10 hours ago, Corax said:

While the searching brought about ways to select individual files and directories, it appears as if in order to do that, git actually does have to download the entire repository regardless.

Indeed. :P

Missing features is just a minor addition to existing major dislikes. a) It's owned by microsoft and b) It's restricting devs in countries sanctioned by the US... Like those devs have anything to do with politics.
Git (the CLI tool) I can dig, and if Github was actually free and open to all, I'd be all for that too. It's clearly not, so I refuse to use it.

 

Share this post


Link to post
Share on other sites
Posted (edited)

Well, I got it working. This is much better, it took a little tweaking, and I did end up doubling the performance  of some wheels in the config, but I can finally go roving through the hills again. Thanks!
QESC4AS.png

The Eve Explorer feels like a landrover again, not a pedal car. 
Setting it up manually was tricky at first, and while driving, having to adjust gears per wheel seemed a bit weird. But I made it work.
The wheel scaling function is really clever - It's a great way to fit the wheel to your vehicle.

I like the way it handles electricity. I demand higher performing wheels, it wants more power. Seems a fair trade, 

The dust effect is pretty cool too

c5RdjlO.pngIt's built for Eve, hence the large amount of wheels.
Although I think someone needs to go sweep the paths around the space center...

The only thing that's a little annoying is mechjeb autopilot doesn't seem to recognise the wheels,  would be nice if fixed someday, but on balance I think the change is still worth it

Edited by Tw1

Share this post


Link to post
Share on other sites
On 4/22/2019 at 9:11 AM, Shadowmage said:

https://github.com/shadowmage45/KerbalFoundries2/tree/master/KerbalFoundries-Patches/Stock

The above patches apply the KSPWheel modules to the stock wheels.  Download them and place them somewhere in your GameData/ folder.  Note:  They haven't been tested or updated in quite some time, so I cannot guarantee how well they work.  At the very least, it is a good place to start though :)

Would patching Wheels/Legs from other mods follow a similar structure to these? Or is additional work needed?

Share this post


Link to post
Share on other sites
16 hours ago, Incarnation of Chaos said:

Would patching Wheels/Legs from other mods follow a similar structure to these?

Fairly similar.  I've had good success on patching every other mod leg that I've seen.  If it can work with the stock modules, it will certainly be able to work with the KSPWheel modules.

The precise settings/configuration needed will of course depend on the specific model, but they should all be able to be converted.

Share this post


Link to post
Share on other sites
1 hour ago, Shadowmage said:

Fairly similar.  I've had good success on patching every other mod leg that I've seen.  If it can work with the stock modules, it will certainly be able to work with the KSPWheel modules.

The precise settings/configuration needed will of course depend on the specific model, but they should all be able to be converted.

Awesome

Share this post


Link to post
Share on other sites
On 8/9/2019 at 7:09 AM, Tw1 said:

Setting it up manually was tricky at first, and while driving, having to adjust gears per wheel seemed a bit weird.

If you use the 'wheel group' function, you can change gears on multiple wheels at the same time.  In the PAW for each wheel there is a selection for 'wheel group'.  Setting this to '0' means 'no group', any other value specified (e.g. 1, 2, etc) will create a 'group' of all wheels that are assigned that number.  Most of the functions in the PAW will then effect the entire group when activated (spring/damper changes, gear changes, enable/disable motor...likely others I'm forgetting).

On 8/9/2019 at 7:09 AM, Tw1 said:

The wheel scaling function is really clever - It's a great way to fit the wheel to your vehicle.

Yeah, I really don't understand why stock doesn't include some sort of scaling functions for most parts.  The least I could do was solve the issues for wheels while I was working on them :)

On 8/9/2019 at 7:09 AM, Tw1 said:

I like the way it handles electricity. I demand higher performing wheels, it wants more power. Seems a fair trade, 

Should be quite... physically based... as well.  The amount of EC input, and torque output, is all based on standard brushless motor equations.  More power output demands more power input, all consistent and logical.

 

On 8/9/2019 at 7:09 AM, Tw1 said:

The only thing that's a little annoying is mechjeb autopilot doesn't seem to recognise the wheels,  would be nice if fixed someday, but on balance I think the change is still worth it

Yeah, that is unfortunately nothing that I can solve on this end of the code.  Any solution would have to come from MechJeb in the form of special-case handling code -- the same kind special handling code that was written for the stock wheels would need to be duplicated to work with these wheels.  Without looking at MJ's stock wheel interop code, I would wager that it would be doable for KSPWheel, but time consuming.  Certainly would be nice at some point though.

Share this post


Link to post
Share on other sites
Posted (edited)

They work alright, they're not without imperfections though. Large rovers, like this one, often bounce with any physicswarp. 

0LJKFlPa.png

There are also struggles in low gravity, lack of traction (not that unexpected here), which ends with the wheels spinning and breaking, I end up just making the wheels really strong so they can be used. 

UBYPQ4i.png

I've only really experimented with the two wheels above, this is the CFC settings I've got currently. 

/roverWheelTR-2L - truck wheels
@PART[wheelMed]
{
	-MODULE[ModuleWheelBase]{}
	-MODULE[ModuleWheelSuspension]{}
	-MODULE[ModuleWheelSteering]{}
	-MODULE[ModuleWheelMotor]{}
	-MODULE[ModuleWheelBrakes]{}
	-MODULE[ModuleWheelDamage]{}
		
	MODULE
	{
		name = KSPWheelBase
		wheelColliderName = WheelCollider
		wheelColliderOffset = 0.125
		wheelRadius = 0.58
		wheelMass = 0.07
		suspensionTravel = 0.125
		loadRating = 3
		minLoadRating = 0.25
		maxLoadRating = 5.5
		maxSpeed = 64
		groundHeightOffset = 0.78
	}
	MODULE
	{
		name = KSPWheelRotation
		wheelMeshName = WheelPivot
		rotationAxis = 1,0,0
	}
	MODULE
	{
		name = KSPWheelSuspension
		suspensionName = SuspensionPivot
		suspensionOffset = -0.10
		suspensionAxis = 0, 1, 0
	}
	MODULE
	{
		name = KSPWheelSteering
		steeringName = SteeringPivot
		maxSteeringAngle = 30
		steeringAxis = 0, 1, 0
	}
	MODULE
	{
		name = KSPWheelMotor
		maxMotorTorque = 3.5
		maxRPM = 2050
	}
	MODULE
	{
		name = KSPWheelBrakes
		maxBrakeTorque = 12
	}
	MODULE
	{
		name = KSPWheelDamage
		wheelName = wheel
		bustedWheelName = bustedwheel
	}
	MODULE
	{
		name = KSPWheelDustEffects
	}
	MODULE
	{
		name = KSPWheelSounds
	}
}

 

/roverWheelS2 - the probe wheels
@PART[roverWheel2]
{
	-MODULE[ModuleWheelBase]{}
	-MODULE[ModuleWheelSuspension]{}
	-MODULE[ModuleWheelSteering]{}
	-MODULE[ModuleWheelMotor]{}
	-MODULE[ModuleWheelBrakes]{}
	-MODULE[ModuleWheelDamage]{}
	MODULE
	{
		name = KSPWheelBase
		wheelColliderName = WheelCollider
		wheelColliderOffset = 0.1939
		wheelRadius = 0.1575
		wheelMass = 0.030
		suspensionTravel = 0.195
		loadRating = 0.3
		minLoadRating = 0.01
		maxLoadRating = 2
		maxSpeed = 11.5
		groundHeightOffset = 0.175
	}
	MODULE
	{
		name = KSPWheelRotation
		wheelMeshName = WheelPivot
		rotationAxis = 1,0,0
	}
	MODULE
	{
		name = KSPWheelSuspension
		suspensionName = SuspensionPivot
		suspensionOffset = -0.18
		suspensionAxis = 0, 1, 0
	}
	MODULE
	{
		name = KSPWheelSteering
		steeringName = SteeringPivot
		maxSteeringAngle = 40
		steeringAxis = 0, 1, 0
		steeringResponse = 10
	}
	MODULE
	{
		name = KSPWheelMotor
		maxMotorTorque = 1.24
		maxRPM = 1300
	}
	MODULE
	{
		name = KSPWheelBrakes
		maxBrakeTorque = 2.5
	}
	MODULE
	{
		name = KSPWheelDamage
		wheelName = wheel
		bustedWheelName = bustedwheel
	}
	MODULE
	{
		name = KSPWheelDustEffects
	}
	MODULE
	{
		name = KSPWheelSounds
	}
}

Apart from in low gravity, and the mechjeb thing, they are an improvement over stock.

Edited by Tw1

Share this post


Link to post
Share on other sites

well, those wheels are just low tech... thats why they brake easily. I dont have bouncing with the wheels either... maybe try kerbal Foundries mod wheels?

Share this post


Link to post
Share on other sites
1 hour ago, Agustin said:

I dont have bouncing with the wheels either... maybe try kerbal Foundries mod wheels?

Part of the bounce is just a part of Unity joint physics, and mostly 'unsolvable' (without resorting to silly stuff like stock's 'locked autostruts').

But yes, part of the bounce is due to the stock models themselves, not being created with Unity physics in mind, with extremely short suspension ranges.  Combine a short suspension range with a high spring value (for a scaled up wheel), and you'll get something that will want to bounce around a bit, esp. when combined with the previously mentioned joint issues.  Creative use of (auto)struts can often mitigate most of the bounce (if caused by joints), and playing with spring/damper settings on the wheels can generally get them into a stable regime from there (if caused by model suspension length).


To note, I don't get bouncing on my craft either.  I've noticed on all the craft where it has been reported, that the craft has wheels mounted out on some skinny / light / long thing with many joints between the wheel and the root part.  All the joints add slop, which causes bouncing when physics interaction starts up.  Most of my craft have the wheels mounted directly to a fuselage / main structural element, which then applies the forces directly to the fuselage; no extra joints = no extra bounce/jitter/slop.

But yeah, the wheel code isn't perfect (I don't think it can be with the limited access to the PhysX side of things that I have), but in most cases it is more reliable and less 'wierd' than the stock wheel code :)

Share this post


Link to post
Share on other sites
Posted (edited)
1 hour ago, Shadowmage said:

I've noticed on all the craft where it has been reported, that the craft has wheels mounted out on some skinny / light / long thing with many joints between the wheel and the root part.  All the joints add slop, which causes bouncing when physics interaction starts up.  Most of my craft have the wheels mounted directly to a fuselage / main structural element, which then applies the forces directly to the fuselage; no extra joints = no extra bounce/jitter/slop.

Huh. Sounds like it's time for me to go download whatever the modern equivalent of the old wielding mod is.  The one thing I still find weird is I don't remember any of this happening with the older versions of KSP's stock wheels. I'd  gladly trade some realism for wheels which actually worked. 

Edited by Tw1

Share this post


Link to post
Share on other sites
1 hour ago, Tw1 said:

The one thing I still find weird is I don't remember any of this happening with the older versions of KSP's stock wheels.

Back in the Pre KSP 1.1 days, these problems didn't exist.  It was only with the upgrade to Unity 5+, where Unity upgraded to a new PhysX version, that these problems started occurring.  PhysX changed their wheel-collider system, and Unity didn't re-implement their end with equivalent features of the old version (if it was even possible).

Unfortunately it isn't even a 'KSP' problem, but one that exists in the game engine and its use of the physics library; it is not a problem caused by KSP code, nor is it one that can be solved by KSP code.

Share this post


Link to post
Share on other sites
3 hours ago, Shadowmage said:

But yes, part of the bounce is due to the stock models themselves, not being created with Unity physics in mind, with extremely short suspension ranges.  Combine a short suspension range with a high spring value (for a scaled up wheel), and you'll get something that will want to bounce around a bit, esp. when combined with the previously mentioned joint issues.  Creative use of (auto)struts can often mitigate most of the bounce (if caused by joints), and playing with spring/damper settings on the wheels can generally get them into a stable regime from there (if caused by model suspension length).


To note, I don't get bouncing on my craft either.  I've noticed on all the craft where it has been reported, that the craft has wheels mounted out on some skinny / light / long thing with many joints between the wheel and the root part.  All the joints add slop, which causes bouncing when physics interaction starts up.  Most of my craft have the wheels mounted directly to a fuselage / main structural element, which then applies the forces directly to the fuselage; no extra joints = no extra bounce/jitter/slop.

But yeah, the wheel code isn't perfect (I don't think it can be with the limited access to the PhysX side of things that I have), but in most cases it is more reliable and less 'wierd' than the stock wheel code :)

Re: the stock wheels, or more specifically the Unity VP wheel code: Not 100% sure of this but where their documentation says that piston forces are in newtons.... I think as implemented (again, on the Unity side) that it's actually behaving as an acceleration rather than as a 'force'....

Share this post


Link to post
Share on other sites

One last thing I should report in trying out the stock replacer configs: The big wheel model gets messed up,  might be something to do with the scaling thing.  These I might just leave stock.A7UH8Kh.png

Share this post


Link to post
Share on other sites
13 minutes ago, Tw1 said:

One last thing I should report in trying out the stock replacer configs: The big wheel model gets messed up,  might be something to do with the scaling thing.

Thanks for the report.  Indeed -- likely related to the scaling feature and some improper configs for that part.

36 minutes ago, Starwaster said:

Re: the stock wheels, or more specifically the Unity VP wheel code: Not 100% sure of this but where their documentation says that piston forces are in newtons.... I think as implemented (again, on the Unity side) that it's actually behaving as an acceleration rather than as a 'force'....

Yeah, that was about the behaviour I saw when I was testing the Unity WheelCollider functionality when developing KSPWheel.  If you took a rigidbody and configured wheels for it, you could change the mass of the rigidbody and the wheel behavior would not change as expected (e.g. would not change at all) -- the suspension would maintain the same compression even with body mass changes (whereas, if it were newtons, the compression should change with changes to mass).  Which would lead me to believe that they are using some abstracted specification, not using newtons directly, but some body-mass-scaled value;  more of a 'ratio' than an actual specification of a physical force.

That was one of the reasons I decided to roll my own.  When you can't even get physically correct specifications for the 'stock' systems... time to look somewhere else.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.