当前位置:网站首页>ROS2自学笔记:Rviz可视化工具
ROS2自学笔记:Rviz可视化工具
2022-07-23 13:35:00 【Raine_Yang】
启动rviz
ros2 run rviz2 rviz2
rviz订阅其他节点话题,得到数据,并将数据渲染为图像。在add键里rviz已经提供了许多常见机器人话题
rviz显示相机画面:
首先在gazebo里创建相机模块
<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="camera">
<xacro:macro name="usb_camera" params="prefix:=camera">
<!-- Create laser reference frame -->
<link name="${prefix}_link">
<inertial>
<mass value="0.1" />
<origin xyz="0 0 0" />
<inertia ixx="0.01" ixy="0.0" ixz="0.0"
iyy="0.01" iyz="0.0"
izz="0.01" />
</inertial>
<visual>
<origin xyz=" 0 0 0 " rpy="0 0 0" />
<geometry>
<box size="0.01 0.04 0.04" />
</geometry>
<material name="black"/>
</visual>
<collision>
<origin xyz="0.0 0.0 0.0" rpy="0 0 0" />
<geometry>
<box size="0.01 0.04 0.04" />
</geometry>
</collision>
</link>
<gazebo reference="${prefix}_link">
<material>Gazebo/Black</material>
</gazebo>
<gazebo reference="${prefix}_link">
<sensor type="camera" name="camera_node">
<update_rate>30.0</update_rate>
<camera name="head">
<horizontal_fov>1.3962634</horizontal_fov>
<image>
<width>1280</width>
<height>720</height>
<format>R8G8B8</format>
</image>
<clip>
<near>0.02</near>
<far>300</far>
</clip>
<noise>
<type>gaussian</type>
<mean>0.0</mean>
<stddev>0.007</stddev>
</noise>
</camera>
<plugin name="gazebo_camera" filename="libgazebo_ros_camera.so">
<ros>
<!-- <namespace>stereo</namespace> -->
<remapping>~/image_raw:=image_raw</remapping>
<remapping>~/camera_info:=camera_info</remapping>
</ros>
<camera_name>${
prefix}</camera_name>
<frame_name>${
prefix}_link</frame_name>
<hack_baseline>0.2</hack_baseline>
</plugin>
</sensor>
</gazebo>
</xacro:macro>
</robot>
1 <xacro:macro name="usb_camera" params="prefix:=camera">
宏定义相机模块,名称usb_camera,参数prefix(用于补全名称)
2
<visual>
<origin xyz=" 0 0 0 " rpy="0 0 0" />
<geometry>
<box size="0.01 0.04 0.04" />
</geometry>
<material name="black"/>
</visual>
设置相机外观与位置,盒型,黑色
3 <sensor type="camera" name="camera_node">
核心功能,设置相机属性。sensor标签用于标明传感器,这里类型为camera
4 <update_rate>30.0</update_rate>
更新率30
5 <image> <width>1280</width> <height>720</height> <format>R8G8B8</format> </image>
设置相机画面宽1280,高720,颜色空间类型R8G8B8
6 <clip> <near>0.02</near> <far>300</far> </clip>
相机拍摄距离上限300,下限0.02
7 <noise> <type>gaussian</type> <mean>0.0</mean> <stddev>0.007</stddev> </noise>
真实相机拍摄画面可能出现噪音,这里模拟噪音
8
<plugin name="gazebo_camera" filename="libgazebo_ros_camera.so">
<ros>
<!-- <namespace>stereo</namespace> -->
<remapping>~/image_raw:=image_raw</remapping>
<remapping>~/camera_info:=camera_info</remapping>
</ros>
<camera_name>${
prefix}</camera_name>
<frame_name>${
prefix}_link</frame_name>
<hack_baseline>0.2</hack_baseline>
</plugin>
调用相机驱动libgazebo_ros_camera.so,可以重定向话题名称改为自己要取的名字
把相机和车身合并
<?xml version="1.0"?>
<robot name="arm" xmlns:xacro="http://www.ros.org/wiki/xacro">
<xacro:include filename="$(find learning_gazebo)/urdf/mbot_base_gazebo.xacro" />
<xacro:include filename="$(find learning_gazebo)/urdf/sensors/camera_gazebo.xacro" />
<xacro:property name="camera_offset_x" value="0.17" />
<xacro:property name="camera_offset_y" value="0" />
<xacro:property name="camera_offset_z" value="0.10" />
<!-- Camera -->
<joint name="camera_joint" type="fixed">
<origin xyz="${camera_offset_x} ${camera_offset_y} ${camera_offset_z}" rpy="0 0 0" />
<parent link="base_link"/>
<child link="camera_link"/>
</joint>
<xacro:usb_camera prefix="camera"/>
<xacro:mbot_base_gazebo/>
</robot>
1 引入相机和车身的xacro模型
<xacro:include filename="$(find learning_gazebo)/urdf/mbot_base_gazebo.xacro" />
<xacro:include filename="$(find learning_gazebo)/urdf/sensors/camera_gazebo.xacro" />
2
<xacro:property name="camera_offset_x" value="0.17" />
<xacro:property name="camera_offset_y" value="0" />
<xacro:property name="camera_offset_z" value="0.10" />
设置相机位置
3
<joint name="camera_joint" type="fixed">
<origin xyz="${camera_offset_x} ${camera_offset_y} ${camera_offset_z}" rpy="0 0 0" />
<parent link="base_link"/>
<child link="camera_link"/>
</joint>
用一个joint连接相机和车身
在rviz里面显示结果
操作:add->image->在topic里选择相机发布的话题名
注:gazebo和rviz区别
gazebo为仿真平台,在没有实体机器人时可以使用gazebo模拟机器人环境
rviz为显示平台,可以显示获得的二维或三维信息,数据来源可以为gazebo也可为其他方式
边栏推荐
- pinia(菠萝)
- 一文带你了解什么是TypeScript
- Nifi 1.16.3 cluster setup +kerberos+ user authentication
- YOLOV7
- The first stage of basic knowledge of numpy data analysis (numpy Foundation)
- 解决data functions should return an object 并(Property “visible“ must be accessed with “$data.visible“)
- C语言基础篇 —— 2-6 指针、数组与sizeof运算符
- AutoCAD基本操作
- 拼多多APP商品详情接口获取activity_id值(拼多多activity_id接口)
- 【笔记】线性回归
猜你喜欢

