CustomMultiBodyVehicle Joint

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: CustomMultiBodyVehicle Joint

Postby Julio Jerez » Mon Feb 01, 2010 8:18 pm

I really need to fix that bug.

David do you have a test that I can use to fix it for real?
It keep comming back and I want to know why it is happening and fix it.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: CustomMultiBodyVehicle Joint

Postby PJani » Mon Feb 01, 2010 9:01 pm

:shock: The lower is softness coef smaller is explosion...
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
User avatar
PJani
 
Posts: 448
Joined: Mon Feb 02, 2009 7:18 pm
Location: Slovenia

Re: CustomMultiBodyVehicle Joint

Postby Dave Gravel » Tue Feb 02, 2010 2:16 am

Currently no, I can have something ready before the week-end.
My current version is not updated for newton 2.16 and my multibody vehicle code is not same of jointlibrary.
I have start to update my stuff with 2.16, I let's you know when I have something ready.
I can do a demo with same code of your jointlibrary with some options showing when the problem is more present...

See ya later.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 801
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: CustomMultiBodyVehicle Joint

Postby PJani » Sat Mar 06, 2010 3:05 pm

I copied tire code from CustomMultiBodyVehicle Joint and created new Joint named CustomWheel, so i have more control over wheels. I rewrited my python(using boost) interface. And now i load object properties thru INFO parser(Ogre uses something very similar to load .material and other scripts). I load python script to new namespace(dict) when object is created so i don't mess my main namespace.
The result of all this is ->


left and right side is controled with only two keys. When one or both of keys are released the left or right wheels are breaked. When one or both keys are pressed the torque is applied according to side.

I apply torque on wheels using formula
Code: Select all
tork = powerPerWheel / ((2 * Pi) * wheelOmega)

If you look closely at wheels wheels are sliping at start(when wheels have omega 0) . Because when my "caterpillar" is stopped wheel omega is 0 or very close to it. So the number is very large at start and torque is very large at start so i added threshold but doesnt help much(and i cant play with it much because torque for turning have to be very large). This problem is very problematic on sloped terrain, because i cant get much traction because of large torqe. Any idea?

And for some reason when fps is high the breaks are working normal but when fps is low breaks just dont "grab" enough to make nice turn. As in the video at the end.
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
User avatar
PJani
 
Posts: 448
Joined: Mon Feb 02, 2009 7:18 pm
Location: Slovenia

Re: CustomMultiBodyVehicle Joint

Postby Aphex » Sat Mar 06, 2010 4:06 pm

PJani wrote:And for some reason when fps is high the breaks are working normal but when fps is low breaks just dont "grab" enough to make nice turn. As in the video at the end.


Are you updating Newton with a fixed timestep?
Aphex
 
Posts: 144
Joined: Fri Jun 18, 2004 6:08 am
Location: UK

Re: CustomMultiBodyVehicle Joint

Postby Dave Gravel » Sat Mar 06, 2010 4:18 pm

I use similar method here too, my joint is named tire projection and the vehicle is external to this joint.
http://www.youtube.com/user/EvadLevarg? ... p0fFOZH--U

Yes it's better for have more controls and more possible configuration, like tank...

You really need a math for calcul the good torque and update it with the same step use for update newton.
Different gear at different revolution, for get good effect you really need to use real setting for the simulation size.
Exemple you need real mass value or equiv, real mass center ..., real friction ..., real suspenssion ..., real tire mass ..., newton frame rate...
Exemple if the mass center is so low ex: -1 or more, You need more friction or the tire sliding easier.
If you use right mass center for your simulation size, You need to use very low friction because the tire have a lot more grip.
The best is to experiment a lot with it, many thing can make a difference.
The most important is that your value of anything stay on the ratio of your simulation size.
If it's not already the case try to make a gear math system for calcul your torque for every frame dependent by a engine rpm.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 801
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: CustomMultiBodyVehicle Joint

Postby PJani » Sat Mar 06, 2010 7:30 pm

Aphex wrote:
PJani wrote:And for some reason when fps is high the breaks are working normal but when fps is low breaks just dont "grab" enough to make nice turn. As in the video at the end.


Are you updating Newton with a fixed timestep?


yep newton is being updated with fixed timestep. I solved this problem. I don't reset break tork and engine tork to 0.0f.

Dave Gravel wrote:I use similar method here too, my joint is named tire projection and the vehicle is external to this joint.
http://www.youtube.com/user/EvadLevarg? ... p0fFOZH--U

Yes it's better for have more controls and more possible configuration, like tank...

You really need a math for calcul the good torque and update it with the same step use for update newton.
Different gear at different revolution, for get good effect you really need to use real setting for the simulation size.
Exemple you need real mass value or equiv, real mass center ..., real friction ..., real suspenssion ..., real tire mass ..., newton frame rate...
Exemple if the mass center is so low ex: -1 or more, You need more friction or the tire sliding easier.
If you use right mass center for your simulation size, You need to use very low friction because the tire have a lot more grip.
The best is to experiment a lot with it, many thing can make a difference.
The most important is that your value of anything stay on the ratio of your simulation size.


hmm interesting. i will try to see what i could do.

Dave Gravel wrote:If it's not already the case try to make a gear math system for calcul your torque for every frame dependent by a engine rpm.


Hmm for this one i am trying to write math expression for 1 month. :?
the problem becomes problem when i want to have "realistic" (diesel or petrol) engine.
Engine RPM is conditioned by gas factor and rpm of output shaft(if clutch is joined), but i need to have all wheels consistent so they are constraned. And when i "back" calculate shaft rpm then i can calculate engine torque(by engine tork curve) and after that i can distribute torque properly on each wheel!
Complicated? :D Try clutching...in that one i will not try to get in to.
I read every PDF, book, eBook every thing that came to my mind about this.
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
User avatar
PJani
 
Posts: 448
Joined: Mon Feb 02, 2009 7:18 pm
Location: Slovenia

Re: CustomMultiBodyVehicle Joint

Postby JernejL » Sat Mar 06, 2010 7:40 pm

You forgot to add differentials to that :P
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: CustomMultiBodyVehicle Joint

Postby Dave Gravel » Sat Mar 06, 2010 9:06 pm

I have test this method from my script, I have test it with many vehicle types and it give good result for my need.
I have get good result with manual and automatic engine.
This is only a test with script, I have a better implementation under delphi pascal.
If you like to see my newer code, I can post it this week because the new code is at job.

Code: Select all
-- [1] BEGIN 5 speeds engine simulation.
TEngine = class(TOXLuaClass)
function TEngine:Create(hp,mrpm,g1,g2,g3,g4,g5,g6)
  self.hp = hp
  self.maxrpm = mrpm
  self.rpm = 0
  self.curgear = 1
  self.enginetorque = 0                                             
  self.automatic = true
  self.diffratio = 3.6
  self.geareffic = 0.7
  self.accelerator = 0
  self.revo = 0
  self.revores = 0
  self.gears =  {g1,g2,g3,g4,g5,g6}
end

function TEngine:LookupTorque()
  if (self.rpm < 7500) then
    return 390
  end 
  if (self.rpm < 8500) then
    return 390*(1000 - (self.rpm - 7500))*0.001
  else
    return 0
  end 
end

function TEngine:GearShifter()
  if self.automatic then
    if (self.rpm >= 4000) and (self.curgear < 5) and (self.curgear>0) then
      self.curgear = self.curgear + 1
    end 
    if (self.rpm <= 2000) and (self.curgear > 1) then
      self.curgear = self.curgear - 1
    end 
  end   
end     
                                   
function TEngine:DoRpm(tireRad,v,speed)
  local wrsp = (speed / tireRad)
  self.rpm = (wrsp * 60 * self.gears[self.curgear] * self.diffratio / (2.0 * math.pi))
end

function TEngine:PushAccel()
  self.accelerator = self.accelerator + 0.02
  if self.accelerator > 1.0 then
    self.accelerator = 1.0
  end 
end

function TEngine:LeaveAccel()
  self.accelerator = self.accelerator - 0.01
  if self.accelerator < 0 then
    self.accelerator = 0
  end    
end
-- [1] END

