How do I create "Junction ID" & "Road ID" in RoadRunner?
Show older comments
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
Umar
on 18 Jul 2024
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.
예은
on 18 Jul 2024
Umar
on 18 Jul 2024
Edited: Angelo Yeo
on 18 Jul 2024
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.
예은
on 18 Jul 2024
Umar
on 18 Jul 2024
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.
예은
on 18 Jul 2024
Umar
on 18 Jul 2024
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.
예은
on 19 Jul 2024
Umar
on 19 Jul 2024
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.
Accepted Answer
More Answers (0)
Categories
Find more on Simulink 3D Animation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!