How to move vehicle using process statements?


I want to be able to use process statements to move a vehicle. The problem is, I can’t get the program to wait for the vehicle to get to the destination before moving to the next statement. The result of this is that the program is executed almost instantaneously and the vehicle moves directly to the last control point (added by the last statement in the program). I wrote this code in a PythonProcessHandler script and it is executed by my process statements (I also attached the code in a .txt file):

I also tried a different approach, using signals, the following way:

  • the OnStatementExecute function from the process handler is executed, it sends a signal containing an integer, via the IntegerSignal signal; after that, execution is suspended using suspendRun
  • at the same time (I guess), the OnRun function in a python script makes a connection between itself and IntegerSignal
  • another function in the same script, called OnRun1, is called whenever the IntegerSignal is modified; this function moves the vehicle to a point (the point is found using the integer)
  • also in this function, the OnFinalDestinationReached property of the vehicle is set to a function p
  • function p modifies StringSignal signal to ‘Done’, causing the the OnStatementExecute to resume execution - and since there’s no more lines in OnStatementExecute, the execution stops and the new statement is executed

This works in the sense that each statement is executed only after the vehicle has reached the destination specified in the previous statement, but there’s a problem. I don’t know why, but after each statement, there’s a pause. Not just that, but THE PAUSE IS INCREASINGLY LARGER. The vehicle goes to the first point, after which it pauses for 10 sec. After that, it goes to the second point, where it pauses for 23 seconds and so on… it takes about 14 hours to get to point 13.

You can find the code for the PythonScript and for the PythonProcessHandler in the images below and in files 2 and 3, respectively.

I’m not interested in an explanation for this behaviour as much as I am interested in finding a way to use a statement to tell a vehicle to go to a point, and have the next statement (of any type) for that to complete.

Any suggestion/advice will be much appreciated
Thank you!

code.rar (1.4 KB)

1 Like