How do I create "Junction ID" & "Road ID" in RoadRunner?

I am using RoadRunner R2024a right now, and I want to assign road IDs to the roads I generate and junction IDs to the junctions.
If you look at the link below,
at 4:42, you can see junction IDs and road IDs in the attributes.
Even if I follow the video exactly, nothing appears in my attributes.
So I looked at the answer of other person who asked similar question.
It says I have to buy matlab and automated driving toolbox, but that costs too much money.
I just want to add something simple like an ID to the attributes.
Is there really no way other than buying matlab and the toolbox?

9 Comments

Hi 예은,
You mentioned in your post, “ It says I have to buy matlab and automated driving toolbox, but that costs too much money. I just want to add something simple like an ID to the attributes. Is there really no way other than buying matlab and the toolbox?”
There is an alternative approach, create a custom script within RoadRunner that generates unique IDs for roads and junctions and then display them in the attributes. Then, customize your workflow within RoadRunner.
This should help you get started with your project now.
Hello Umar.
Thank you sincerely for your response.
Yes, I was indeed looking for the alternative approach you mentioned.
If I create a custom script and apply it to RoadRunner, can I confirm the IDs of the roads and junctions created by RoadRunner in their attributes?
However, how do I create a custom script and apply it to RoadRunner?
I tried to find related methods on the MATLAB website, and searching google, but I couldn't find them and moved on to information about other additional toolboxes or add-ons.
I want to find a way to add attributes without additional costs(if possible).
Can you tell me how to find information about custom scripts?
I apologize as I can't seem to find it no matter how much I search, possibly due to language barriers.
Hi 예은,
No problem, glad to help out. Please see my response to your questions below.
Question: If I create a custom script and apply it to RoadRunner, can I confirm the IDs of the roads and junctions created by RoadRunner in their attributes?
Yes, by creating a custom script in Matlab, you can extract and confirm these IDs. Here's a simple example to demonstrate how you can achieve this:
% Assuming 'road' and 'junction' are the objects containing road and junction attributes
% Accessing the ID of a road
roadID = road.ID;
% Accessing the ID of a junction
junctionID = junction.ID;
disp(['Road ID: ', num2str(roadID)]);
disp(['Junction ID: ', num2str(junctionID)]);
By running this script in Matlab after applying it to RoadRunner, you can verify the IDs of the roads and junctions created by RoadRunner in their attributes.
Question: how do I create a custom script and apply it to RoadRunner?
Write your custom script in Matlab, ensuring it performs the desired operations or functions. Save the script with a meaningful name and the .m extension. In RoadRunner, use the run function to execute your custom script.
Here is an example of a simple custom script in Matlab that multiplies two numbers:
% Custom Script: multiply_numbers.m
num1 = 5;
num2 = 10;
result = num1 * num2;
disp(['The result of multiplying ', num2str(num1), ' and ', num2str(num2), ' is ', num2str(result)]);
After saving this script as multiply_numbers.m, you can run it in RoadRunner using the run function:
run('multiply_numbers.m');
This will execute the script and display the result in the RoadRunner environment.
Hope following these steps will help you get started with your project now. Please let me know if you have any further questions.
Thank you so much.
Your response is really helpful.
I'm sorry, but I seem to be struggling with very basic things.
Regarding the second question, after saving this script as "multiply_numbers.m", you can run it in RoadRunner using the run function:
I have completed saving the "multiply_numbers.m" file, but I don't know how to run this function in RoadRunner.(I can run this in MATLAB, but this is not what you're talking about. Right?)
I really don't know how to connect RoadRunner with MATLAB.
Could you please help me?
Hi 예은,
No problem, glad to find out that you are making progress.Please follow the steps mentioned below regarding your recent post.
Open MATLAB on your system. Add the directory containing your "multiply_numbers.m" file to the MATLAB path using code snippet below. This step ensures that MATLAB can locate and access your function.
addpath('full_path_to_directory_containing_multiply_numbers.m');
Launch RoadRunner on your system, connect to MATLAB using the MATLAB scripting interface using code snippet below. This interface allows you to interact with MATLAB from within RoadRunner.
rr = RoadRunner();
rr.eval('matlab');
Once connected, you can load and run the "multiply_numbers.m" function from MATLAB using code snippet below.
rr.eval('run(''multiply_numbers.m'')');
Please let me know if you have any further questions.
Thank you so much for your kind replies.
I had no issues running up to addpath('full_path_to_directory_containing_multiply_numbers.m');
However, after running RoadRunner, when I execute rr = RoadRunner();, I encounter an error message saying "RoadRunner" is an unrecognized function or variable.
I have purchased a license for RoadRunner and I am using MATLAB version R2024a.
Is there any additional setup required in MATLAB?
Hi 예은,
Sorry, in my comments addpath('full_path_to_directory_containing_multiply_numbers.m'); referring to the words “full path to directory containing multiply numbers” was an example, in order to use addpath() function right way, please refer
https://www.mathworks.com/help/matlab/ref/addpath.html
Once you understand how to use this function correctly, then double-check that the path is accurate and includes the folder where RoadRunner is located, your issue should be resolved. Because the error message you mentioned arises due to incorrect path.
I'm sorry, I think I'm lost here.
Firstly, I didn't use "addpath('full_path_to_directory_containing_multiply_numbers.m');" exactly.
Instead, I used the path where the multiply_numbers.m file is located, which in my case is USERS/documents/MATLAB.
So, if I understand correctly, after moving the multiply_numbers.m file to where RoadRunner is located, I should use the path of multiply_numbers.m inside RoadRunner as the parameter for addpath.
I tried moving multiply_numbers.m to C:\Program Files\RoadRunner R2024a, where RoadRunner is installed, and then executed "addpath" in MATLAB before running "rr = RoadRunner();", but I'm still experiencing the same error.
Did I misunderstand something?
Sorry to bother you with this again.
Hi 예은,
Make sure to include the directory where multiply_numbers.m is located, not just the RoadRunner installation directory.Here is an example of how you can add the path correctly:
addpath('C:\Program Files\RoadRunner R2024a'); % Add RoadRunner directory to the path
addpath('C:\Program Files\RoadRunner R2024a\YOUR_SCRIPT_DIRECTORY'); % Add the directory containing multiply_numbers.m
By adding both the RoadRunner directory and the specific directory containing your script, Matlab will be able to locate and execute multiply_numbers.m successfully.

