“chasePlot” doesn't show ego vehicle

2 views (last 30 days)
why the following code did not show egovhicle? I try to set chasePlot propertites ViewLocation to larger than default,but it still can't show egovhicle? how can i fixt it?(run in R2022a)
scenario = drivingScenario("SampleTime",0.01,"StopTime",3);
roadNetwork(scenario,"OpenStreetMap","my_openstreetmap_export.xml");% openstreetmap xml file see attachment
egovhicle = vehicle(scenario,ClassID=1);
egopath = [-133,-388,0;-98,-266,0];
egospeed = 30;
smoothTrajectory(egovhicle,egopath,egospeed);
chasePlot(egovhicle)

Accepted Answer

Adam Danz
Adam Danz on 19 Jul 2022
Edited: Adam Danz on 19 Jul 2022
chasePlot is outside my area of expertise but I did some digging found that if you change the ViewLocation of the scene then your vehicle comes into view.
The default ViewLocation is behind the actor's center at 2.5x the length of the actor. Your vehicle length is 4.7 but for whatever reason, the viewLocation needs to be back even further. This value worked.
chasePlot(egovhicle,'ViewLocation', [-32,0])
This may indicate that there's something not right with your scene or vehicle properties or that there is a bug. If you think there's a bug, please contact tech support and supply your code and data file. Contact Us - MATLAB & Simulink
It may be helpful to trouble shoot by plotting the scene with a top-down view
% Look at a bird's eye view to see where the vehicle is
plot(scenario)
% It's a large scene which makes the vehicle small, zoom in to the vehicle
xlim([-190 -90])
ylim([-440, -350])
  1 Comment
Brandon Ballard
Brandon Ballard on 23 May 2023
Similar Problem occured when using the chasePlot after going from Matlab 2021a to Matlab 2023a. Scenario created fine but visualisation for the car patch or mesh did not appear for the duration of advancing the scenario. When changing the viewing angle between scenario advances the patch appeared in the correct location but the viewing angle would reset after advancing the scenario and it would disappear again.
Code worked fine in Matlab 2021a but does not work correctly in 2023a. After changing the viewing location of the camera chasing the vehicle to [-32, 0] the patch reappears. May be related to the dimensions of the road since the code being run was a 3 lane motorway with lane widths of 3.65m on a straight path. The standard example for the chasePlot works fine so it seems that for some road/lane specifications the Viewing Location must be changed.

Sign in to comment.

More Answers (0)

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!