Runtime update of waypoints/path in drivingScenario

I want to input " waypoints " directly in runtime to the " drivingScenario " function of Automated Driving System Toolbox.
When I simulate, it runs once for the first pre-defined waypoint and then it says "The simulation is not running. Call restartSimulation to start over."
I used a while loop but it makes several figure plots in different new windows which is annoying and I don't think it would actually work that way.
So how to get input in runtime to move the vehicle/actor?

 Risposta accettata

If you want to control the position/orientation of any specific actor you can set its properties yourself instead of defining a path. If you want to see the changes take effect immediately you can call updatePlots() on the scenario. Otherwise, the changes will render in the plots on the next call to the advance() method.

5 Commenti

Haroon
Haroon il 15 Nov 2017
Modificato: Haroon il 15 Nov 2017
I don't know how to move actor with position. It moves on the waypoints. I have attached the file. It takes waypoint coordinates from USB as input. I want to move it with that input in runtime (x and y only). So how to move it the best way. I am updating the waypoints continuously with it but it doesn't seem the best way.
If you want to have the scenario move actors for you, then you can use path() and advance().
At the moment you've defined only one actor and are interested in moving it yourself.
So, for now, I would do something like:
s = drivingScenario
...
v = vehicle(s);
figure(1);
hAxes = gca;
chasePlot(v,'Parent',hAxes);
while <USB data available>
xpos = <xposition from USB data>
ypos = <yposition from USB data>
yaw = <yaw from USB data in degrees>
v.Position = [xpos ypos 0];
v.Yaw = yaw;
updatePlots(s)
drawnow
end
Nice and simple but somehow it makes another vehicle as well, I dont know why. I used while(1) for the
while <USB data available>
As in image there are at least 2 vehicles...
Your code looks fine for the most part.
A simple thing to try is to close all your windows, then do a "clear all" and try your script again.
Make sure you don't create an actor twice. (You can check to see where this happens by single stepping through your code and looking at the number of actors in the scenario (just look at the Actors property). If you see just one actor, you're good to go. If you see more than one... single step to find where you may have accidentally added an additional actor/vehicle.
Good luck!
-G
Thanks I will look for it and if I got stuck in some big problem again I will probably let you know here. Thank you for the help :)

Accedi per commentare.

Più risposte (0)

Richiesto:

il 14 Nov 2017

Commentato:

il 17 Nov 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by