C7. Manipulation 機器手臂 #
C7.1. TurtleBot3 跟 OpenManipulator-X 機器手臂 #

ROBOTIS 的 OpenManipulator-X 小型機器手臂,是支援 ROS 的機器手臂之一。其優點是使用 Dynamixel 智能馬達跟 3D 列印出來的零配件,可製造出成本低的機器手臂。
OpenManipulator-X 小型機器手臂的優點,是可與 TB3 Waffle 跟 TB3 Waffle Pi 款相容。通過這種相容性,可以彌補手臂自由度的不足,並可通過 TB3 已加載的 SLAM 和 Navigation 導航的功能,讓 TB3 變成更具完整性的服務機器人。TB3 及 OpenManipulator-X 的結合,可以作為 mobile manipulator 移動式機器手臂使用,執行下列影片中的操作。
C7.2. 手臂軟體設定 #
1. 在 Remote PC 上下載,build OpenManipulator 相關套件,以便後續手臂組裝後使用
[Remote PC]
$ cd ~/catkin_ws/src/
$ git clone -b noetic https://github.com/ROBOTIS-GIT/turtlebot3_manipulation.git
$ git clone -b noetic https://github.com/ROBOTIS-GIT/turtlebot3_manipulation_simulations.git
$ git clone -b noetic https://github.com/ROBOTIS-GIT/open_manipulator_dependencies.git
$ sudo apt install ros-noetic-ros-control* ros-noetic-control* ros-noetic-moveit* ros-noetic-dwa-local-planner
$ cd ~/catkin_ws && catkin_make
- 如果 catkin_make 完成沒有錯誤,OpenManipulator 套件就安裝成功。你就可以在 RViz 中,載入搭載有 OpenManipulator-X 手臂的 TB3 Waffle or TB3 Waffle Pi 模型。
$ cd ~/catkin_ws && catkin_make
$ cd ~/catkin_ws/src/
$ git clone https://github.com/ROBOTIS-GIT/open_manipulator_with_tb3.git
$ git clone https://github.com/ROBOTIS-GIT/open_manipulator_with_tb3_msgs.git
$ git clone https://github.com/ROBOTIS-GIT/open_manipulator_with_tb3_simulations.git
$ git clone https://github.com/ROBOTIS-GIT/open_manipulator_perceptions.git
$ sudo apt-get install ros-melodic-smach* ros-melodic-ar-track-alvar ros-melodic-ar-track-alvar-msgs
$ cd ~/catkin_ws && catkin_make
C7.4. OpenCR 控制板設定 #
將 OpenManipulator-X 手臂安裝到 TB3 後,需要上傳控制手臂馬達的韌體到 OpenCR 板,請依照下列步驟。
1. TB3 SBC 端: 下載 OpenCR 韌體到 SBC 樹莓派,及用下列指令上傳正確的韌體
[TurtleBot3 SBC]
$ export OPENCR_PORT=/dev/ttyACM0
$ export OPENCR_MODEL=om_with_tb3_noetic
$ rm -rf ./opencr_update.tar.bz2
$ wget https://github.com/ROBOTIS-GIT/OpenCR-Binaries/raw/master/turtlebot3/ROS1/latest/opencr_update.tar.bz2
$ tar -xvf opencr_update.tar.bz2
$ cd ./opencr_update
$ ./update.sh $OPENCR_PORT $OPENCR_MODEL.opencr
2. 當上傳完成,你會看到 terminal 上出現 jump_to_fw 的字串。

