当前位置: 首页 > news >正文

ROS 发行版 jazzy 加载urdf 渲染到 RVIZ2

新版启动urdf需要两个包分别为urdf_tutorial、urdf_launch

配置package.xml

<exec_depend>rviz_common</exec_depend>

<exec_depend>rviz_default_plugins</exec_depend>

<exec_depend>rviz2</exec_depend>

<exec_depend>robot_state_publisher</exec_depend>

<exec_depend>joint_state_publisher</exec_depend>

<exec_depend>joint_state_publisher_gui</exec_depend>

<exec_depend>xacro</exec_depend>

<exec_depend>launch_ros</exec_depend>

CMakeLists.txt配置

install(DIRECTORY launch worlds urdf meshes models rviz

DESTINATION share/${PROJECT_NAME})

launch.py 内容

from launch import LaunchDescription

from launch_ros.substitutions import FindPackageShare

from launch.actions import DeclareLaunchArgument,IncludeLaunchDescription

from launch.substitutions import PathJoinSubstitution,LaunchConfiguration,Command

from launch_ros.actions import Node

from launch_ros.parameter_descriptions import ParameterValue

from launch.conditions import IfCondition,UnlessCondition

import os

def generate_launch_description():

ld = LaunchDescription()

## 找到 项目 包

samll_turtle_dir = FindPackageShare("small_turtle")

## URDF Model 路径

urdf_model_path = PathJoinSubstitution([samll_turtle_dir,"urdf","small_turtle.urdf"])

## urdf_model_path = os.path.join(samll_turtle_dir,"urdf","small_turtle.urdf")

## rviz 配置文件路径

rviz_config_path = PathJoinSubstitution([samll_turtle_dir,"rviz","display.rviz"])

## joint_state_publisher_gui 配置

gui_arg = DeclareLaunchArgument(name="gui",default_value="true",choices=["true","false"],

description="Flag to enable joint_state_publisher_gui")

ld.add_action(gui_arg)

## 声明 rviz

rviz_arg = DeclareLaunchArgument(name="rvizconfig",default_value=rviz_config_path,

description="Absolute path to rviz config file")

ld.add_action(rviz_arg)

## 声明 urdf model

ld.add_action(DeclareLaunchArgument(name="model",default_value=urdf_model_path,

description="Path to robot urdf"))

## robot_state_publisher 配置

robot_description_content = ParameterValue(Command(["xacro ",LaunchConfiguration("model")]),value_type=str)

robot_state_publisher_node = Node(

package="robot_state_publisher",

executable="robot_state_publisher",

parameters=[{"robot_description":robot_description_content}]

)

ld.add_action(robot_state_publisher_node)

## joint_state_publisher

joint_state_publisher_node = Node(

package="joint_state_publisher",

executable="joint_state_publisher",

condition=UnlessCondition(LaunchConfiguration("gui"))

)

ld.add_action(joint_state_publisher_node)

## joint_state_publisher_gui

joint_state_publisher_gui_node = Node(

package="joint_state_publisher_gui",

executable="joint_state_publisher_gui",

condition=IfCondition(LaunchConfiguration("gui"))

)

ld.add_action(joint_state_publisher_gui_node)

## rviz

rviz_node = Node(

package="rviz2",

executable="rviz2",

arguments=["-d",LaunchConfiguration("rvizconfig")],

output="screen"

)

ld.add_action(rviz_node)

return ld

http://www.lryc.cn/news/433316.html

相关文章:

  • SpringBoot中利用EasyExcel+aop实现一个通用Excel导出功能
  • 排序链表(归并排序)
  • Adobe After Effects的插件--------CC Particle World
  • 电脑硬盘数据丢失了怎么恢复?简单实用的硬盘数据找回的方法
  • k8s调度(pod亲和、反亲和、污点、容忍度)
  • 智能制造核心领域:自动化、物联网、大数据分析、人工智能在现代制造业中的应用与融合
  • Android Studio 2024最新版Hello World
  • 请解释Java中的CountDownLatch和CyclicBarrier的区别和使用场景。什么是Java中的Semaphore?它如何控制并发访问?
  • Django+Vue3前后端分离学习(五)(前端登录页面搭建)
  • 虚拟机安装macos系统
  • AI基础 L9 Local Search II 局部搜索
  • 828华为云征文|使用sysbench对Mysql应用加速测评
  • 2024 年高教社杯全国大学生数学建模竞赛题目——D 题 反潜航空深弹命中概率问题的求解
  • 【Kubernetes】常见面试题汇总(一)
  • 简单实用的php全新实物商城系统
  • Leetcode面试经典150题-128.最长连续序列-递归版本另解
  • spring security 中的授权使用
  • python安装以及访问openAI API
  • 【Unity小技巧】URP管线遮挡高亮效果
  • C#中的GDI和GDI+(Graphics Device Interface Plus)图形设备接口
  • 谷粒商城のNginx
  • Debug-027-el-tooltip组件的使用及注意事项
  • 猫眼电影字体破解(图片转码方法)
  • flink wordcount
  • 组合模式(Composite Pattern)
  • 教你制作一本加密的样本册
  • C语言进阶【1】--字符函数和字符串函数【1】
  • git提交自动带上 Signed-off-by信息
  • 图论(2)
  • ASP.NET Core 入门教学十九 依赖注入ioc