Space Engineers

Space Engineers

DAS - Driver Assisting System
This topic has been locked
£6lbs._onion 18 Aug, 2021 @ 10:12am
[SOLVED!] "Sunbathing seal" Problem with Vehicle + Trailer (all axis hitch) setup.
Issue:
  • When trailer Suspensions control are given to the script, the main vehicle's Rear Suspensions are significantly weaken - results in the whole setup looking like what I like to call "Sunbathing Seal" (hence the title.)

Fix tried:
Originally posted by author:
@Λlyx's Van the script has problems with pitch-free hinges. If you can leave with static strength on trailer wheels I can suggest the script edits:
find the line:
if(Math.Abs(UserInput.AD) < 0.2) // !!workaround: steering bug
replace it with:
if(Math.Abs(UserInput.AD) < 0.2 && !suspension.IsSubgrid) // !!workaround: steering bug

Working Fix
Originally posted by Wanderer_308:
All right, i come with alternative approach, instead of finding a workaround for an issue, we will (or try to) fix it. Scrap all previous edits and do this:
find code:
suspension.WeightDistributionRatio=Math.Abs((suspension.WheelPositionAgainstCoM.Z-frontHalfZ)/wheelsBaseZ*weightRearRatio);
else
suspension.WeightDistributionRatio=Math.Abs((rearHalfZ-suspension.WheelPositionAgainstCoM.Z)/wheelsBaseZ*weightFrontRatio);
replace it with
suspension.WeightDistributionRatio=Math.Abs(((wheelsBaseZ-suspension.WheelPositionAgainstCoM.Z)/wheelsBaseZ)*weightFrontRatio);
else
suspension.WeightDistributionRatio=Math.Abs(((wheelsBaseZ+suspension.WheelPositionAgainstCoM.Z)/wheelsBaseZ)*weightRearRatio);
Those should redistribute strength across all wheels, more strength closer to CoM, less to the periphery. Test it and say how is it going. I wanted to change the formula a long time ago, even did a math model at work, but forgot it there.


Result:
- RESOLVED!
Last edited by £6lbs._onion; 21 Aug, 2021 @ 2:30pm
< >
Showing 1-13 of 13 comments
Wanderer_308  [developer] 18 Aug, 2021 @ 10:42am 
You haven't forgot to set the strength of the trailer wheels manually in the terminal, right?
£6lbs._onion 18 Aug, 2021 @ 11:26am 
I did set them up like how I would like them to be before recompiling the script

The same problem occurs as if I didn't implement your fix code.

And it's the rear suspensions on the main grid that's having the weaken strength problem
£6lbs._onion 18 Aug, 2021 @ 11:31am 
I should have taken some picture to better show what I mean, but please bear with me here.