C7.4.1. 使用 Arduino IDE 來上傳韌體 #
補充資料:了解更多有關,如何使用 Arduino IDE 來上傳韌體。 #
1. 如 PC 的 OS 是 Linux,下列指令設定 OpenCR 的 USB port。如果其他 OS(OSX or Windows),可跳過此步驟。
$ wget https://raw.githubusercontent.com/ROBOTIS-GIT/OpenCR/master/99-opencr-cdc.rules
$ sudo cp ./99-opencr-cdc.rules /etc/udev/rules.d/
$ sudo udevadm control --reload-rules
$ sudo udevadm trigger
$ sudo apt install libncurses5-dev:i386
2. 安裝 Arduino IDE
– 下載最新的 Arduino IDE
3. 安裝好後,執行 Arduino IDE
4. 按 Ctrl + , 來打開 Preferences menu
5. 在 Additional Boards Manager URLs 輸入下列位址
https://raw.githubusercontent.com/ROBOTIS-GIT/OpenCR/master/arduino/opencr_release/package_opencr_index.json

6. 打開 TurtleBot3 with OpenMANIPULATOR 韌體。
– 依你的平台選擇對應的韌體。
TurtleBot3 with OpenMANIPULATOR : File > Examples > turtlebot3 > turtlebot3_with_open_manipulator > turtlebot3_with_open_manipulator_core
7. 在 turtlebot3_with_open_manipulator_core.h 檔案內,取消 #define NOETIC_SUPPORT 的註釋,然後儲存
8. 連接 OpenCR 板到 PC 上,從 Tools > Board 選單選擇 OpenCR > OpenCR Board
9. 從 Tools > Port 選單中選擇連接 OpenCR 的 USB port
10. upload 圖示或 Ctrl+U 來上傳韌體


11. 如果上傳失敗,可以嘗試在 recovery mode 下重新上傳韌體。OpenCR 的 recovery mode 啟動順序如下。在 recovery mode 時,OpenCR 的 STATUS led 燈會定時的閃爍。
- 按住 PUSH SW2 鍵
- 按一下 Reset 鍵
- 然後鬆開 Reset 鍵
- 再鬆開 PUSH SW2 鍵

C7.5. Bringup 啟動 TB3 與機器手臂 #
C7.5.1. 執行 roscore #
在 Remote PC 新開 terminal 執行 roscore
[Remote PC]
$ roscore
C7.5.2. 定義 TurtleBot3 Model #
如果 TURTLEBOT3_MODEL 並沒有在 .bashrc 檔內定義, 則要輸出 TB3 Model 參數 (waffle or waffle_pi) 到 .bashrc 檔內
[TurtleBot3 SBC]
$ export TURTLEBOT3_MODEL=waffle_pi
C7.5.3. 啟動 TB3 #
在 TB3 SBC,啟動 TB3,開始 rosserial 及 LDS sensor
[TurtleBot3 SBC]
$ roslaunch turtlebot3_bringup turtlebot3_robot.launch
C7.6. 模擬 #
此節使用 Gazebo 模擬器來模擬 TB3 與 OpenManipulator-X 機器手臂。
C7.6.1. 執行 Gazebo #
在 Gazebo 模擬器內載入 TB3 with OpenManipulator-X 的檔案。
[Remote PC]
$ roslaunch turtlebot3_manipulation_gazebo turtlebot3_manipulation_gazebo.launch

C7.6.2. 執行 move_group node #
要能夠使用 MoveIt 功能,需啟動 move_group node。使用下列指令開啟 Gazebo,點擊 [▶] 鍵來開始模擬。如果啟動成功,會出現 “You can start planning now!” 訊息。
[Remote PC]
$ roslaunch turtlebot3_manipulation_moveit_config move_group.launch
C7.6.3. 執行 RViz #
讀取 moveit.rviz 檔後,就可以在 RViz 內使用 MoveIt 功能。moveit.rviz 檔是用來設置 MoveIt 環境。
你可以使用 interactive marker 來控制已安裝的機器手臂,並模擬手臂移動到 goal position,通過事前的手臂模擬移動,有助於防止可能的實際性接觸。
[Remote PC]
$ roslaunch turtlebot3_manipulation_moveit_config moveit_rviz.launch