中国化NFT?NFR横空出世

检测器:用递归特征金字塔和可切换的阿托洛斯卷积检测物体

FreeRTOS个人笔记-挂起/解挂任务

Heartless sword English Chinese bilingual poem 006. to my wife

一文带你了解什么是TypeScript

O3DF执行董事Royal O’Brien:开源没有边界,所有共享的声音都会变成实际方向

Tan Zhangxi, director of risc-v Foundation: risc-v has gradually expanded from the edge to the center

Lake Shore—EMPX-H2 型低温探针台

FIO performance testing tool

Detector: detect objects with recursive feature pyramid and switchable atolos convolution
随机推荐
微机原理与技术接口随堂练习
UiPath Studio Enterprise 22.4 Crack
Royal O'Brien, executive director of o3df: open source has no boundaries, and all shared sounds will become the actual direction
SQL156 各个视频的平均完播率
Distance IOU loss: faster and better learning for bounding box regression
同花顺上选择券商,网上客户经理开户安全吗
Ie box model and standard box model
Tips and tricks for Neural Networks 深度学习训练神经网络的技巧总结(不定期更新)
检测器:用递归特征金字塔和可切换的阿托洛斯卷积检测物体
2022-7-22 面经复习+简单题目整理
系统内存介绍和内存管理
【笔记】线性回归
Heartless sword English Chinese bilingual poem 006. to my wife
fio性能测试工具
TS encapsulates the localstorage class to store information
anchor free yolov1
Convolutional neural network model -- googlenet network structure and code implementation
Leetcode-67. binary sum
PIP reports an error could not find a version that satisfies the... No matching distribution
FIO performance testing tool