我试图在ROS中运行一个Simulink FMU,以便在Gazebo进行联合仿真。我已经能够在Python中模拟和验证FMU,但是,当我尝试在ROS中加载它时,我得到了一个错误。
我正在尝试这个问题,问题是ROS无法找到Linux的二进制文件(二进制文件/Linux 64中的fmu_traject.so文件),因为FMU是在Windows 10中导出的,我试图在Ubuntu18.04中加载它。解决方案只是从安装在Ubuntu machine.next命令中的MATLAB-Simulink从这指南导出FMU。在第一航站楼:
source /opt/ros/dashing/setup.bash
cd ~/FMI/Trajectory # The path where the FMU is
ros2 run fmi_adapter fmi_adapter_node __params:=my_params.yaml以防万一,文件"my_parmas.yaml"只包含到FMU的路径:
fmi_adapter_node:
ros__parameters:
fmu_path: '/home/ubuntu1804/FMI/Trajectory/fmu_traject.fmu'在第二航站楼:
source /opt/ros/dashing/setup.bash
ros2 lifecycle set /fmi_adapter_node configure
ros2 lifecycle set /fmi_adapter_node activate在运行ros2 lifecycle set /fmi_adapter_node configure之后,将在终端2中打印以下内容:
Transitioning failed下一个错误出现在终端1中:
[ERROR][FMI2XML] Start attribute is required for this causality, variability and initial combination
[FATAL][FMILIB] Could not change to the DLL directory /tmp/fmi_adapter_DrX8pj/binaries/linux64/
[FATAL][FMILIB] The FMU contains no binary for this platform.
[ERROR] []: Caught exception in callback for transition 10
[ERROR] []: Original error: Creation of dllfmu failed!
[WARN] []: Error occurred while doing error handling.此外,我还测试了如何创建一个启动文件并以以下方式运行它。
source /opt/ros/dashing/setup.bash
cd ~/FMI/Trajectory # The path where the FMU is
ros2 launch SimulinkFMU_launcher.launch.py我在启动文件"SimulinkFMU_launcher.launch.py"下面附加,它完全基于上述指南。
import ament_index_python.packages
import launch
import launch.actions
import launch.launch_description_sources
import launch.substitutions
def generate_launch_description():
# fmu_path = (ament_index_python.packages.get_package_share_directory('fmi_adapter_examples') +
# '/share/DampedPendulum.fmu')
fmu_path = 'FMI/Trajectory/fmu_traject.fmu'
fmi_adapter_description = launch.actions.IncludeLaunchDescription(
launch.launch_description_sources.PythonLaunchDescriptionSource(
ament_index_python.packages.get_package_share_directory(
'fmi_adapter') + '/launch/fmi_adapter_node.launch.py'),
launch_arguments={'fmu_path': fmu_path}.items())
description = launch.LaunchDescription()
description.add_action(fmi_adapter_description)
return description这是我在启动文件中获得的日志:
[INFO] [launch]: All log files can be found below /home/ubuntu1804/.ros/log/2022-04-27-09-24-45-820715-ubuntu-13445
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [fmi_adapter_node-1]: process started with pid [13462]
[fmi_adapter_node-1] [ERROR] []: Caught exception in callback for transition 10
[fmi_adapter_node-1] [ERROR] []: Original error: Given FMU file 'FMI/Trajectory/fmu_traject.fmu' not found or cannot be read!
[fmi_adapter_node-1] [WARN] []: Error occurred while doing error handling.
[ERROR] [launch_ros.actions.lifecycle_node]: Failed to make transition 'TRANSITION_CONFIGURE' for LifecycleNode '/fmi_adapter_node'发布于 2022-05-02 06:20:01
问题是ROS无法找到Linux的二进制文件(二进制文件/Linux 64中的fmu_traject.so文件),因为FMU是在Windows 10中导出的,我试图在Ubuntu18.04中加载它。解决方案只是从安装在Ubuntu机器上的导出FMU。
https://stackoverflow.com/questions/72024837
复制相似问题