本文叙述如何将turtlebot3 burger的.urdf.xacro轉化為.urdf檔案,為進一步使用turtlebot3 burger模型進行仿真做準備。
1. 建立工作空間
mkdir catkin_ws_turtlebot3
cd catkin_ws_turtlebot3
mkdir src
git clone https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
git clone https://github.com/ROBOTIS-GIT/turtlebot3.git
git clone https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git
cd ~/catkin_ws
rosdep install --from-paths src -i -y
catkin_make
2. “.urdf.xacro”檔案轉為“.urdf”檔案
turtlebot3的描述檔案位于turtlebot3_description包中,turtlebot3_burger.urdf.xacro檔案的路徑如下:
/home/xxx/catkin_ws_turtlebot3/src/turtlebot3/turtlebot3_description/urdf
執行如下指令進行檔案轉化:
cd ~/catkin_ws
catkin_make
source devel/setup.bash
cd catkin_ws_turtlebot3/src/turtlebot3/turtlebot3_description/urdf
rosrun xacro xacro.py turtlebot3_burger.urdf.xacro > turtlebot3_burger.urdf --inorder
3. 檢查urdf檔案并啟動
check_urdf turtlebot3_burger.urdf
roslaunch urdf_tutorial display.launch model:=turtlebot3_burger.urdf
注:常見報錯及注意事項
①轉化之前先進工作空間進行編譯、重新整理環境
②報錯 :“傳統處理方式已棄用”
運作
rosrun xacro xacro.py turtlebot3_burger.urdf.xacro > turtlebot3_burger.urdf
指令後,會出現如下錯誤
xacro: Traditional processing is deprecated. Switch to --inorder processing!
To check for compatibility of your document, use option --check-order.
For more infos, see http://wiki.ros.org/xacro#Processing_Order
resource not found: turtlebot3_description
ROS path [0]=/opt/ros/kinetic/share/ros
ROS path [1]=/opt/ros/kinetic/share None
when processing file: turtlebot3_burger.urdf.xacro
傳統處理方式已棄用,轉向 --inorder(無序) 方式進行處理)
To check for compatibility of your document, use option --check-order.
For more infos, see http://wiki.ros.org/xacro#Processing_Order
解決辦法:指令後面加上 --order 問題即可解決,即:
rosrun xacro xacro.py turtlebot3_burger.urdf.xacro > turtlebot3_burger.urdf --inorder
③報錯 :檔案不存在
如果出現檔案不存在的報錯,錯誤如下所示
No such file or directory: turtlebot3_burger.urdf.xacro None None
需先進工作空間進行編譯重新整理環境,再進入到描述檔案所在路徑進行轉換即可
④輪子無法顯示 ,出現如下error
[WARN] [1607996313.829612]: The 'use_gui' parameter was specified, which is deprecated. We'll attempt to find and run the GUI, but if this fails you should install the 'joint_state_publisher_gui' package instead and run that. This backwards compatibility option will be removed in Noetic.
[ERROR] [1607996313.830762]: Could not find the GUI, install the 'joint_state_publisher_gui' package
[joint_state_publisher-2] process has died [pid 7104, exit code 1, cmd /opt/ros/kinetic/lib/joint_state_publisher/joint_state_publisher __name:=joint_state_publisher __log:=/home/tianye/.ros/log/3d9c732a-3e76-11eb-89f2-84fdd1b995d3/joint_state_publisher-2.log].
log file: /home/tianye/.ros/log/3d9c732a-3e76-11eb-89f2-84fdd1b995d3/joint_state_publisher-2*.log
運作如下指令安裝GUI後重新運作
sudo apt-get install ros-kinetic-joint-state-publisher-gui
參考資料
ROS将xacro檔案轉換成URDF檔案
ROS學習之URDF
用ROS制作我們的機器人小車(一): URDF簡介
URDF中出現Could not find the GUI, install the ‘joint_state_publisher_gui’ package問題