Sign in to comment.

 Accepted Answer

Angelo Yeo
Angelo Yeo on 19 Jul 2024
Edited: Angelo Yeo on 19 Jul 2024
Showing Junction ID, etc. in the attribute panel shown in the video is a function that can only be seen with RoadRunner's developer license, and is not available to end users as of now.
End users can use the OpenDRIVE Export Preview Tool to view Lane Id, Road Id, and Junction Id.
  1. With any "rrscene" file open, click the OpenDRIVE Export Preview Tool to “Export” it. (There is no need to change any special settings.)
  2. With the OpenDRIVE Export Preview Tool activated, you can check the Id values by clicking on a road, etc.

2 Comments

Thank you Angelo!
This information is really valuable to me as well.
Being able to check, junction, lane, and road IDs is a significant development for me.
However, I've noticed that these IDs change every time I export.
Furthermore, I can't change these IDs.
Is there any way for me to change(set) these IDs?
@예은, I don't think the IDs are changing for every export for me. Can you show your issue with screenshots? Also, can you let me reproduce the issue with given example scenes in RR?
Also, unfortunately, the IDs are shown as "read-only" in Open DRIVE Export Preview Tool. If you want to change this, please reach out to MW technical support and apply for an enhancement reqruest.

Sign in to comment.

More Answers (0)

Products

Release

R2024a

Asked:

on 18 Jul 2024

Commented:

on 19 Jul 2024

Community Treasure Hunt

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

Start Hunting!