안녕하세요. 저는 Turtlebot3 E-Manual의 **Load Multiple TurtleBot3s**를 참고하여 현실 환경에서 여러 대의 터틀봇을 한 remote pc에서 navigation하는 것을 목표로 하고 있습니다.
이를 위해 위의 예제를 참고하여 하나의 터틀봇3 버거에 namespace를 적용하여 bringup을 하였습니다.
$ ros2 launch turtlebot3_bringup robot.launch.py namespace:=tb3_1 # Insert what you want to use as namespace
네비게이션은 .github.com/ROBOTIS-GIT/turtlebot3.git 해당 패키지의 navigation2.launch.py에 namespace를 추가하였습니다.
수정한 navigation2.launch.py
#!/usr/bin/env python3import os
from ament_index_python.packages import get_package_share_directoryfrom launch import LaunchDescriptionfrom launch.actions import DeclareLaunchArgument, IncludeLaunchDescriptionfrom launch.launch_description_sources import PythonLaunchDescriptionSourcefrom launch.substitutions import LaunchConfigurationfrom launch_ros.actions import Node
TURTLEBOT3_MODEL = os.environ[‘TURTLEBOT3_MODEL’]ROS_DISTRO = os.environ.get(‘ROS_DISTRO’)
def generate_launch_description():
namespace = LaunchConfiguration('namespace', default='TB3_1')
use_sim_time = LaunchConfiguration('use_sim_time', default='false')
map_dir = LaunchConfiguration(
'map',
default=os.path.join(
get_package_share_directory('turtlebot3_navigation2'),
'map', 'map.yaml'))
param_file_name = 'burger_tb3_1.yaml'
param_dir = LaunchConfiguration(
'params_file',
default=os.path.join(
get_package_share_directory('turtlebot3_navigation2'),
'param',
param_file_name))
nav2_launch_file_dir = os.path.join(get_package_share_directory('nav2_bringup'), 'launch')
rviz_config_file = LaunchConfiguration(
'rviz_config_file',
default=os.path.join(
get_package_share_directory('turtlebot3_navigation2'),
'rviz', 'nav2_ns_view.rviz')
)
return LaunchDescription([
DeclareLaunchArgument('namespace', default_value=namespace, description='Robot namespace'),
DeclareLaunchArgument('map', default_value=map_dir, description='Full path to map file to load'),
DeclareLaunchArgument('params_file', default_value=param_dir, description='Full path to param file to load'),
DeclareLaunchArgument('use_sim_time', default_value='false', description='Use simulation clock if true'),
DeclareLaunchArgument('rviz_config_file', default_value=rviz_config_file, description='RViz config'),
IncludeLaunchDescription(
PythonLaunchDescriptionSource([nav2_launch_file_dir, '/bringup_launch.py']),
launch_arguments={
'namespace': namespace,
'use_namespace': 'True',
'map': map_dir,
'use_sim_time': use_sim_time,
'params_file': param_dir
}.items(),
),
IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(nav2_launch_file_dir, 'rviz_launch.py')),
launch_arguments={
'use_sim_time': use_sim_time,
'namespace': namespace,
'use_namespace': 'False',
'rviz_config': rviz_config_file,
'log_level': 'warn'
}.items(),
),
])
/bringup_launch.py 부분에 ‘namespace’: namespace, ‘use_namespace’: ‘True’ 를 추가하여 navigation stack에도 namespace가 적용되도록 설정하였고, rviz_launch.py’에도 ‘namespace’: namespace, ‘use_namespace’: 'True’하였는데 적용 시 rviz에서 frame이 나타나지 않아 ‘use_namespace’: ‘False’로 설정하였습니다.
이렇게 하여 실행하면 rviz에서는 frame이 나타나지만 네비게이션 런치파일을 실행했을 때 local costmap과 global costmap에서 scan토픽을 구독하지 않는 문제가 발생하고, TB3_1/map frame_id로 /TB3_1/initialpose를 퍼플리시하여 초기위치를 설정하여도 amcl이 작동하지 않아 map→odom→base_footprint→….에서 map→odom이 생성되지 않았습니다.
이런 문제를 하결하고자 navigation 런치파일에서 불러오는 로봇의 파라미터 .yaml의 amcl, bt_navigator, local_costmap, global_costmap의 ros_parameters에 namespace를 붙여 수정하였고
global_frame: TB3_1/map
robot_base_frame: TB3_1/base_link
odom_topic: /TB3_1/odom
map_server에는 frame_id를 아래와 같이 지정하였지만 여전히 문제는 해결되지 않고 있습니다.
map_server:
ros__parameters:
use_sim_time: False
yaml_filename: "map.yaml"
frame_id: "TB3_1/map"
.rviz파일은 namespace를 적용한 결과가 rviz에 잘 나타나도록 아래와 같이 수정하였습니다.
- Class: rviz_default_plugins/TF
Enabled: true
Frame Timeout: 15
Frames:
All Enabled: false
TB3_1/base_footprint:
Value: true
TB3_1/base_link:
Value: true
TB3_1/base_scan:
Value: true
TB3_1/camera_depth_frame:
Value: true
TB3_1/camera_depth_optical_frame:
Value: true
TB3_1/camera_link:
Value: true
TB3_1/camera_rgb_frame:
Value: true
TB3_1/camera_rgb_optical_frame:
Value: true
TB3_1/caster_back_left_link:
Value: true
TB3_1/caster_back_right_link:
Value: true
TB3_1/imu_link:
Value: true
TB3_1/map:
Value: true
TB3_1/odom:
Value: true
TB3_1/wheel_left_link:
Value: true
TB3_1/wheel_right_link:
Value: true
Tree:
TB3_1/map:
TB3_1/odom:
TB3_1/base_footprint:
TB3_1/base_link:
TB3_1/base_scan:
{}
TB3_1/camera_link:
TB3_1/camera_depth_frame:
TB3_1/camera_depth_optical_frame:
{}
TB3_1/camera_rgb_frame:
TB3_1/camera_rgb_optical_frame:
{}
TB3_1/caster_back_left_link:
{}
TB3_1/caster_back_right_link:
{}
TB3_1/imu_link:
{}
TB3_1/wheel_left_link:
{}
TB3_1/wheel_right_link:
{}
navigation의 터미널 로그는 아래와 같습니다.
rviz2-2] [ERROR] [1760942859.961255804] [rviz2]: Vertex Program:rviz/glsl120/indexed_8bit_image.vert Fragment Program:rviz/glsl120/indexed_8bit_image.frag GLSL link result :
[rviz2-2] active samplers with a different type refer to the same texture image unit
[component_container_isolated-1] [INFO] [1760942859.978919813] [TB3_1.lifecycle_manager_navigation]: Configuring waypoint_follower
[component_container_isolated-1] [INFO] [1760942859.979021415] [TB3_1.waypoint_follower]: Configuring
[component_container_isolated-1] [INFO] [1760942859.986462934] [TB3_1.waypoint_follower]: Created waypoint_task_executor : wait_at_waypoint of type nav2_waypoint_follower::WaitAtWaypoint
[component_container_isolated-1] [INFO] [1760942859.987226956] [TB3_1.lifecycle_manager_navigation]: Configuring velocity_smoother
[component_container_isolated-1] [INFO] [1760942859.987334038] [TB3_1.velocity_smoother]: Configuring velocity smoother
[component_container_isolated-1] [INFO] [1760942859.990065525] [TB3_1.lifecycle_manager_navigation]: Activating controller_server
[component_container_isolated-1] [INFO] [1760942859.990172578] [TB3_1.controller_server]: Activating
[component_container_isolated-1] [INFO] [1760942859.990201622] [TB3_1.local_costmap.local_costmap]: Activating
[component_container_isolated-1] [INFO] [1760942859.990215188] [TB3_1.local_costmap.local_costmap]: Checking transform
[component_container_isolated-1] [INFO] [1760942859.990235126] [TB3_1.local_costmap.local_costmap]: Timed out waiting for transform from TB3_1/base_link to TB3_1/odom to become available, tf error: Invalid frame ID "TB3_1/odom" passed to canTransform argument target_frame - frame does not exist
[component_container_isolated-1] [INFO] [1760942860.490291427] [TB3_1.local_costmap.local_costmap]: Timed out waiting for transform from TB3_1/base_link to TB3_1/odom to become available, tf error: Invalid frame ID "TB3_1/odom" passed to canTransform argument target_frame - frame does not exist
[component_container_isolated-1] [INFO] [1760942860.990324404] [TB3_1.local_costmap.local_costmap]: Timed out waiting for transform from TB3_1/base_link to TB3_1/odom to become available, tf error: Invalid frame ID "TB3_1/odom" passed to canTransform argument target_frame - frame does not exist
...
[component_container_isolated-1] [INFO] [1760942875.203844537] [TB3_1.amcl]: Message Filter dropping message: frame 'TB3_1/base_scan' at time 1760942874.274 for reason 'the timestamp on the message is earlier than all the data in the transform cache'
[component_container_isolated-1] [INFO] [1760942875.302896254] [TB3_1.amcl]: Message Filter dropping message: frame 'TB3_1/base_scan' at time 1760942874.374 for reason 'the timestamp on the message is earlier than all the data in the transform cache'
[component_container_isolated-1] [INFO] [1760942875.400622078] [TB3_1.amcl]: Message Filter dropping message: frame 'TB3_1/base_scan' at time 1760942874.474 for reason 'discarding message because the queue is full'
[component_container_isolated-1] [INFO] [1760942875.490295830] [TB3_1.local_costmap.local_costmap]: Timed out waiting for transform from TB3_1/base_link to TB3_1/odom to become available, tf error: Invalid frame ID "TB3_1/odom" passed to canTransform argument target_frame - frame does not exist
[component_container_isolated-1] [INFO] [1760942875.506691594] [TB3_1.amcl]: Message Filter dropping message: frame 'TB3_1/base_scan' at time 1760942874.574 for reason 'discarding message because the queue is full'
[component_container_isolated-1] [INFO] [1760942875.610002793] [TB3_1.amcl]: Message Filter dropping message: frame 'TB3_1/base_scan' at time 1760942874.684 for reason 'the timestamp on the message is earlier than all the data in the transform cache'
[component_container_isolated-1] [INFO] [1760942875.706476423] [TB3_1.amcl]: Message Filter dropping message: frame 'TB3_1/base_scan' at time 1760942874.784 for reason 'the timestamp on the message is earlier than all the data in the transform cache'
다중 로봇 네비게이션을 위해 단일 로봇에 네임스페이스를 적용하여 navigation을 하는 것부터 시도하고 있지만 아래의 문제로 인해 어떻게 이를 구현해야 할지 모르겠습니다.
- namespace 적용 후에 initialpose 토픽을 어떤 frame_id로 설정해야 하나요?
- 1번을 해결하면 amcl 초기화가 안되는 문제가 해결되는 것인가요?
- 왜 제가 설정한 값으로 실행하면 global costmap과 local costmap은 scan토픽을 구독하지 않는 것인가요?
- bringup에 namespace를 적용한 후 .rviz 파일과 로봇 파라미터 파일 .yaml을 어떻게 수정하는 것이 적절한가요?
답변해주시면 감사하겠습니다.