Deploying trained agent to run in simulink hardware-in-the-loop (self-balancing robot)

12 views (last 30 days)
I currently have this error:
Toolchain 'Microsoft Visual C++ 2019 v16.0 | nmake (64-bit Windows)' does not contain a build tool named 'Assembler'
I am using r2022a. I am trying to deploy my (DDPG) trained agent on arduino mega board using mathworks user-defined function block but I run into the above error.
I have also tried using the predict block and I get the error:
Error in 'RL_SBR_test1_21/Predict1': Failed to evaluate mask initialization commands.
Caused by: MAT-file C:\RL_SBR\RL_SBR\RL_SBR\savedAgents\Agent1780.mat does not contain a valid SeriesNetwork, DAGNetwork, dlnetwork, yolov2ObjectDetector, yolov3ObjectDetector, yolov4ObjectDetector, ssdObjectDetector or pointPillarsObjectDetector object.
Although I am able to simulate the mat file:
load Agent1780.mat
simOpts=rlSimulationOptions('MaxSteps',1000);
xpr=sim(env,saved_agent,simOpts);
I will appreciate any feedback.

Answers (1)

Abhishek Chakram
Abhishek Chakram on 16 Feb 2024
Edited: Abhishek Chakram on 16 Feb 2024
Hi Justus Nwoke,
It looks like you are encountering the error message "Toolchain 'Microsoft Visual C++ 2019 v16.0 | nmake (64-bit Windows)' does not contain a build tool named 'Assembler'" suggests that the toolchain configured for your MATLAB session does not have an assembler tool included. This might be an issue if you are trying to compile code that requires assembly language compilation.
To resolve this, you can check if the toolchain is set up correctly in MATLAB:
  • Run “mex -setup C++” to configure the C++ compiler.
  • Run “mex -setup C“ to configure the C compiler.
The second error message suggests that the MAT-file you are trying to use with the Predict block does not contain an object that the block recognizes. DDPG agents consist of actor and critic networks, and you might need to extract the underlying neural network from the actor for prediction purposes. Here is an example code for extracting and saving the actor network:
load('Agent1780.mat', 'saved_agent');
actorNetwork = getActor(saved_agent); % Extract the actor network
% Assuming the actor network is a SeriesNetwork or a compatible type
save('ActorNetwork.mat', 'actorNetwork');
Then, use the “ActorNetwork.mat” file with the Predict block.
You can refer to the following documentation to know more about the “getActor” function used: https://www.mathworks.com/help/reinforcement-learning/ref/rl.agent.rlqagent.getactor.html
Best Regards,
Abhishek Chakram

Community Treasure Hunt

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

Start Hunting!