ROS學習問題集錦(一)_機器人模擬(by古月)學習遇到的問題
原文中,建立了一個的簡單的URDF,簡單內容如下:
建立一個簡單的智慧車機器人smartcar:
一、建立硬體描述包
二、智慧車尺寸資料
三、建立urdf檔案:
建立一個urdf資料夾並創立一個urdf檔案,然後urdf程式碼如下:
這裡寫程式碼片<?xml version="1.0"?>
<robot name="smartcar">
<link name="base_link">
<visual>
<geometry>
<box size="0.25 .16 .05" />
</geometry>
<origin rpy="0 0 1.57075" xyz="0 0 0"/>
<material name="blue">
<color rgba="0 0 .8 1"/>
</material>
</visual>
</link>
<link name="right_front_wheel">
<visual>
<geometry>
<cylinder length=".02" radius="0.025"/>
</geometry>
<material name="black">
<color rgba="0 0 0 1"/>
</material>
</visual>
</link>
<joint name="right_front_wheel_joint" type="continuous">
<axis xyz="0 0 1"/>
<parent link="base_link"/>
<child link="right_front_wheel"/>
<origin rpy="0 1.57075 0" xyz="0.08 0.1 -0.03"/>
<limit effort="100" velocity="100"/>
<joint_properties damping="0.0" friction="0.0"/>
</joint>
<link name="right_back_wheel">
<visual>
<geometry>
<cylinder length=".02" radius="0.025"/>
</geometry>
<material name="black">
<color rgba="0 0 0 1"/>
</material>
</visual>
</link>
<joint name="right_back_wheel_joint" type="continuous">
<axis xyz="0 0 1"/>
<parent link="base_link"/>
<child link="right_back_wheel"/>
<origin rpy="0 1.57075 0" xyz="0.08 -0.1 -0.03"/>
<limit effort="100" velocity="100"/>
<joint_properties damping="0.0" friction="0.0"/>
</joint>
<link name="left_front_wheel">
<visual>
<geometry>
<cylinder length=".02" radius="0.025"/>
</geometry>
<material name="black">
<color rgba="0 0 0 1"/>
</material>
</visual>
</link>
<joint name="left_front_wheel_joint" type="continuous">
<axis xyz="0 0 1"/>
<parent link="base_link"/>
<child link="left_front_wheel"/>
<origin rpy="0 1.57075 0" xyz="-0.08 0.1 -0.03"/>
<limit effort="100" velocity="100"/>
<joint_properties damping="0.0" friction="0.0"/>
</joint>
<link name="left_back_wheel">
<visual>
<geometry>
<cylinder length=".02" radius="0.025"/>
</geometry>
<material name="black">
<color rgba="0 0 0 1"/>
</material>
</visual>
</link>
<joint name="left_back_wheel_joint" type="continuous">
<axis xyz="0 0 1"/>
<parent link="base_link"/>
<child link="left_back_wheel"/>
<origin rpy="0 1.57075 0" xyz="-0.08 -0.1 -0.03"/>
<limit effort="100" velocity="100"/>
<joint_properties damping="0.0" friction="0.0"/>
</joint>
<link name="head">
<visual>
<geometry>
<box size=".02 .03 .03"/>
</geometry>
<material name="white">
<color rgba="1 1 1 1"/>
</material>
</visual>
</link>
<joint name="tobox" type="fixed">
<parent link="base_link"/>
<child link="head"/>
<origin xyz="0 0.08 0.025"/>
</joint>
</robot>
四、建立launch命令檔案
在smartcar_description資料夾下建立launch資料夾,建立智慧車的描述檔案 base.urdf.rviz.launch,描述程式碼如下:
這裡寫程式碼片<launch>
<arg name="model" />
<arg name="gui" default="False" />
<param name="robot_description" textfile="$(find smartcar_description)/urdf/smartcar.urdf" />
<param name="use_gui" value="$(arg gui)"/>
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" ></node>
<node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
<node name="rviz" pkg="rviz" type="rviz" args="-d $(find urdf_tutorial)/urdf.vcg" />
</launch>
五、效果演示
roslaunch smartcar_description base.urdf.rviz.launch gui:=true
但是這裡出現了一個問題,出現如下錯誤程式碼:
ERROR: the config file ‘/opt/ros/indigo/share/urdf_tutorial/urdf.vcg’ is a .vcg file, which is the old rviz config format.
New config files have a .rviz extension and use YAML formatting. The format changed
between Fuerte and Groovy. There is not (yet) an automated conversion program.
[rviz-3] process has died [pid 9796, exit code 1, cmd /opt/ros/indigo/lib/rviz/rviz -d /opt/ros/indigo/share/urdf_tutorial/urdf.vcg __name:=rviz __log:=/home/turtlebot/.ros/log/22fdf80a-c91b-11e7-b393-54271e267424/rviz-3.log].
log file: /home/turtlebot/.ros/log/22fdf80a-c91b-11e7-b393-54271e267424/rviz-3*.log
檢查原因後發現,應該是之前博主使用的rviz是之前老的版本,所以在最後的base.urdf.rviz.launch檔案中的最後一句“ ”
改為
然後問題解決,出現瞭如下結果: