Home Game Development 2nd – How can I transfer a car utilizing pace and steering angle?

2nd – How can I transfer a car utilizing pace and steering angle?

0
2nd – How can I transfer a car utilizing pace and steering angle?

[ad_1]

I wish to drive a car in x and y coordinate space with vary from (0,0) to (6000,5000). I’m utilizing Visible Parts (utilizing Python API).

On enter I’ve pace knowledge and steering angle of wheels from Simulink. For instance pace of 30 (0.25 m/sec) with the steering angle of wheels from 35 to -35.

I can use one thing like x = pace * COS( steeringAngle ) and y = pace * SIN( steeringAngle ) whereas including up the values of x and y collectively respectively for every loop.

However the issue is it goes in a single course. If the car flip and involves space under the worth of present x and y. I do not know the best way to really get the precise x and y worth when the flip is a lot that it goes to lowered values of x and y. An idea picture is hooked up. Anybody is aware of the best way to remedy this?

Right here is my code:

Velocity= [1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000] #Incoming Velocity
  Angle= [0,0,0,10,0,0,-20,-20,0,35,35,35,35,35,35,35,35] #Incoming Angle
  merchandise = app.findComponent('Ball') #Discover part in VC
  delay(0.1)

  newposition = [10,2500,0,90,0,180] #New place array
  x = newposition[0]
  y = newposition[1]
  z = newposition[2]
  w = newposition[3]
  p = newposition[4]
  r = newposition[5]   #wpr is yaw, pitch, roll
  Xold=0
  Yold=2500
  Rold=0     #retailer x y and r

  for s, a in zip(Velocity, Angle):        #get values from array
    delay(1)
    print "(Velocity, Angle) ->",(s, a)
    x=s
    y=Yold
    r=a         #simply retailer

    rad=math.radians(a)
    x=math.cos(rad)*s
    y=math.sin(rad)*s           #convert to radians

    Xold=Xold+x
    Yold=Yold+y
    Rold=Rold+r              #add to prev worth
    x=Xold
    y=Yold
    r=Rold
    print x,y,r

    mtx = merchandise.PositionMatrix         #get place of BALL
    mtx.P = vcVector.new(x,y,z)   #Place
    mtx.WPR = vcVector.new(w,p,r) #Orientation as yaw,pitch,roll
    merchandise.PositionMatrix = mtx             #retailer new location
    merchandise.replace()
    app.render()

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here