C7.6.4. 執行 ROBOTIS GUI Controller 圖形介面控制器 #
你也可以使用 ROBOTIS GUI 圖形介面在 Gazebo 內控制 OpenManipulator-X 機器手臂。GUI controller 支援 Task Space Control 及 Joint Space Control 兩種方式由你選擇。
- Task Space Control: 基於 OpenMANIPULATOR-X 末端執行器的有效夾取位置(表示為爪手之間的小紅色立方體)進行控制。
- Joint Space Control: 根據每個關節角度進行控制。
[Remote PC]
$ roslaunch turtlebot3_manipulation_gui turtlebot3_manipulation_gui.launch

C7.7. 操作實體的 OpenManipulator-X 手臂 #
請依照下列指示來操作。
C7.7.1. 執行 roscore #
執行 roscore 來跑 ROS1
[Remote PC]
$ roscore
C7.7.2. 執行 Bringup 啟動 #
1. 在 TB3 SBC,執行 Bringup node 啟動 TB3,開始 rosserial 及 LDS sensor
[TurtleBot3 SBC]
$ roslaunch turtlebot3_bringup turtlebot3_robot.launch
2. 在 TB3 執行 OpenManipulator-X 的 Bringup 啟動套件
[Remote PC]
$ roslaunch turtlebot3_manipulation_bringup turtlebot3_manipulation_bringup.launch
C7.7.3. 執行 move_group node #
[Remote PC]
$ roslaunch turtlebot3_manipulation_moveit_config move_group.launch
C7.7.4. 執行 RViz #
執行 RViz 來可視化觀看數據,及使用 interactive marker
[Remote PC]
$ roslaunch turtlebot3_manipulation_moveit_config moveit_rviz.launch
C7.7.5. 執行 ROBOTIS GUI Controller #
使用 ROBOTIS GUI Controller 取代 RViz tool 來控制機器手臂
[Remote PC]
$ roslaunch turtlebot3_manipulation_gui turtlebot3_manipulation_gui.launch
C7.8. SLAM #
TB3 與 OpenManipulator-X 使用 SLAM 功能在未知地圖上建圖。

C7.8.1. 執行 roscore #
執行 roscore 來跑 ROS1
[Remote PC]
$ roscore
C7.8.2. 執行 Bringup 啟動 #
在 TB3 SBC,執行 Bringup node 啟動 TB3,開始 rosserial 及 LDS sensor
[TurtleBot3 SBC]
roslaunch turtlebot3_bringup turtlebot3_robot.launch
C7.8.3. 執行 SLAM node #
執行 SLAM node 來 update 未知地圖,預設是 gmapping package。
[Remote PC]
$ roslaunch turtlebot3_manipulation_slam slam.launch
C7.8.4. 執行 turtlebot3_teleop_key Node #
1. 使用 turtlebot3_teleop_key Node 來控制 TB3 移動,以建立更新地圖。
[Remote PC]
$ roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch
2. 一旦建好地圖,執行 map_saver node 儲存地圖。
[Remote PC]
$ rosrun map_server map_saver -f ~/map
C7.9. Navigation 導航 #
使用 Navigation node,讓 TB3+OpenManipulator-X 機器人,移動到指定位置。
C7.9.1. 執行 roscore #
[Remote PC]
$ roscore
C7.9.2. 執行 Bringup 啟動 #
在 TB3 SBC,執行 Bringup node 啟動 TB3,開始 rosserial 及 LDS sensor
[TurtleBot3 SBC]
roslaunch turtlebot3_bringup turtlebot3_robot.launch
C7.9.3. 執行 Navigation node #
下列指令執行 Navigation node,會呼叫 urdf 格式(Unified Robot Description Format) 機器人模型及 RViz 設定資料,來設置 GUI 環境,Navigation 參數及更新地圖。
[Remote PC]
$ roslaunch turtlebot3_manipulation_navigation navigation.launch map_file:=$HOME/map.yaml

