当前位置:网站首页>Gazebo 控制实例
Gazebo 控制实例
2022-07-27 23:01:00 【2021 Nqq】
文章目录
运动控制实现流程
roslaunch urdf02_gazebo demo03_env.launch
启动gazebo仿真环境 demo03_env.launch
launch文件
<launch>
<!-- 1. 需要再参数服务器中载入 urdf -->
<param name = "robot_description" command = "$(find xacro)/xacro $(find urdf02_gazebo)/urdf/car.urdf.xacro" />
<!-- 2. 启动Gazebo仿真环境 roslaunch gazebo_ros empty_world.launch-->
<include file = "$(find gazebo_ros)/launch/empty_world.launch">
<arg name = "world_name" value = "$(find urdf02_gazebo)/worlds/box_house.world" />
</include>
<!-- 3. 在Gazebo中添加机器人模型 -->
<!-- rosrun gazebo_ros spawn_model -urdf -model mycar -param robot_description , 这里mycar是robot name-->
<node pkg = "gazebo_ros" type = "spawn_model" name = "spawn_model" args = "-urdf -model mycar -param robot_description"/>
</launch>
添加传动装置及控制器 move.xacro
<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="left2link" />
<xacro:joint_trans joint_name="right2link" />
<!-- 控制器 -->
<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>left2ink</leftJoint> <!-- 左轮 -->
<rightJoint>right2link</rightJoint> <!-- 右轮 -->
<wheelSeparation>${base_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集成文件 car.urdf.xacro
<robot name="mycar" xmlns:xacro="http://wiki.ros.org/xacro">
<!-- 包含惯性矩阵文件 -->
<xacro:include filename = "head.xacro" />
<!-- 包含底盘、摄像头、雷达的xacro文件 -->
<xacro:include filename = "demo02_car_base.urdf.xacro" />
<xacro:include filename = "demo03_car_camera.urdf.xacro" />
<xacro:include filename = "demo04_car_laser.urdf.xacro" />
<!-- 运动控制 -->
<xacro:include filename = "gazebo/move.xacro" />
</robot>
Rviz 查看里程计消息
里程计: 机器人相对出发点坐标系的位姿状态(X 坐标 Y 坐标 Z坐标以及朝向)
启动Rviz demo04_sensor.launch
<launch>
<!-- 启动rviz -->
<node pkg = "rviz" type = "rviz" name = "rviz" args = "-d $(find urdf01_rviz)/config/show_mycar.rviz"/>
<!-- 添加关节状态发布节点 -->
<node pkg = "joint_state_publisher" type = "joint_state_publisher" name = "joint_state_publisher" />
<!-- 添加机器人状态发布节点 -->
<node pkg = "robot_state_publisher" type = "robot_state_publisher" name = "robot_state_publisher" />
</launch>
source ./devel/setup.bash
roslaunch urdf02_gazebo demo03_env.launch
roslaunch urdf02_gazebo demo04_sensor.launch
添加组件
雷达 laser.xacro
<robot name="my_sensors" xmlns:xacro="http://wiki.ros.org/xacro">
<!-- 雷达 -->
<gazebo reference="laser"><!-- reference 名字要与demo04_car_laser里面雷达名字相同-->
<sensor type="ray" name="rplidar">
<pose>0 0 0 0 0 0</pose><!-- x y z 欧拉角 -->
<visualize>true</visualize>
<update_rate>5.5</update_rate>
<ray>
<scan>
<horizontal>
<samples>360</samples> <!--雷达旋转一周采集360个点-->
<resolution>1</resolution><!--每一个线会有一根测距,2表示每两根线会有一根测距-->>
<min_angle>-3</min_angle><!-- 单位是弧度 向右转3个弧度 顺时针-->
<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><!--名字要与demo04_car_laser里面雷达名字相同-->
</plugin>
</sensor>
</gazebo>
</robot>
摄像头 camera.xacro
<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>
rostopic pub -r 10 /cmd_vel 设置参数让机器人转动
边栏推荐
- Branch and loop sentence exercises
- Demo: the test interface receives duplicate data and creates documents in a short time
- Swoole websocket service
- Detailed explanation of swoole memory table
- Oracle grouping takes the maximum value
- Basic learning of cesium
- 学习笔记12:Eratosthenes筛选法求素数(100以内) 和 魔方阵
- Operator depth anatomy
- 华为旗下哈勃投资入股VCSEL芯片厂商纵慧芯光
- Cross desktop web container evolution
猜你喜欢

从功能测试到自动化测试,月薪突破30K+,我的6年测开经验。

C language programming | single dog topic explanation

110. SAP UI5 FileUploader 控件深入介绍 - 为什么需要一个隐藏的 iframe

Redis-哨兵模式

110. In depth introduction to sap ui5 fileuploader control - why do you need a hidden iframe

文件系统挂载

File system mount

Rancher2.6 monitoring grafana docking LDAP

I/O设备的基本概念及分类

代码随想录笔记_哈希_1002查找共用字符
随机推荐
[300 opencv routines] 241. Scale invariant feature transformation (SIFT)
范德蒙德卷积 学习笔记
Uni app advanced style framework / production environment
Basic concept and classification of i/o equipment
Arm中国夺权大战的背后:“独立”两年,仍难“自主”?
C language programming | single dog topic explanation
Starfish Os打造的元宇宙生态,跟MetaBell的合作只是开始
Recommended system - indicators: CTR, CVR
Recommended system model: DSSM twin tower model for embedded recall
Recommended system model (III): fine scheduling model [LR, gbdt, wide & deep, DCN, DIN, Dien, MMOE, ple]
自用图床搭建教程
Analysis and recurrence of network security vulnerabilities
Swoole定时器
C语言程序设计 | 单身狗题目讲解
C语言main函数传递参数
Recommended system - offline recall: u2tag2i, ICF
怎么清晰地理解、表达 IaaS 、 PaaS 、 SaaS ?
Examples of application of JMeter in performance testing
Demo: the test interface receives duplicate data and creates documents in a short time
吴雄昂发内部信:Arm的指控是莫须有的,现有成果不允许有任何损害!