Roadrunner Prop/Object coordinates and values in MATLAB/Simulink

3 views (last 30 days)
Hello, I've been working on Roadrunner co-simulation with MATLAB/Simulink.
I've been wondering if there's a way to extract to MATLAB/Simulink the properties such as the coordinates of a prop/object from a Roadrunner Scene, or a even better, a Scenario. I know it's already possible to get from a Roadrunner Scenario to MATLAB/Simulink the values such as Pose and Velocity of an Actor and trough Simulink lane values and such, but is there a way to get for example the coordinates of say a Stop Sign that's inside a Scene or a Scenario?
Thanks in advance,
Edward

Answers (1)

Ayush
Ayush on 27 Dec 2023
To export the coordinates of prop/object from a Roadrunner Scene you may follow the similar workflow described here:
  • Export to OpenDRIVE or OpenSCENARIO: OpenDRIVE (.xodr) or OpenSCENARIO (.xosc) file contain information about the road network and the traffic scenario, respectively. Props like stop signs are usually part of the static environment and may be included in the OpenDRIVE description
% Read the OpenDRIVE XML file into MATLAB
xodrData = xmlread('MyRoadNetwork.xodr');
  • Parse the Exported File: After exporting the scene or scenario, you can parse the resulting file in MATLAB to extract the coordinates of the stop sign. This would involve writing a script to read the XML structure of the OpenDRIVE or OpenSCENARIO file and locate the relevant information.
% Find all 'object' elements (assuming stop signs are stored as objects)
objects = xodrData.getElementsByTagName('object');
  • Loop through all the object to find 'stop signs':
% Loop through all objects to find stop signs
for k = 0:objects.getLength-1
thisObject = objects.item(k);
% Check if this object is a stop sign
if strcmpi(thisObject.getAttribute('type'), 'sign') && ...
strcmpi(thisObject.getAttribute('subtype'), 'stop')
% Get the stop sign's coordinates
% Note: The actual attributes to check and how to extract the coordinates
% will depend on the OpenDRIVE format and how RoadRunner exports it
xPos = str2double(thisObject.getAttribute('x'));
yPos = str2double(thisObject.getAttribute('y'));
zPos = str2double(thisObject.getAttribute('z'));
% Display or store the coordinates
disp(['Stop sign found at: ', num2str([xPos, yPos, zPos])]);
end
end
You may refer to documention for more information about the structure of OpenDriveAssetData.xml:
  1. https://www.mathworks.com/help/roadrunner/ug/convert-asset-data-between-roadrunner-and-asam-opendrive.html#mw_ca168795-020e-4d77-aac3-0169b88a2784
Thanks,
Ayush Jaiswal

Community Treasure Hunt

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

Start Hunting!