Command Palette

Search for a command to run...

Back to skills
skill № 11364

rviz2

RViz2 可视化开发技能 - 3D可视化、插件开发、显示类型配置、交互工具开发

FreeNo executable scripts
MIUAVby MIUAV★ 30 GitHub stars

Install rviz2 in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

About this skill

RViz2 Visualization Skill

用于 RViz2 可视化工具的配置和插件开发


何时使用

当需要以下帮助时使用此技能:

  • 配置 RViz2 显示项
  • 创建自定义显示插件
  • 开发交互工具
  • 可视化传感器数据
  • 配置导航可视化

快速参考

安装 RViz2

# ROS2 Humble
sudo apt install ros-humble-rviz2

# ROS2 Iron
sudo apt install ros-iron-rviz2

# 从源码构建
cd ~/ros2_ws
vcs import src < https://github.com/ros2/rviz.git
cd src/rviz
rosdep install -r --from-paths . --ignore-src -y
colcon build --packages-up-to rviz_common rviz_rendering rviz

启动 RViz2

# 启动默认配置
rviz2

# 加载指定配置文件
rviz2 -d /path/to/config.rviz

# 启动新窗口
rviz2 --window geometry

RViz2 配置文件 (.rviz)

Visualization Manager:
  Class: "rviz2/VisualizationManager"
  Fixed Frame: "map"
  Tools:
    - Class: "rviz_interactive_tools/MoveFace"
    - Class: "rviz_default_plugins/Interact"
      Hide Small Objects: false
    - Class: "rviz_default_plugins/SetInitialPose"
      Topic: "/initialpose"
    - Class: "rviz_default_plugins/SetGoal"
      Topic: "/move_base_simple/goal"
  
  Displays:
    - Class: "rviz_default_plugins/Grid"
      Name: "Grid"
      Plane: "XY"
      Cell Size: 1
      Reference Frame: "map"
    
    - Class: "rviz_default_plugins/RobotModel"
      Name: "Robot Model"
      Description Topic:
        Topic: "/robot_description"
        Type: "robot_state/JointState"
    
    - Class: "rviz_default_plugins/PointCloud2"
      Name: "Lidar Points"
      Topic:
        Topic: "/scan"
        Type: "sensor_msgs/PointCloud2"
      Color Transform: "RGB"
      Style: "Points"
    
    - Class: "rviz_default_plugins/Map"
      Name: "Occupancy Map"
      Topic:
        Topic: "/map"
        Type: "nav_msgs/OccupancyGrid"
      Color Scheme: "map"
    
    - Class: "rviz_default_plugins/Trajectory"
      Name: "Path"
      Topic:
        Topic: "/plan"
        Type: "nav_msgs/Path"
      Color: 0 0 255 255
      Line Width: 3

显示类型配置

激光雷达点云

// 创建点云显示
rviz_common::Display* createPointCloudDisplay(rviz_common::DisplayContext* context)
{
  rviz_common::Display* display = context->createDisplay("rviz_default_plugins/PointCloud2");
  display->initialize(context);
  
  // 设置属性
  rviz_common::Property* props = display->getProperty();
  props->subProp("Topic")->subProp("Topic")->setValue("/scan");
  props->subProp("Style")->setValue("Points");
  props->subProp("Size (Pixels)")->setValue(3);
  
  return display;
}

TF 变换树

// TF 显示配置
{
  "Class": "rviz_default_plugins/TF",
  "Name": "TF Tree",
  "Frame Timeout": 5,
  "All Frames Enabled": true,
  "Marker Scale": 1.0,
  "Show Names": true,
  "Show Axes": true,
  "Show Arrows": true
}

机器人模型

<!-- robot.urdf.xacro -->
<?xml version="1.0" ?>
<robot name="my_robot" xmlns:xacro="http://www.ros.org/wiki/xacro">
  
  <!-- Base Link -->
  <link name="base_link">
    <visual>
      <origin xyz="0 0 0" rpy="0 0 0"/>
      <geometry>
        <box size="0.5 0.4 0.2"/>
      </geometry>
      <material name="white">
        <color rgba="1 1 1 1"/>
      </material>
    </visual>
    <collision>
      <origin xyz="0 0 0" rpy="0 0 0"/>
      <geometry>
        <box size="0.5 0.4 0.2"/>
      </geometry>
    </collision>
  </link>
  
  <!-- Wheel -->
  <joint name="left_wheel_joint" type="continuous">
    <parent link="base_link"/>
    <child link="left_wheel"/>
    <origin xyz="0 0.25 0" rpy="-1.5708 0 0"/>
    <axis xyz="0 0 1"/>
  </joint>
  
  <link name="left_wheel">
    <visual>
      <geometry>
        <cylinder radius="0.1" length="0.05"/>
      </geometry>
    </visual>
  </link>
</robot>

路径可视化

- Class: "nav_msgs/Path"
  Name: "Global Path"
  Topic:
    Topic: "/move_base/NavfnROS/plan"
    Type: "nav_msgs/Path"
  Color: 0 255 0 255
  Line Style: "Lines"
  Line Width: 0.05
  
- Class: "nav_msgs/Path"
  Name: "Local Plan"
  Topic:
    Topic: "/move_base/DWAPlannerROS/local_plan"
    Type: "nav_msgs/Path"
  Color: 255 0 0 255
  Line Width: 0.03

RViz2 插件开发

创建插件包

# 创建包
cd ~/ros2_ws/src
ros2 pkg create --dependencies rviz_common rviz_rendering rviz_ogre_vendor --library-name my_rviz_plugin my_rviz_display_plugin

# CMakeLists.txt
cmake_minimum_required(VERSION 3.8)
project(my_rviz_display_plugin)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wdeprecated-register)
endif()

find_package(ament_cmake REQUIRED)
find_package(rviz_common REQUIRED)
find_package(rviz_rendering REQUIRED)

include_directories(
  include
)

add_library(my_display SHARED
  src/my_display.cpp
)

target_link_libraries(my_display
  rviz_common::rviz_common
  rviz_rendering::rviz_rendering
)

ament_target_dependencies(my_display
  rclcpp
  visualization_msgs
)

# Install
ament_export_libraries(my_display)
install(TARGETS my_display
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
  RUNTIME DESTINATION bin
)

创建自定义 Display 插件

// include/my_rviz_display_plugin/my_custom_display.hpp
#ifndef MY_CUSTOM_DISPLAY_HPP_
#def
Full SKILL.md on GitHub

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

Bundled files

  • display-configuration/SKILL.md
  • marker-visualization/SKILL.md
  • plugin-development/SKILL.md
  • tf-visualization/SKILL.md

FAQ

What does the rviz2 skill do?

RViz2 可视化开发技能 - 3D可视化、插件开发、显示类型配置、交互工具开发

How do I install the rviz2 skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the rviz2 skill run scripts?

No, this skill is instructions only (SKILL.md) with no executable scripts.

Related skills

Compare rviz2 with