Effacer les filtres
Effacer les filtres

Change Simulink Working Directory when using Road Runner.

4 vues (au cours des 30 derniers jours)
Samuel Burrows
Samuel Burrows le 21 Nov 2023
Modifié(e) : Ayush le 27 Nov 2023
I have looked everywhere and can't seem to find any solutions for it.
I am currently using Simulink to model the behavior of some actors in Road Runner. I believe my model works but I can't seem to use it in Road Runner. When I run the Road Runner Scenario/Simulation in Road Runner, it loads up Matlab like it's going to run the model with my scenario/simulation but then it crashes. It's barely on screen long enough for me to get a screenshot of the error it does throw.
The model is just a basic model that pulls the actors stats (pose, velocity, ID) and passes them to a script I wrote and then passes them back to the Road Runner scenario. It doesn't alter this data in anyway.
The error it throws:
I'm not worried about the warnings, I know how to fix them and since this screenshot I have. I'm just curious as to how to change teh working directory of this simulink model that's called through Road Runner. All my Road Runner files are from my project folder and the simulink model is in a working directory with no relation to the Road Runner bin. I'm just confused as to how and why it defaulted to the working directory it has.

Réponse acceptée

Ayush
Ayush le 27 Nov 2023
Modifié(e) : Ayush le 27 Nov 2023
Hi Samuel,
I understand that you want to change your working directory to run your Simulink model responsible for the behaviour of some actors in Road Runner. Based on the screenshot shared by you, it seems that the directory you are trying to access or write into is write-protected which may lead to the crash.
In general, MATLAB will default to the last working directory that was used or the directory where the session was initiated. Here are some possible workarounds to ensure that Simulink uses the correct working directory when using Road Runner:
1. Try “Run As Administrator” for MATLAB: To overcome the issue of not having write access to a particular directory as shown in the screenshot attached. Start the MATLAB software as an administrator to override the permission settings and enable write access to the “Road Runner R2023b“ directory.
2.Set the working directory in your script: If you have a script that initializes the simulation, you can set the working directory there using the `cd` (change directory) command in MATLAB. Here is a code snippet for your reference:
cd('C:\path\to\your\project\folder');
3.Use the `startup` script: If there is a “startup.m” script in the directory where MATLAB is installed or in your MATLAB user path, it would execute this before running the simulation or operation. You can leverage this script to run certain commands to set the working directory desired in your project. Here is a code snippet for your reference:
if exist('C:\path\to\your\project\folder', 'dir')
cd('C:\path\to\your\project\folder');
end
Please refer to the below documentation to know more about the ‘startup’ script and its usage:
4.Modify the Simulink model properties & callbacks: By leveraging the callbacks of you Simulink model, you can execute the ‘cd’ command before the simulation starts to ensure that the model is running on the desired working directory. The callbacks that you can use for adding the cd command can be ‘PreLoadFcn’, ‘PostLoadFcn’, ‘InitFcn’ and ‘StartFcn’. Please refer to the below documentation to know more about the ‘Model Callbacks’:
5.Check the Road Runner settings: While installing Road Runner in your system, you get a license file upon activation, this file should be saved in a folder which is write-accessible. Try changing the location of the file to a different location in your system to avoid the application crashing upon start. Please refer to the below documentation to know more about the installation of Road Runner:
6.Use absolute paths: As a last workaround, you could modify your model and scripts to use absolute paths when loading and saving data, so that they do not depend on the current working directory.
Hope it helps,
Regards,
Ayush Misra

Plus de réponses (0)

Catégories

En savoir plus sur Introduction to Installation and Licensing dans Help Center et File Exchange

Produits


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by