当前位置:网站首页>[Advanced ROS] Lecture 11 Robot co-simulation based on Gazebo and Rviz (motion control and sensors)
[Advanced ROS] Lecture 11 Robot co-simulation based on Gazebo and Rviz (motion control and sensors)
2022-07-30 13:55:00 【Born as Zhaoxu】
【ROS进阶篇】基于Gazebo和Rvizrobot co-simulation(Motion Control and Sensors)

文章目录
前言
In the previous blog, we systematically learned how to useGazebo对使用URDFFile the completed robot model for integrated simulation,Starting from the basic simulation process,Specific robot examples are given in the follow-up,and attached at the end usingGazeboTutorial for Creating a Simulation Environment,This section mainly focuses on使用URDF、Gazebo、Rviz进行联合仿真,URDF 用于创建机器人模型、Rviz 可以显示机器人感知到的环境信息,Gazebo 用于仿真,可以模拟外界环境,and robotic sensors,,This section focuses more on usingGazebo模拟传感器数据,并在RvizComplete display and analysis in.
一、机器人运动控制(ros_control)
1. 组件介绍
- 引入原因:在RVIZ中,我们通过ArbotixAuxiliary realized based onURDFFile the motion control of the robot model,而在Gazebo仿真中,Although we have established a specific simulation environment,But want to really control the robot movement,A key component package is also required.

应用场景:同样的ROSProgram deployment on different actual concrete robot systems.

介绍:ROS_CONTROL,是一组软件包,包含控制器、管理器、硬件、interface for transmission,Essentially a control middleware,提供了一套规范,除了这些,ros_controlAlso provides a hardware abstraction layer,Responsible for hardware resource management,controllerJust request resources from the abstraction layer.

- Function introduction of each data flow layer:
- Controller Manager:
Each robot may have multiplecontroller,So here is the concept of a controller manager,Provides a common interface to manage differentcontroller.controller manager的输入就是ROSThe output of the upper application.- Controller:
完成每个joint的控制,Request the underlying hardware resources,提供了PID控制器,读取硬件资源接口中的状态,issuing control commands.- Hardware Rescource:
An interface that provides hardware resources for the upper and lower layers.- RobotHW:
The hardware abstraction layer deals directly with the hardware,通过write和readmethod to complete the operation of the hardware,This layer also contains joint limits、torque conversion、State transition and other functions.- Real Robot:
The actual robot also needs its own embedded controller,After receiving the command, it needs to be reflected on the actuator,such as receiving the location1的命令后,Then you need to make the actuator fast、stable arrival position1.
- 特点:For different robotic platforms,ros_controlProvides a standard canonical interface architecture,Improved program compatibility、Efficiency and flexible portability,使用时直接调用gazebo中的相关接口即可.
2. Motion Control Implementation
- 基本流程:
- 创建机器人模型;
- 编写一个单独的xacro文件,添加传动装置及控制器,and integrated together;
- 启动Gazebo发布/cmd_velmessage control movement
- basic robotURDF文件略,传动、The control file example below:
<robot name="my_car_move" xmlns:xacro="http://wiki.ros.org/xacro">
<!-- 传动实现:用于连接控制器与关节 -->
<xacro:macro name="joint_trans" params="joint_name">
<!-- Transmission is important to link the joints and the controller -->
<transmission name="${joint_name}_trans">
<type>transmission_interface/SimpleTransmission</type>
<joint name="${joint_name}">
<hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
</joint>
<actuator name="${joint_name}_motor">
<hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
</xacro:macro>
<!-- 每一个驱动轮都需要配置传动装置 -->
<xacro:joint_trans joint_name="left_wheel2base_link" />
<xacro:joint_trans joint_name="right_wheel2base_link" />
<!-- 控制器 -->
<gazebo>
<plugin name="differential_drive_controller" filename="libgazebo_ros_diff_drive.so">
<rosDebugLevel>Debug</rosDebugLevel>
<publishWheelTF>true</publishWheelTF>
<robotNamespace>/</robotNamespace>
<publishTf>1</publishTf>
<publishWheelJointState>true</publishWheelJointState>
<alwaysOn>true</alwaysOn>
<updateRate>100.0</updateRate>
<legacyMode>true</legacyMode>
<leftJoint>left_wheel2base_link</leftJoint> <!-- 左轮 -->
<rightJoint>right_wheel2base_link</rightJoint> <!-- 右轮 -->
<wheelSeparation>${base_link_radius * 2}</wheelSeparation> <!-- 车轮间距 -->
<wheelDiameter>${wheel_radius * 2}</wheelDiameter> <!-- 车轮直径 -->
<broadcastTF>1</broadcastTF>
<wheelTorque>30</wheelTorque>
<wheelAcceleration>1.8</wheelAcceleration>
<commandTopic>cmd_vel</commandTopic> <!-- 运动控制话题 -->
<odometryFrame>odom</odometryFrame>
<odometryTopic>odom</odometryTopic> <!-- 里程计话题 -->
<robotBaseFrame>base_footprint</robotBaseFrame> <!-- 根坐标系 -->
</plugin>
</gazebo>
</robot>
- 集成xacro文件:
<!-- 组合小车底盘与摄像头 -->
<robot name="my_car_camera" xmlns:xacro="http://wiki.ros.org/xacro">
<xacro:include filename="my_head.urdf.xacro" />
<xacro:include filename="my_base.urdf.xacro" />
<xacro:include filename="my_camera.urdf.xacro" />
<xacro:include filename="my_laser.urdf.xacro" />
<xacro:include filename="move.urdf.xacro" />
</robot>
- 启动launch文件:
<launch>
<!-- 将 Urdf 文件的内容加载到参数服务器 -->
<param name="robot_description" command="$(find xacro)/xacro $(find demo02_urdf_gazebo)/urdf/xacro/my_base_camera_laser.urdf.xacro" />
<!-- 启动 gazebo -->
<include file="$(find gazebo_ros)/launch/empty_world.launch">
<arg name="world_name" value="$(find demo02_urdf_gazebo)/worlds/hello.world" />
</include>
<!-- 在 gazebo 中显示机器人模型 -->
<node pkg="gazebo_ros" type="spawn_model" name="model" args="-urdf -model mycar -param robot_description" />
</launch>
- 控制机器人运动:命令行控制/Writing Node Controls:

二、Sensor information simulation and display
1. 里程计信息
里程计信息:The pose state of the robot relative to the starting point coordinate system(Position Coordinates and Movement Orientation)
操作流程:
- Start with a startup fileRviz,Open state publishing node:
<launch> <!-- 启动 rviz --> <node pkg="rviz" type="rviz" name="rviz" /> <!-- 关节以及机器人状态发布节点 --> <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" /> <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" /> </launch>
- 在Rviz中添加组件:
2. 雷达信息
- 2.1 编写xacro文件,Add radar sensor information
<robot name="my_sensors" xmlns:xacro="http://wiki.ros.org/xacro">
<!-- 雷达 -->
<gazebo reference="laser">
<sensor type="ray" name="rplidar">
<pose>0 0 0 0 0 0</pose>
<visualize>true</visualize>
<update_rate>5.5</update_rate>
<ray>
<scan>
<horizontal>
<samples>360</samples>
<resolution>1</resolution>
<min_angle>-3</min_angle>
<max_angle>3</max_angle>
</horizontal>
</scan>
<range>
<min>0.10</min>
<max>30.0</max>
<resolution>0.01</resolution>
</range>
<noise>
<type>gaussian</type>
<mean>0.0</mean>
<stddev>0.01</stddev>
</noise>
</ray>
<plugin name="gazebo_rplidar" filename="libgazebo_ros_laser.so">
<topicName>/scan</topicName>
<frameName>laser</frameName>
</plugin>
</sensor>
</gazebo>
</robot>
- 2.2 Integrate files into robot models:
<!-- Combined trolley chassis and sensors -->
<robot name="my_car_camera" xmlns:xacro="http://wiki.ros.org/xacro">
<xacro:include filename="my_head.urdf.xacro" />
<xacro:include filename="my_base.urdf.xacro" />
<xacro:include filename="my_camera.urdf.xacro" />
<xacro:include filename="my_laser.urdf.xacro" />
<xacro:include filename="move.urdf.xacro" />
<!-- radar simulation xacro 文件 -->
<xacro:include filename="my_sensors_laser.urdf.xacro" />
</robot>
- 2.3 启动gazebo,启动rviz,Add radar information display plugin:

3. 摄像头信息
- 3.1 Configure the camera sensor
<robot name="my_sensors" xmlns:xacro="http://wiki.ros.org/xacro">
<!-- 被引用的link -->
<gazebo reference="camera">
<!-- 类型设置为 camara -->
<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">
<alwaysOn>true</alwaysOn>
<updateRate>0.0</updateRate>
<cameraName>/camera</cameraName>
<imageTopicName>image_raw</imageTopicName>
<cameraInfoTopicName>camera_info</cameraInfoTopicName>
<frameName>camera</frameName>
<hackBaseline>0.07</hackBaseline>
<distortionK1>0.0</distortionK1>
<distortionK2>0.0</distortionK2>
<distortionK3>0.0</distortionK3>
<distortionT1>0.0</distortionT1>
<distortionT2>0.0</distortionT2>
</plugin>
</sensor>
</gazebo>
</robot>
- 3.2 Integrated Robot Model,Similar to the first two sensors,略
- 3.3 启动仿真环境gazebo,启动rviz显示数据,添加组件:

4. kinect摄像头信息
- 4.1 配置kinect传感器:
<robot name="my_sensors" xmlns:xacro="http://wiki.ros.org/xacro">
<gazebo reference="kinect link名称">
<sensor type="depth" name="camera">
<always_on>true</always_on>
<update_rate>20.0</update_rate>
<camera>
<horizontal_fov>${60.0*PI/180.0}</horizontal_fov>
<image>
<format>R8G8B8</format>
<width>640</width>
<height>480</height>
</image>
<clip>
<near>0.05</near>
<far>8.0</far>
</clip>
</camera>
<plugin name="kinect_camera_controller" filename="libgazebo_ros_openni_kinect.so">
<cameraName>camera</cameraName>
<alwaysOn>true</alwaysOn>
<updateRate>10</updateRate>
<imageTopicName>rgb/image_raw</imageTopicName>
<depthImageTopicName>depth/image_raw</depthImageTopicName>
<pointCloudTopicName>depth/points</pointCloudTopicName>
<cameraInfoTopicName>rgb/camera_info</cameraInfoTopicName>
<depthImageCameraInfoTopicName>depth/camera_info</depthImageCameraInfoTopicName>
<frameName>kinect link名称</frameName>
<baseline>0.1</baseline>
<distortion_k1>0.0</distortion_k1>
<distortion_k2>0.0</distortion_k2>
<distortion_k3>0.0</distortion_k3>
<distortion_t1>0.0</distortion_t1>
<distortion_t2>0.0</distortion_t2>
<pointCloudCutoff>0.4</pointCloudCutoff>
</plugin>
</sensor>
</gazebo>
</robot>
- 4.2 Integrated Robot Model,Similar to the previous sensor,略
- 4.3 启动仿真环境gazebo,启动rviz显示数据,添加组件:

总结
- 声明:本节博客部分参考了CSDN用户赵虚左的ROS教程,本文主要内容是使用URDFfile to build the robot model,并通过Gazebo创建仿真环境,Analog sensor using,在RVIZDone for the sensor data visualization analysis and processing,In the second half of the analysis, we found that,对于传感器(里程计、雷达、摄像头)分析来说,都是从xacro文件出发,添加相应配置,Integrate into robot model file,Finally, start each simulation component to modify the configuration to complete the co-simulation,Each simulation component,complete the corresponding effect.
- 至此,ROSThe advanced part of the tutorial is over,对于ROSThe content of the part mainly includes the content of the navigation part, which will be supplemented in the future.,针对于GazeboThe usage tutorial will also have a separate column,敬请期待.
边栏推荐
- strlen跟sizeof区别
- What are the hard-core upgrades and applications that cannot be missed in Greenplum 6.0?
- R语言筛选时间序列数据的子集(subset time series data)、使用window函数筛选连续日期时间范围内的数据(start参数和end参数分别指定起始和结束时间)
- libudev 使用说明书
- Raja Koduri澄清Arc GPU跳票传闻 AXG年底前新推四条产品线
- CF603E Pastoral Oddities
- 05 | 后台登录:基于账号密码的登录方式(下)
- SQL 26 calculation under 25 years of age or older and the number of users
- leetcode207.课程表(判断有向图是否有环)
- ARC115F Migration
猜你喜欢

No-code development platform all application settings introductory tutorial

jsArray数组复制方法性能测试2207300040

MQTT网关读取西门子PLC数据传输到阿里云平台案例教程

二手手机销量突破3亿部,与降价的iPhone夹击国产手机

自从外包干了四年,基本废了...

高性能数据访问中间件 OBProxy(三):问题排查和服务运维

What are the hard-core upgrades and applications that cannot be missed in Greenplum 6.0?

缓存一致性

Study Notes - Becoming a Data Analyst in Seven Weeks "Week 2: Business": Business Analysis Metrics

No-code development platform application visible permission setting introductory tutorial
随机推荐
机器学习——特征选择
matlab画图,仅显示部分图例
【23考研】408代码题参考模板——链表
cpu / CS 和 IP
LeetCode二叉树系列——107.二叉树的层序遍历II
el-table中el-table-column下的操作切换class样式
戴墨镜的卡通太阳SVG动画js特效
Jenkins自动化部署项目
canvas彩虹桥动画js特效
CF1320E Treeland and Viruses
CMake库搜索函数居然不搜索LD_LIBRARY_PATH
20220729 证券、金融
外包干了七年,废了。。。
数据中台建设(五):打破企业数据孤岛和提取数据价值
ENVI图像处理(6):NDVI和植被指数
R语言ggplot2可视化:使用ggpubr包的ggmaplot函数可视化MA图(MA-plot)、设置label.select参数自定义在图中显示标签的基因类型(自定义显示的标签列表)
No-code development platform application visible permission setting introductory tutorial
第十三天笔记
qq udp tcp机制
【Advanced Mathematics】【7】Double Integral