C7.9.4. 如何在 Navigation 時控制 OpenManipulator-X 手臂 #
Navigation node 執行後,當 TurtleBot3 接近目標位置時,你可以運行此節點,來控制 TurtleBot3 上的 OpenManipulator-X 手臂。但是,當 TurtleBot3 處於移動狀態時,OpenManipulator-X 手臂的運動會受到外部影響,例如重心或振動的影響而不穩定;因此建議在 TurtleBot3 不移動時才使用機器手臂。
C7.9.4.1. 執行 OpenManipulator 的 Bringup 啟動 #
執行 turtlebot3_manipulation_bringup node 就如單獨使用手臂一樣。此節點包含 arm_controller 跟 gripper_controller.
[Remote PC]
$ roslaunch turtlebot3_manipulation_bringup turtlebot3_manipulation_bringup.launch
C7.9.4.2. 執行 move_group Node #
move_group node 支援兩種介面來控制 OpenManipulator-X 手臂: MoveIt! 及 ROBOTIS GUI。選擇任一你偏愛的方式。此章節只介紹 ROBOTIS GUI 方式。
[Remote PC]
$ roslaunch turtlebot3_manipulation_moveit_config move_group.launch
C7.9.5. 執行 ROBOTIS GUI Controller #
使用此介面來控制 TB3 上的 OpenManipulator-X 手臂。
[Remote PC]
$ roslaunch turtlebot3_manipulation_gui turtlebot3_manipulation_gui.launch
C7.10. TurtleBot3 Home Service Challenge 居家服務挑戰賽 #

C7.10.1. 開始入門 #
C7.10.1.1. 先決條件 #
[Remote PC]
- 安裝好 ROS1 Noetics 的 remote PC(筆電/桌電)
- 本節指令是基於 Gazebo simulation
C7.10.1.2. Remote PC 設定 #
1. 安裝 Home Service Challenge packages
[Remote PC]
$ cd ~/catkin_ws/src/
$ git clone -b noetic https://github.com/ROBOTIS-GIT/turtlebot3_home_service_challenge.git
$ git clone -b noetic-devel https://github.com/machinekoder/ar_track_alvar
$ cd ~/catkin_ws && catkin_make
2. 在 RViz 載入 TB3 Waffle(or Waffle Pi) with OpenManipulator-X 手臂
[Remote PC]
$ export TURTLEBOT3_MODEL=${TB3_MODEL}
$ roslaunch turtlebot3_manipulation_description turtlebot3_manipulation_view.launch use_gui:=true

C7.10.4. Missions 任務 #
C7.10.4.1. 執行 Demo 及 Manager 套件 #
1. 執行 Gazebo Simulation
[Remote PC]
$ roslaunch turtlebot3_home_service_challenge_simulation competition.launch
2. 在 Gazebo 模擬器執行 simulation demo
[Remote PC]
$ roslaunch turtlebot3_home_service_challenge_tools turtlebot3_home_service_challenge_demo_simulation.launch

3. 執行 manager package,是用來運行 Home Service Challenge 任務
[Remote PC]
$ roslaunch turtlebot3_home_service_challenge_manager manager.launch
C7.10.4.2. 不同的指令 #
在 Home Service Challenge 挑戰賽使用下列指令。
[Remote PC]
- Ready : TurtleBot3 準備開始任務
$ rostopic pub -1 /tb3_hsc/command std_msgs/String ready_mission
- Start : TurtleBot3 開始任務
$ rostopic pub -1 /tb3_hsc/command std_msgs/String start_mission
- Stop : TurtleBot3 停止執行任務
$ rostopic pub -1 /tb3_hsc/command std_msgs/String stop_mission
- Restart : TurtleBot3 依照一個給定的情境,重新開始執行任務
$ rostopic pub -1 /tb3_hsc/command std_msgs/String restart_mission:SCENARIO_NAME
C7.10.4.3. Operation Test 操作測試 #
發布下列 topics 來測試 navigation 導航跟 manipulation 機器手臂功能。
- Navigation 導航
[Remote PC]
$ rostopic pub -1 /tb3_hsc/command std_msgs/String nav_start

$ rostopic pub -1 /tb3_hsc/command std_msgs/String nav_ar_marker_0

$ rostopic pub -1 /tb3_hsc/command std_msgs/String nav_ar_marker_1

$ rostopic pub -1 /tb3_hsc/command std_msgs/String nav_ar_marker_2

$ rostopic pub -1 /tb3_hsc/command std_msgs/String nav_ar_marker_3

- Manipulation 機器手臂操作
[Remote PC]
$ rostopic pub -1 /tb3_hsc/command std_msgs/String arm_home

$ rostopic pub -1 /tb3_hsc/command std_msgs/String arm_joint

$ rostopic pub -1 /tb3_hsc/command std_msgs/String arm_task

$ rostopic pub -1 /tb3_hsc/command std_msgs/String open_gripper

$ rostopic pub -1 /tb3_hsc/command std_msgs/String close_gripper

C7.10.4.4. Configuration 設置 #
依據所給的環境,可修改 configuration 設置檔內的資料。
- scenario.yaml: 此檔案包含 scenario 情境資料
– 檔案路徑: /turtlebot3_home_service_challenge_manager/script/scenario.yaml
– 腳本 script 檔
[Remote PC]
SCENARIO_NAME: # start - scenario - finish
task: TASK_NAME
args: [0, 1, 2]
timeout: 10 #sec, 0 : no time out
next_scenario: find_object
scenario_on_failure: standby
retry_times: 0 #times, 0 : no retry
- room.yaml: 此檔案包含 Home Service 挑戰賽場地數據
– 檔案路徑: /turtlebot3_home_service_challenge_manager/config/room.yaml
– 腳本 script 檔
[Remote PC]
room_1:
name: toilet
object:
marker: ar_marker_0
position: [0.25, 0, 0.15]
target:
marker: ar_marker_4
position: [0.25, 0, 0.15]
x: [1.5, 0.6]
y: [1.5, 0.2]
- config.yaml: 此設定檔包含 manager package 的資料
– 檔案路徑: /turtlebot3_home_service_challenge_manager/config/config.yaml
C7.10.4.5. Home Service 挑戰賽任務細節 #
居家服務挑戰賽的目標,是按照給定的規則,將四個不同的物體,從客廳移動到特定的地方,然後返回起點。
使用 demo package,在挑戰賽中移動物體的流程如下:
1. 導航到客廳的一個目標
- 找到目標,然後使用 Navigation package 導航抵達目標位置
2. 接近目標位置
- 為了精確的接近目標,TurtleBot3 輪子,直接由通過 AR marker 計算目標位置來控制。(使用的 topic: /tb3_hsc/cmd_vel)。為了產生可靠的效能,閉迴路 Closed-loop 和控制系統的使用,可以指定的次數。
3. 使用 OpenManipulator-X 爪夾抓取目標處物件
- 使用 moveit package 來抓取物件(Joint space control, Task space control 及 Gripper control)

4. 離開到下個房間放置物件(使用的 topic: /tb3_hsc/cmd_vel)
- 當從目標處往回走時,輪子由 mamager 程式使用 /tb3_hsc/cmd_vel topic 直接控制
5. 導航到要安置物件的目標處
- 找下一個目標,使用 Navigation package 導航抵達目標處位置
6. 接近目標
7. 使用爪手放置物件
8. 使用 Navigation package 回到起始點
C7.10.5. 用 Gazebo 來模擬 #
在 Gazebo 模擬器中,模擬 TB3 附OpenManipulator-X 進行 Home Service 挑戰賽
1. 執行 Gazebo
[Remote PC]
$ roslaunch turtlebot3_home_service_challenge_simulation competition.launch

2. 在 Gazebo 跑 simulation demo
[Remote PC]
$ roslaunch turtlebot3_home_service_challenge_tools turtlebot3_home_service_challenge_demo_simulation.launch

3. 執行 Home Service Manager
[Remote PC]
$ roslaunch turtlebot3_home_service_challenge_manager manager.launch
4. 使用 Home Service Manager 指令(參考 Chap 7.10.4.2.)