鱼香ROS社区
    • 版块
    • 最新
    • 未解决
    • 已解决
    • 群组
    • 注册
    • 登录
    紧急通知:禁止一切关于政治&VPN翻墙等话题,发现相关帖子会立马删除封号
    提问前必看的发帖注意事项: 社区问答规则(小鱼个人)更新 | 高质量帖子发布指南

    第十章fishbot建图rviz2的fixed frame报错,无法显示地图

    已定时 已固定 已锁定 已移动
    ROS 2相关问题
    ros2 第十章 rviz2
    3
    9
    772
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • 4417555354
      头怎么还不秃啊
      最后由 编辑

      fishbot_cartographer/cartographer.launch代码如下

      
      import os
      from launch import LaunchDescription
      from launch.substitutions import LaunchConfiguration
      from launch_ros.actions import Node
      from launch_ros.substitutions import FindPackageShare
      
      
      def generate_launch_description():
          # 定位到功能包的地址
          pkg_share = FindPackageShare(package='fishbot_cartographer').find('fishbot_cartographer')
          
          #=====================运行节点需要的配置=======================================================================
          # 是否使用仿真时间,我们用gazebo,这里设置成true
          use_sim_time = LaunchConfiguration('use_sim_time', default='true')
          # 地图的分辨率
          resolution = LaunchConfiguration('resolution', default='0.05')
          # 地图的发布周期
          publish_period_sec = LaunchConfiguration('publish_period_sec', default='1.0')
          # 配置文件夹路径
          configuration_directory = LaunchConfiguration('configuration_directory',default= os.path.join(pkg_share, 'config') )
          # 配置文件
          configuration_basename = LaunchConfiguration('configuration_basename', default='fishbot_2d.lua')
          rviz_config_dir = os.path.join(pkg_share, 'config')+"/cartographer.rviz"
          print(f"rviz config in {rviz_config_dir}")
      
          
          #=====================声明三个节点,cartographer/occupancy_grid_node/rviz_node=================================
          cartographer_node = Node(
              package='cartographer_ros',
              executable='cartographer_node',
              name='cartographer_node',
              output='screen',
              parameters=[{'use_sim_time': use_sim_time}],
              arguments=['-configuration_directory', configuration_directory,
                         '-configuration_basename', configuration_basename])
      
          cartographer_occupancy_grid_node = Node(
              package='cartographer_ros',
              executable='cartographer_occupancy_grid_node',
              name='cartographer_occupancy_grid_node',
              output='screen',
              parameters=[{'use_sim_time': use_sim_time}],
              arguments=['-resolution', resolution, '-publish_period_sec', publish_period_sec])
      
          rviz_node = Node(
              package='rviz2',
              executable='rviz2',
              name='rviz2',
              arguments=['-d', rviz_config_dir],
              parameters=[{'use_sim_time': use_sim_time}],
              output='screen')
      
          #===============================================定义启动文件========================================================
          ld = LaunchDescription()
          ld.add_action(cartographer_node)
          ld.add_action(cartographer_occupancy_grid_node)
          ld.add_action(rviz_node)
      
          return ld
      

      fishbot_description/gazebo.launch代码如下

      import os
      from launch import LaunchDescription
      from launch.actions import ExecuteProcess
      from launch_ros.actions import Node
      from launch_ros.substitutions import FindPackageShare
      
      
      def generate_launch_description():
          robot_name_in_model = 'fishbot'
          package_name = 'fishbot_description'
          urdf_name = "fishbot_base.urdf"
      
          ld = LaunchDescription()
          pkg_share = FindPackageShare(package=package_name).find(package_name) 
          urdf_model_path = os.path.join(pkg_share, f'urdf/{urdf_name}')
          gazebo_world_path = os.path.join(pkg_share, 'world/fishbot.world')
      
          # Start Gazebo server
          start_gazebo_cmd =  ExecuteProcess(
              cmd=['gazebo', '--verbose','-s', 'libgazebo_ros_init.so', '-s', 'libgazebo_ros_factory.so',gazebo_world_path],
              output='screen')
      
          # Launch the robot
          spawn_entity_cmd = Node(
              package='gazebo_ros', 
              executable='spawn_entity.py',
              arguments=['-entity', robot_name_in_model,  '-file', urdf_model_path ], output='screen')
      
          ld.add_action(start_gazebo_cmd)
          ld.add_action(spawn_entity_cmd)
      
      
          return ld
      

      fishbot_description/display_rviz2.launch代码如下

      import os
      from launch import LaunchDescription
      from launch.substitutions import LaunchConfiguration
      from launch_ros.actions import Node
      from launch_ros.substitutions import FindPackageShare
      
      
      def generate_launch_description():
          package_name = 'fishbot_description'
          urdf_name = "fishbot_base.urdf"
      
          ld = LaunchDescription()
          pkg_share = FindPackageShare(package=package_name).find(package_name) 
          urdf_model_path = os.path.join(pkg_share, f'urdf/{urdf_name}')
      
          robot_state_publisher_node = Node(
              package='robot_state_publisher',
              executable='robot_state_publisher',
              arguments=[urdf_model_path]
              )
      
          joint_state_publisher_node = Node(
              package='joint_state_publisher_gui',
              executable='joint_state_publisher_gui',
              name='joint_state_publisher_gui',
              arguments=[urdf_model_path]
              )
      
          rviz2_node = Node(
              package='rviz2',
              executable='rviz2',
              name='rviz2',
              output='screen',
              )
      
          # ld.add_action(joint_state_publisher_node)
          ld.add_action(robot_state_publisher_node)
          ld.add_action(rviz2_node)
      
          return ld
      
      1 条回复 最后回复 回复 引用 0
      • 4417555354
        头怎么还不秃啊
        最后由 编辑

        QQ图片20230515104705.png

        1 条回复 最后回复 回复 引用 0
        • 4417555354
          头怎么还不秃啊
          最后由 编辑

          ros2版本: humble ubuntu版本:22.04

          1 条回复 最后回复 回复 引用 0
          • 4417555354
            头怎么还不秃啊
            最后由 编辑

            此回复已被删除!
            1 条回复 最后回复 回复 引用 0
            • 4417555354
              头怎么还不秃啊
              最后由 编辑

              按教程先执行的gazebo.launch再执行cartographer.launch

              1 条回复 最后回复 回复 引用 0
              • 4417555354
                头怎么还不秃啊
                最后由 编辑

                终端日志如下
                终端1

                hdm@hdm-virtual-machine:~/d2lros2/nav_ws$ source install/setup.bash
                ros2 launch fishbot_description gazebo.launch.py
                not found: "/home/hdm/d2lros2/nav_ws/install/cartographer_ros_msgs/share/cartographer_ros_msgs/local_setup.bash"
                [INFO] [launch]: All log files can be found below /home/hdm/.ros/log/2023-05-15-08-40-32-100409-hdm-virtual-machine-3968
                [INFO] [launch]: Default logging verbosity is set to INFO
                [INFO] [gazebo-1]: process started with pid [3993]
                [INFO] [spawn_entity.py-2]: process started with pid [3995]
                [spawn_entity.py-2] [INFO] [1684111234.837423372] [spawn_entity]: Spawn Entity started
                [spawn_entity.py-2] [INFO] [1684111234.839541462] [spawn_entity]: Loading entity XML from file /home/hdm/d2lros2/nav_ws/install/fishbot_description/share/fishbot_description/urdf/fishbot_base.urdf
                [spawn_entity.py-2] [INFO] [1684111234.847188459] [spawn_entity]: Waiting for service /spawn_entity, timeout = 30
                [spawn_entity.py-2] [INFO] [1684111234.850326630] [spawn_entity]: Waiting for service /spawn_entity
                [gazebo-1] Gazebo multi-robot simulator, version 11.10.2
                [gazebo-1] Copyright (C) 2012 Open Source Robotics Foundation.
                [gazebo-1] Released under the Apache 2 License.
                [gazebo-1] http://gazebosim.org
                [gazebo-1] 
                [gazebo-1] Gazebo multi-robot simulator, version 11.10.2
                [gazebo-1] Copyright (C) 2012 Open Source Robotics Foundation.
                [gazebo-1] Released under the Apache 2 License.
                [gazebo-1] http://gazebosim.org
                [gazebo-1] 
                [gazebo-1] [Msg] Waiting for master.
                [gazebo-1] [Msg] Connected to gazebo master @ http://127.0.0.1:11345
                [gazebo-1] [Msg] Publicized address: 192.168.1.103
                [gazebo-1] [Wrn] [GuiIface.cc:120] Could not find the Qt platform plugin "wayland" in ""
                [spawn_entity.py-2] [INFO] [1684111237.923595500] [spawn_entity]: Calling service /spawn_entity
                [spawn_entity.py-2] [INFO] [1684111238.817074194] [spawn_entity]: Spawn status: SpawnEntity: Successfully spawned entity [fishbot]
                [gazebo-1] [INFO] [1684111239.028024078] [diff_drive]: Wheel pair 1 separation set to [0.200000m]
                [gazebo-1] [INFO] [1684111239.029597513] [diff_drive]: Wheel pair 1 diameter set to [0.065000m]
                [gazebo-1] [INFO] [1684111239.035535833] [diff_drive]: Subscribed to [/cmd_vel]
                [gazebo-1] [INFO] [1684111239.047795731] [diff_drive]: Advertise odometry on [/odom]
                [gazebo-1] [INFO] [1684111239.067134085] [diff_drive]: Publishing odom transforms between [odom] and [base_footprint]
                [gazebo-1] [INFO] [1684111239.111004399] [fishbot_joint_state]: Going to publish joint [right_wheel_joint]
                [gazebo-1] [INFO] [1684111239.114673636] [fishbot_joint_state]: Going to publish joint [left_wheel_joint]
                [INFO] [spawn_entity.py-2]: process has finished cleanly [pid 3995]
                [gazebo-1] context mismatch in svga_surface_destroy
                [gazebo-1] context mismatch in svga_surface_destroy
                
                

                终端2

                /d2lros2/nav_ws/src$ source install/setup.bash
                ros2 launch fishbot_cartographer cartographer.launch.py 
                not found: "/home/hdm/d2lros2/nav_ws/src/install/cartographer_ros_msgs/share/cartographer_ros_msgs/local_setup.bash"
                [INFO] [launch]: All log files can be found below /home/hdm/.ros/log/2023-05-15-11-41-48-291804-hdm-virtual-machine-57453
                [INFO] [launch]: Default logging verbosity is set to INFO
                rviz config in /home/hdm/d2lros2/nav_ws/src/install/fishbot_cartographer/share/fishbot_cartographer/config/cartographer.rviz
                [INFO] [cartographer_node-1]: process started with pid [57454]
                [INFO] [cartographer_occupancy_grid_node-2]: process started with pid [57456]
                [INFO] [rviz2-3]: process started with pid [57458]
                [rviz2-3] Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
                [cartographer_node-1] [INFO] [1684122108.972841501] [cartographer logger]: I0515 11:41:48.000000 57454 configuration_file_resolver.cc:41] Found '/home/hdm/d2lros2/nav_ws/src/install/fishbot_cartographer/share/fishbot_cartographer/config/fishbot_2d.lua' for 'fishbot_2d.lua'.
                [cartographer_node-1] [INFO] [1684122108.974296311] [cartographer logger]: I0515 11:41:48.000000 57454 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/map_builder.lua' for 'map_builder.lua'.
                [cartographer_node-1] [INFO] [1684122108.974492682] [cartographer logger]: I0515 11:41:48.000000 57454 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/map_builder.lua' for 'map_builder.lua'.
                [cartographer_node-1] [INFO] [1684122108.974755899] [cartographer logger]: I0515 11:41:48.000000 57454 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/pose_graph.lua' for 'pose_graph.lua'.
                [cartographer_node-1] [INFO] [1684122108.974834889] [cartographer logger]: I0515 11:41:48.000000 57454 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/pose_graph.lua' for 'pose_graph.lua'.
                [cartographer_node-1] [INFO] [1684122108.975225587] [cartographer logger]: I0515 11:41:48.000000 57454 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/trajectory_builder.lua' for 'trajectory_builder.lua'.
                [cartographer_node-1] [INFO] [1684122108.975299146] [cartographer logger]: I0515 11:41:48.000000 57454 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/trajectory_builder.lua' for 'trajectory_builder.lua'.
                [cartographer_node-1] [INFO] [1684122108.975401550] [cartographer logger]: I0515 11:41:48.000000 57454 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/trajectory_builder_2d.lua' for 'trajectory_builder_2d.lua'.
                [cartographer_node-1] [INFO] [1684122108.975453097] [cartographer logger]: I0515 11:41:48.000000 57454 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/trajectory_builder_2d.lua' for 'trajectory_builder_2d.lua'.
                [cartographer_node-1] [INFO] [1684122108.975979673] [cartographer logger]: I0515 11:41:48.000000 57454 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/trajectory_builder_3d.lua' for 'trajectory_builder_3d.lua'.
                [cartographer_node-1] [INFO] [1684122108.976082808] [cartographer logger]: I0515 11:41:48.000000 57454 configuration_file_resolver.cc:41] Found '/opt/ros/humble/share/cartographer/configuration_files/trajectory_builder_3d.lua' for 'trajectory_builder_3d.lua'.
                
                
                29180440352 1 条回复 最后回复 回复 引用 0
                • 29180440352
                  shadowwalker @441755535
                  最后由 编辑

                  @441755535 用rqt看下节点和话题是否都有

                  4417555354 1 条回复 最后回复 回复 引用 0
                  • 4417555354
                    头怎么还不秃啊 @2918044035
                    最后由 编辑

                    @2918044035 QQ图片20230515143842.png

                    小鱼小 1 条回复 最后回复 回复 引用 0
                    • 小鱼小
                      小鱼 技术大佬 @441755535
                      最后由 编辑

                      @441755535 话题很孤立的感觉,没有节点订阅,有运行建图节点吗

                      新书配套视频:https://www.bilibili.com/video/BV1GW42197Ck/

                      1 条回复 最后回复 回复 引用 0
                      • 第一个帖子
                        最后一个帖子
                      皖ICP备16016415号-7
                      Powered by NodeBB | 鱼香ROS