当前位置: 代码迷 >> 综合 >> Ubuntu20.04 创建机器人URDF模型并在rviz中显示过程中遇到的一些问题
  详细解决方案

Ubuntu20.04 创建机器人URDF模型并在rviz中显示过程中遇到的一些问题

热度:32   发布时间:2023-11-02 11:19:04.0

背景环境:

Ubuntu 20.0.04
ROS-Noetic
所学教程:《ROS机器人开发实践》chapter 6_2


问题描述及解决方法:

  1. 报错:无法启动节点<robot_state_publisher/state_publisher>

ERROR: cannot launch node of type [robot_state_publisher/state_publisher]: Cannot locate node of type [state_publisher] in package [robot_state_publisher]. Make sure file exists in package path and permission is set to executable (chmod +x)
原因:名称不对应导致无法定位该节点,修改display_mrobot_chassis_urdf.launch文件中robot_state_publisher的type:

<span style="background-color:#f5f5f5"><span style="color:#272a30"><code class="language-html">	<span style="color:#880000"><!-- 运行robot_state_publisher节点,发布tf  --></span><span style="color:#000088"><node</span> <span style="color:#660066">name</span><span style="color:#666600">=</span><span style="color:#008800">"robot_state_publisher"</span> <span style="color:#660066">pkg</span><span style="color:#666600">=</span><span style="color:#008800">"robot_state_publisher"</span> <span style="color:#660066">type</span><span style="color:#666600">=</span><span style="color:#008800">"state_publisher"</span> <span style="color:#000088">/></span></code></span></span>

修改为

<span style="background-color:#f5f5f5"><span style="color:#272a30"><code class="language-html">	<span style="color:#880000"><!-- 运行robot_state_publisher节点,发布tf  --></span><span style="color:#000088"><node</span> <span style="color:#660066">name</span><span style="color:#666600">=</span><span style="color:#008800">"robot_state_publisher"</span> <span style="color:#660066">pkg</span><span style="color:#666600">=</span><span style="color:#008800">"robot_state_publisher"</span> <span style="color:#660066">type</span><span style="color:#666600">=</span><span style="color:#008800">"robot_state_publisher"</span> <span style="color:#000088">/></span></code></span></span>
  1. 在rviz中打开后没有出现joint_state_publisher图形控制界面,也就无法来调节控制rviz中对应轮子模型的转动

原因:可能是版本更新的问题,现在joint_state_publisher节点不会调出图形控制界面,需要下载joint_state_publisher_gui并修改display_mrobot_chassis_urdf.launch文件。
下载joint_state_publisher_gui

<span style="background-color:#f5f5f5"><span style="color:#272a30"><code class="language-html"><span style="color:#000000">$ sudo apt-get install ros-noetic-joint-state-publisher-gui   </span></code></span></span>

然后修改display_mrobot_chassis_urdf.launch文件,将joint_state_publisher替换为joint_state_publisher_gui

<span style="background-color:#f5f5f5"><span style="color:#272a30"><code class="language-html">	<span style="color:#880000"><!-- 运行joint_state_publisher节点,发布机器人的关节状态  --></span><span style="color:#000088"><node</span> <span style="color:#660066">name</span><span style="color:#666600">=</span><span style="color:#008800">"joint_state_publisher_gui"</span> <span style="color:#660066">pkg</span><span style="color:#666600">=</span><span style="color:#008800">"joint_state_publisher_gui"</span> <span style="color:#660066">type</span><span style="color:#666600">=</span><span style="color:#008800">"joint_state_publisher_gui"</span> <span style="color:#000088">/></span></code></span></span>
  1. rviz中没有显示机器人模型
    首先将rviz左栏Display中Global Options-Fixed Frame改成base_link,然后左下角Add添加RobotModel,OK了。
  相关解决方案