All grids are Large-Grid.
- Main Vehicle: 4 Suspensions - 2 Front, 2 Rear (≤ the pair I'm having issues with)
- Trailer: 4 Suspensions - all situated to the Rear (in a sense like an irl semi-truck Trailer)
Last edited by £6lbs._onion; 18 Aug, 2021 @ 12:46pm
£6lbs._onion 18 Aug, 2021 @ 11:36am 
I realise after posting the above comment that I do have something to visually show what I described :p

The current setup I have is more finalised than what is shown in the video, but they share the same design.

https://youtu.be/XDNd5oCy4eg
Wanderer_308  [developer] 18 Aug, 2021 @ 3:03pm 
I see. It will take more edits than i thought. Let me think...
Wanderer_308  [developer] 18 Aug, 2021 @ 3:47pm 
All right, try this:
locate the line:
weightsSum += suspension.WeightDistributionRatio;
and add the code before it, so it should look like:
if(!suspension.IsSubgrid)
weightsSum += suspension.WeightDistributionRatio;
find lines
rearHalfZ = Math.Max(rearHalfZ, suspension.WheelPositionAgainstCoM.Z);
frontHalfZ = Math.Min(frontHalfZ, suspension.WheelPositionAgainstCoM.Z);
and add the code before it, so it should look like:
if(!suspension.IsSubgrid)
{
rearHalfZ = Math.Max(rearHalfZ, suspension.WheelPositionAgainstCoM.Z);
frontHalfZ = Math.Min(frontHalfZ, suspension.WheelPositionAgainstCoM.Z);
}
keep the previous edit, from first post.
Last edited by Wanderer_308; 18 Aug, 2021 @ 3:48pm
£6lbs._onion 19 Aug, 2021 @ 9:56am 
Tried the extra patch just now.

the suspensions that I'm having issues with is improved by 1% lol (from 9% to 10%).
But now the Fronts strength is also significantly increased - from ~30% to 42%.

I think I'll upload the vehicle up as unlisted so you could take a look yourself if you're willing to.

and thank you for helping thus far
Wanderer_308  [developer] 20 Aug, 2021 @ 1:44pm 
All right, i come with alternative approach, instead of finding a workaround for an issue, we will (or try to) fix it. Scrap all previous edits and do this:
find code:
suspension.WeightDistributionRatio=Math.Abs((suspension.WheelPositionAgainstCoM.Z-frontHalfZ)/wheelsBaseZ*weightRearRatio);
else
suspension.WeightDistributionRatio=Math.Abs((rearHalfZ-suspension.WheelPositionAgainstCoM.Z)/wheelsBaseZ*weightFrontRatio);
replace it with
suspension.WeightDistributionRatio=Math.Abs(((wheelsBaseZ-suspension.WheelPositionAgainstCoM.Z)/wheelsBaseZ)*weightFrontRatio);
else
suspension.WeightDistributionRatio=Math.Abs(((wheelsBaseZ+suspension.WheelPositionAgainstCoM.Z)/wheelsBaseZ)*weightRearRatio);
Those should redistribute strength across all wheels, more strength closer to CoM, less to the periphery. Test it and say how is it going. I wanted to change the formula a long time ago, even did a math model at work, but forgot it there.
Last edited by Wanderer_308; 20 Aug, 2021 @ 1:45pm
£6lbs._onion 21 Aug, 2021 @ 1:53pm 
Oh my... It functions 𝒃 𝒆 𝒂 𝒖 𝒕 𝒊 𝒇 𝒖 𝒍 𝒍 𝒚 !
Just as I had hoped for and even more! :D
It can now climbs 45 degree grade with ease, even when starting mid way up, without thrusters support!

Some more questions:
- Since this type of fix is based on main CoM, it should function as normal for any setup, right? Be it single body system or multi-body system (i.e trailer convoy)?

Or this fix is only specific for my case? (If it is, I'm even more grateful)

- Permission to upload showcase video of the patch? :P

Wanderer_308  [developer] 21 Aug, 2021 @ 2:50pm 
Originally posted by Λlyx's Van:
- Since this type of fix is based on main CoM, it should function as normal for any setup, right? Be it single body system or multi-body system (i.e trailer convoy)?
Not really. Multi-body has more complex physical behavior than the single rigid body, since it has multiple points of reaction, and calculating them all is a nontrivial task. My formula is designed for rigid body rovers, it sorta works шер trailers too because one joint brings little error to the whole system, but the more there would be trailers the more error would be noticeable.
Originally posted by Λlyx's Van:
- Permission to upload showcase video of the patch? :P
Sure you can showcase it, I would be glad to any video featuring my script. Also, I think to make this fix official and upload an update to my script in not so distant future. Problems with trailers were reported for a long time now.
£6lbs._onion 21 Aug, 2021 @ 4:33pm 
I see, basically the script should run fine as long as things are kept within practical scale then.

And thank you for the greenlight. As well as thank you for everything :D :selike:
£6lbs._onion 21 Aug, 2021 @ 5:33pm 
https://youtu.be/v9lK6hwCd2k

here's the video showing the patch in action, it's just me driving around terrain with the script running lel
< >
Showing 1-13 of 13 comments
Per page: 1530 50