function TVehicle:CervoEngine()
  onAccel = false
  gspeed = self:GetSpeed()     
 
  self.engine:DoRpm(tires[0].majorradius ,self,gspeed)
 
  self.engine.revo = self.engine.accelerator
              * self.engine:LookupTorque()
              * self.engine.gears[self.engine.curgear]
              * self.engine.diffratio
              * self.engine.geareffic               

  if self.vtype == CAR4X2 then                                                           
    if IsKeyDown(self.vkleft) then
      if steer < self.maxsteerangle then steer = steer + self.steerratio end 
      self.tireprojection[0]:SetSteerAngle(steer)
      self.tireprojection[3]:SetSteerAngle(steer)
    else
    if IsKeyDown(self.vkright) then
      if steer > -self.maxsteerangle then steer = steer - self.steerratio end   
      self.tireprojection[0]:SetSteerAngle(steer)
      self.tireprojection[3]:SetSteerAngle(steer) 
    else
      if steer>0 then steer = steer -self.steerratio end
      if steer<0 then steer = steer +self.steerratio end 
      self.tireprojection[0]:SetSteerAngle(steer)
      self.tireprojection[3]:SetSteerAngle(steer)       
    end
    if IsKeyDown(self.vkaccel) then
      self.engine:PushAccel()
      self:PushTorque(1,self.engine.revo)
      self:PushTorque(2,self.engine.revo)
      onAccel = true
    else
    if IsKeyDown(self.vkdeccel) then
      self.engine:PushAccel()
      self:PushTorque(1,-self.engine.revo)
      self:PushTorque(2,-self.engine.revo)   
      onAccel = true
    end
  end
  end   
  if self.vtype == CAR2X4 then                                                           
    if IsKeyDown(self.vkleft) then
      if steer < self.maxsteerangle then steer = steer + self.steerratio end 
      self.tireprojection[0]:SetSteerAngle(steer)
      self.tireprojection[3]:SetSteerAngle(steer)
    else
    if IsKeyDown(self.vkright) then
      if steer > -self.maxsteerangle then steer = steer - self.steerratio end   
      self.tireprojection[0]:SetSteerAngle(steer)
      self.tireprojection[3]:SetSteerAngle(steer) 
    else
      if steer>0 then steer = steer -self.steerratio end
      if steer<0 then steer = steer +self.steerratio end 
      self.tireprojection[0]:SetSteerAngle(steer)
      self.tireprojection[3]:SetSteerAngle(steer)       
    end
    if IsKeyDown(self.vkaccel) then
      self.engine:PushAccel()
      self:PushTorque(0,self.engine.revo)
      self:PushTorque(3,self.engine.revo)
      onAccel = true
    else
    if IsKeyDown(self.vkdeccel) then
      self.engine:PushAccel()
      self:PushTorque(0,-self.engine.revo)
      self:PushTorque(3,-self.engine.revo)   
      onAccel = true
    end
  end
  end       
  if self.vtype == CAR4X4 then                                                           
    if IsKeyDown(self.vkleft) then
      if steer < self.maxsteerangle then steer = steer + self.steerratio end 
      self.tireprojection[0]:SetSteerAngle(steer)
      self.tireprojection[3]:SetSteerAngle(steer)
    else
    if IsKeyDown(self.vkright) then
      if steer > -self.maxsteerangle then steer = steer - self.steerratio end   
      self.tireprojection[0]:SetSteerAngle(steer)
      self.tireprojection[3]:SetSteerAngle(steer) 
    else
      if steer>0 then steer = steer -self.steerratio end
      if steer<0 then steer = steer +self.steerratio end 
      self.tireprojection[0]:SetSteerAngle(steer)
      self.tireprojection[3]:SetSteerAngle(steer)       
    end
    if IsKeyDown(self.vkaccel) then
      self.engine:PushAccel()
      self:PushTorque(0,self.engine.revo)
      self:PushTorque(1,self.engine.revo)
      self:PushTorque(2,self.engine.revo)
      self:PushTorque(3,self.engine.revo)
      onAccel = true
    else
    if IsKeyDown(self.vkdeccel) then
      self.engine:PushAccel()
      self:PushTorque(0,-self.engine.revo)
      self:PushTorque(1,-self.engine.revo)
      self:PushTorque(2,-self.engine.revo)   
      self:PushTorque(3,-self.engine.revo)
      onAccel = true
    end
  end
  end
  if self.vtype == MONSTER then 
 
  end
  if self.vtype == BIGRIGS then

  end   
  if self.vtype == TRAILOR then

  end
  if self.vtype == TANK then

  end
  self.engine:LeaveAccel()
  self.engine:GearShifter()
