Change Vehicle direction

Hi!

How can I change the direction in which my vehicle moves along the x-axis? Currently, my car is moving in the wrong direction (backwards), and I want to correct it so that when I give it a command to move, it goes in the desired x-axis direction. Alternatively, can I use negative acceleration to achieve the correct direction of movement?

Hello!
What method are you using? Are you using a python script to drive the servo directly, if so you can use a statement like “cont.move(-Long)” to make the vehicle go backwards. Actually, if you only need movement in one direction, you can check the movement direction setting of your Link, I think it may be set upside down.

1 Like

Thank you!

I am new and trying to learn.

I could tried both if you could explain more for me as beginner to understand. :sweat_smile:

This is the Python script code that i have:

from vcScript import *
import vcVector

def OnRun():
comp = getComponent()
vehicle = comp.getBehaviour(“Vehicle”)

vehicle.clearMove()
vehicle.Acceleration = 300.0  
vehicle.Deceleration = 300.0
vehicle.MaxSpeed = 800.0

point = vcVector.new(149500, -3500, -500)  
vehicle.addControlPoint(point)

Appreciate your help!

from vcScript import *
import vcVector

def OnRun():
  comp = getComponent()
  vehicle = comp.getBehaviour('Vehicle')

  vehicle.clearMove()
  vehicle.Acceleration = 300.0  
  vehicle.Deceleration = 300.0
  vehicle.MaxSpeed = 800.0

  point = vcVector.new(1495, -3500, -500)  
  vehicle.addControlPoint(point)
  signal = comp.findBehaviour("BooleanSignal")
  triggerCondition(lambda:getTrigger()==signal and signal.Value)
  vehicle.rePlan()#remove point
  point = vcVector.new(-1495, 3500, 500)  
  vehicle.addControlPoint(point)

Is this what you want? I think you may not have deleted the points, which will lead to problems such as the addition of multiple vectors.Hope this helps, have a nice day.

I am still confuse…

What i understand is you create a signal to be trigger before re plan the route to -1495 instead of 1495.

Firstly i dont understand why we need to do that since if we just want to re route we can just change the first controlpoint to -1495.

This still does not solve my problem since i want to change my vehicle from driving backward to driving forward, not changing distination :sweat_smile:

Or It is just me who have no clue… Why would i need the boolean signal?

Appreciate your help!

I’m very sorry!
This may not help you, I may understand what you mean, I thought you need to move in the opposite direction after reaching a position, the BOOL signal is what I use to help control the car to move in the opposite direction. In fact, you can check the help manual about Vector, which can help you a lot. Sorry again for not being able to help you. :joy:

1 Like

@WilliamSmith Could you give me some suggestion here?

Vehicle AP, eh? It has been a long time. If I recall, one hack is to modify some orientation like component, node or the vehicle itself because it’s just a visualization and there is trickery. Otherwise, going bananas is one option where the vehicle behavior itself is not responsible for driving backwards rather another system or interpolater. For example, you could probably write a script to move the component along an axis over time to target location, and then give mastership back to the vehicle. I believe the vehicles in eCatalog have property for moving backward but there script takes time to ingest.

My suggestion is tell the vehicle to let go of the wheel and let another script or function take care of it.

1 Like

Is this something you are looking for?
Backwards.vcmx (651.5 KB)

1 Like

Thank you, sound complicated…

I am using import model and gave vehicle behaviour to it. Dont know what i did wrong.

Let see if i will be able to solve this.

I think this is solution i need but it still does not work. Even worse it start changing my vehicle position everytime i reset simulation.

I dont really understand why you set vehicle.OffsetMatrix = None, i try with and without but the result is still the same.

I cant see you use mtx_p as well, could you explain why you create it?

from vcScript import *
import vcVector

def OnRun():
comp = getComponent()
vehicle = comp.getBehaviour(“Vehicle”)

vehicle.clearMove()
vehicle.Acceleration = 3000.0
vehicle.Deceleration = 300.0
vehicle.MaxSpeed = 8000.0
vehicle.Interpolation = 0.8
vehicle.OffsetMatrix = None

m = comp.PositionMatrix
m.rotateRelZ(180)
vehicle.OffsetMatrix = m

point = vcVector.new(200000,0,0,0)
vehicle.addControlPoint(point)

Appreciate if you could help me.