"Save" function doesn't work in a Simulink FMU

3 visualizzazioni (ultimi 30 giorni)
Jon Aztiria
Jon Aztiria il 25 Mag 2022
Risposto: Avadhoot il 23 Gen 2024
I'm creating a Simulink FMU for robot trajectories. The input of my FMU is targetPos, i.e., the target point coordinates (x,y,z) of the robot.
The outputs are:
  • ExitFlag - (not) reachable point
  • config - joint angles of the manipulator
  • info - IK solver details
I'm aiming to save the joint angles of all waypoints in the trajectory, i.e., config in all Simulink iterations. I prefer to do it in .csv for later compatibility, but .mat is also fine. I've included the Save block in Simulink directly connected to config.
I've exported the model as standalone FMU and it's generated succesfully.
Then, I've tested the FMU in ROS 2 with the fmi_adapter, but the .mat is not being generated.
ros2 launch fmi_adapter fmi_adapter_node.launch.py fmu_path:=FMI/Trajectory/RobotMARA_SimulinkFMU_v3.fmu
So, is there an incompatibility with the "Save" block in an FMU? Any work around to solve this problem is welcome.
Thank you,
Jon

Risposte (1)

Avadhoot
Avadhoot il 23 Gen 2024
Hi Jon,
I understand that you are facing difficulties in saving the data from the FMU into a ".mat" file. In environments outside MATLAB, the functions like "save" may not work as expected as they do not have direct access to the file system. This is the reason behind the problem you are facing. Saving the data directly to a file from the FMU is not straightforward. You need to capture the data in the environment in which h the FMU is run and then save the data to a file from that environment. There are a few workarounds around this.
  1. Post process the data in the FMU: Capture the required data while the FMU is running and then save it to a file using the ROS2's file handling capabilities.
  2. Log the data: If the FMU supports it you can log the data and extract it after the simulation.
  3. Use an external environment: Run the FMU in an external environment and then use an external script to save the captured data to a file.
I hope it helps.

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by