Gazebo筆記(一)

Chien-lin.Tseng
My learning note
Published in
11 min readJul 8, 2019

2019年7月8日(一)

目錄:

一、網站

二、XML介紹(就是上面網站)

三、Using a URDF in Gazebo

四、(承三) 理解 rrbot.xacro 裡面在寫些什麼

一、網站

(1) gazebo 教學

(2) 可以參考的網站

(3) XML 格式

二、XML介紹(就是上面網站)

(1) 介紹

<entry>
<name>Peter Ju </name>
<tel>04-23456789</tel>
<email href="mailto:peter@hotmail.com" />
<comments> graduate student</comments>
</entry>
(我的註解:這是我更改後的。原本網頁中,</entry>似乎有寫錯?......)

標籤(tag):<tel>、</tel>都是標籤。<tel>是開始標籤(start tag),</tel>是結束標籤(end tag)。只有開始標籤內可以有屬性(attribute)。

標籤中被<>括起來的文字,稱作元素(element)。如 tel 就是元素。
成對標籤中的文字,稱為內容(content)。 如 04–23456789 就是內容。

(2) 結構

  • 元素(Element)、屬性(Atrribute)
<person id="A123456789">  和  </person>元素指的是 person
屬性(Atrribute)指的是, id="A123456789"
  • 註解(Comment):
<!--  .....................  -->
  • 若要將XML中的一段資料,包括文字與標籤都當作純文字,而不需經過剖析器來解釋其中標籤,可利用
<![CDATA[.............]]> (我的註解:上面這條是我另外找的,原本網站貌似打錯......)

(3) 範例

三、Using a URDF in Gazebo

(1) 拿到 RRBot 程式
RRBot是一個 3-linkage 2-joint arm (我目前的解讀是:3條線、2個關節)

cd ~/catkin_ws/src/
git clone https://github.com/ros-simulation/gazebo_ros_demos.git
cd ..
catkin_make

(2) 檢查一下RRBot(用 Rviz)

roslaunch rrbot_description rrbot_rviz.launch---------------------------------------------------------
突然發現一件事:
roslaunch ,目的是一次性啟動多個節點,
如果執行 roslaunch 時沒有roscore,它會自己roscore !!
如果執行 roslaunch 時有roscore,它會使用現有的roscore 。
以上說明,在下列的網站中。

注意,這裡可能會有bug(因為沒有一些程式),要自己加上去:

ERROR: cannot launch node of type [joint_state_publisher/joint_state_publisher]: joint_state_publisher
--------------------------------------------------------------
遇到這種 error 時,執行:
sudo apt-get install ros-kinetic-joint-state-publisher
--------------------------------------------------------------
遇到其他兩個類似問題時,將 joint-state-publisher替換成對應的項目
sudo apt-get install ros-kinetic-xxxx

成功之後的圖:

這個可以自己調整

(3) 檢查 RRBot URDF

The rest of this tutorial will refer to various aspects of the RRBot URDF. Go ahead and view the rrbot.xacro file now: (這句是抄教學的)

rosed rrbot_description rrbot.xacro// 這個指令會到 rrbot_description包下,找到rrbot.xacro,並且vim它
---------------------------------------------------------
註解:如果打不開的話,在 catkin_ws source一下環境
source devel/setup.bash

(4) 在 Gazebo內看

launch RRBot into Gazebo:

roslaunch rrbot_gazebo rrbot_world.launch

成功的樣子,它會一直晃動,直到平衡:

四、(承三) 理解 rrbot.xacro 裡面在寫些什麼

(1) 重要:把 rrbot.xacro 對照著看

rosed rrbot_description rrbot.xacro

(2) Header of a URDF File

All you need in your root element tag is the name of the robot and optionally the xml namespace for xacro if you are using that. (抄的)

大略翻譯:在你的 root element tag 中,需要的只有 the name of the robot 和 the xml namespace for xacro (不一定要)。
註:xmlns應該就是 xml namespace。
下方是例子:

<robot name="rrbot" xmlns:xacro="http://www.ros.org/wiki/xacro"> 

(3) Rigidly Fixing A Model to the World (想要固定機器人在一個定點)

If you would like your URDF model to be permanently attached to the world frame (the ground plane), you must create a “world” link and a joint that fixes it to the base of your model.
大略翻譯: 如果想要把 URDF model 永久固定在一個位子,則要創立一個 “world” link 和 一個 joint 。 範例如下:

  <!-- Used for fixing robot to Gazebo 'base_link' -->
<link name="world"/>

<joint name="fixed" type="fixed">
<parent link="world"/>
<child link="link1"/>
</joint>
---------------------------------------------------------------
目前的解讀:
先創立一個link,我覺得link應該就是一條東西,或一個物體,
再仔細創立一個joint(關節),這個joint中要填入parent link、child link (可以當作前一個物體、下一個物體)。

下面是註解:

<link name="world"/><link name="world"></link>
兩者理論上是一樣,但之後要試試看是否能用,打個問號?
(7月14日測試) 都可以用!!

(4) Links

the following is an example link from RRBot:
下面是從 RRBot 貼過來的 link example:

  <!-- Base Link -->
<link name="link1">
<collision>
<origin xyz="0 0 ${height1/2}" rpy="0 0 0"/>
<geometry>
<box size="${width} ${width} ${height1}"/>
</geometry>
</collision>

<visual>
<origin xyz="0 0 ${height1/2}" rpy="0 0 0"/>
<geometry>
<box size="${width} ${width} ${height1}"/>
</geometry>
<material name="orange"/>
</visual>

<inertial>
<origin xyz="0 0 1" rpy="0 0 0"/>
<mass value="1"/>
<inertia
ixx="1.0" ixy="0.0" ixz="0.0"
iyy="1.0" iyz="0.0"
izz="1.0"/>
</inertial>
</link>

注意一下:gazebo使用的單位為 公斤與公尺。

(5) 承(4) 繼續介紹<collision> and <visual> elements

These tags work essentially the same in Gazebo as in Rviz. It is important that you specify both though, because unlike some ROS applications, Gazebo will not use your <visual> elements as <collision> elements if you do not explicitly specify a <collision> element. Instead, Gazebo will treat your link as "invisible" to laser scanners and collision checking. (抄網站的)
英文要看,另外有個大概意思是:<visual>和<collision>都要寫

  • Simplify collision model:
    這段我暫時跳過
  • Materials: Using proper colors and textures

A standard URDF can specify colors using a tag such as in the RRBot:

<material name="orange"/>

剩下跳過。

  • STL and Collada files:

我跳過。

(6) 承(4)<inertial> Element

先關掉,記得重新啟動 roslaunch rrbot_gazebo rrbot_world.launch

--

--