end

function TVehicle:PushTorque(id,val)
  self.tireprojection[id]:SetTorque(val)
end

Exemple:

impreza = TVehicle("")
impreza:LoadFromFile("impreza.3ds")
impreza:AutoSleep(false)
impreza:Position(0,5,0)
impreza:MaterialCollision(0.05,0.4,0.3,0.3)
impreza:NewtonMass(1180)
impreza:CenterMass(0,-0.25,0)
impreza:InitEngine(CAR4X4, 4,1.25,0.9,0.7,0.975,-3)
impreza:InitNewton()
impreza:AddWheelSpring(1.4,-0.6,0.925, 0.225,0.14, 0.05,0.4,1.25,1.25, 40, tiredir,tireup, false, -0.25,0.3,250,12.5,true)
impreza:AddWheelSpring(1.4,-0.6,-0.925, 0.225,0.14, 0.05,0.4,1.25,1.25, 40, tiredir,tireup, false, -0.25,0.3,250,12.5,true)
impreza:AddWheelSpring(-1.35,-0.6,0.925, 0.225,0.14, 0.05,0.4,1.25,1.25, 40, tiredir,tireup, false, -0.25,0.3,250,12.5,true)
impreza:AddWheelSpring(-1.35,-0.6,-0.925, 0.225,0.14, 0.05,0.4,1.25,1.25, 40, tiredir,tireup, false, -0.25,0.3,250,12.5,true)


Good luck with your prj.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 801
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: CustomMultiBodyVehicle Joint

Postby PJani » Sun Mar 07, 2010 3:02 pm

I see you are using lua. If i am right?

Thank you :)
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
User avatar
PJani
 
Posts: 448
Joined: Mon Feb 02, 2009 7:18 pm
Location: Slovenia

Re: CustomMultiBodyVehicle Joint

Postby Dave Gravel » Mon Mar 08, 2010 2:34 am

Yes I have test lua a lot this winter.
The code is not super clean, it's only a old test.
My real project is under delphi pascal.
I have rewrite a better one under pascal but it is at job.
I think this lua code can give to you a good idea of what you need.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 801
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: CustomMultiBodyVehicle Joint

Postby Sash » Mon Mar 29, 2010 7:24 am

I'm allso trying to play with CustomMultiBodyVehicle (2.18) and still cannot pick a good balance between these params: BodyMass, WheelMass, SuspLength, SpringConst, SpringDamper. Can anyone submit a working set as a starting point (or working demo) ?
Sash
 
Posts: 34
Joined: Wed Sep 30, 2009 3:38 am
Location: Novosibirsk

Re: CustomMultiBodyVehicle Joint

Postby Dave Gravel » Mon Mar 29, 2010 3:41 pm

Just to test logical ratio.
Exemple vehicle mass 100 tire mass 1,2,3,4,5 SuspLength is very personal to your tire pos and your request, 0.01 to 1, SpringConst 10, 20 SpringDamper 0.25, 0.5 , 1.0
Exemple vehicle mass 1000 tire mass 10,20,30... SpringConst 80, 100 SpringDamper 1.0, 5.0

You need to do a lot of try and errors before get a good equilibrum between your simulation size, mass and vehicle shape too, because the mass center.
The SpringDamper is very critical, exemple if your vehicle mass is high like 1000 or over and if your tire mass is so low a high damper value can make explode the simulation.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 801
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: CustomMultiBodyVehicle Joint

Postby Sash » Tue Mar 30, 2010 8:01 am

Thanks, that's exactly what I needed.
Sash
 
Posts: 34
Joined: Wed Sep 30, 2009 3:38 am
Location: Novosibirsk

Re: CustomMultiBodyVehicle Joint

Postby Sash » Wed Mar 31, 2010 3:25 pm

BTW, although CustomMultiBodyVehicle(front, up, carBody) created with dVector& front , this vector is not taken in account for GetSpeed() function. F.e. when I create vehicle with dVector front(0,0,1) - it rather shows a side sleep. Not a big problem, but probably should be improved in the future.
Sash
 
Posts: 34
Joined: Wed Sep 30, 2009 3:38 am
Location: Novosibirsk

PreviousNext

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests

cron