Are ROS2 namespaces fully supported by Matlab/simulink?

조회 수: 2 (최근 30일)
Diego
Diego 2024년 5월 13일
답변: Diego 2024년 5월 13일
I'm currently working with ros2 nodes generated from simulink, and I need several instances of these nodes with different names running in the same network.
Using Humble, R2023b and Ubuntu 22.04 I don't need the workaround used in this previous question to launch each node.
However, the namespace is only applied to the node name, not to the topics.
Is it a bug? Or is this functionality still in development?
Just in case, I add the python launch file:
from launch import LaunchDescription
from launch_ros.actions import Node
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
def generate_launch_description():
# Declare the namespace launch argument
namespace = DeclareLaunchArgument(
'car_namespace',
default_value='kitt',
description='Namespace for the ROS2 node'
)
# Define the launch value for the namespace
namespace_arg = LaunchConfiguration('car_namespace')
# Launch the ROS2 node with the specified namespace, package, and executable
node = Node(
package='car_control_system',
executable='CAR_CONTROL_SYSTEM',
namespace=namespace_arg
)
return LaunchDescription([
namespace,
node
])

채택된 답변

Diego
Diego 2024년 5월 13일
I have the answer, and it happens the same in some other ros2 codes, like the ros_gz_bridge:
If you declare your topics starting by slash, they won't be affected by namespaces.
Now that I changed my topic names so that they do not start by slash, it works perfectly.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 ROS Network Access in Simulink에 대해 자세히 알아보기

태그

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by