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. 使用 SSH 指令連上 TurtleBot3 SBC
[Remote PC]
$ ssh ubuntu@{IP_ADDRESS_OF_TURTLEBOT3}
2. 安裝 TurtleBot3 Manipulation 等套件
[TurtleBot3 SBC]
$ sudo apt install ros-humble-hardware-interface ros-humble-xacro ros-humble-ros2-control ros-humble-ros2-controllers ros-humble-gripper-controllers
$ cd ~/turtlebot3_ws/src/
$ git clone -b humble https://github.com/ROBOTIS-GIT/turtlebot3_manipulation.git
$ cd ~/turtlebot3_ws && colcon build --symlink-install
3. 在 Remote PC 開 terminal,然後下列指令來安裝所需套件。
[Remote PC]
$ sudo apt install ros-humble-dynamixel-sdk ros-humble-ros2-control ros-humble-ros2-controllers ros-humble-gripper-controllers ros-humble-moveit*
$ cd ~/turtlebot3_ws/src/
$ git clone -b humble https://github.com/ROBOTIS-GIT/turtlebot3_manipulation.git
$ cd ~/turtlebot3_ws && colcon build --symlink-install
C7.4. OpenCR 控制板設定 #
將 OpenManipulator-X 手臂安裝到 TB3 後,需要上傳控制手臂馬達的韌體到 OpenCR 板,請依照下列步驟。
1. TB3 SBC 端: 下載 OpenCR 韌體到 SBC 樹莓派,及用下列指令上傳正確的韌體
[TurtleBot3 SBC]
$ export OPENCR_PORT=/dev/ttyACM0
$ export OPENCR_MODEL=turtlebot3_manipulation
$ rm -rf ./opencr_update.tar.bz2
$ wget https://github.com/ROBOTIS-GIT/OpenCR-Binaries/raw/master/turtlebot3/ROS2/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. 選擇 Sketch > Include Library > Manage Libraries… 來安裝 DYNAMIXEL2Arduino library。

7. 從 Library Manager 選單選擇DYNAMIXEL2Arduino 來安裝。

8. 開啟 TurtleBot3 Manipulation 範例
- File > Examples > turtlebot3 > turtlebot3_manipulation > turtlebot3_manipulation
9. microUSB 連接 OpenCR 板到 PC 上,從 Arduino IDE 選擇 Tools > Board > OpenCR > OpenCR Board
10. 從 Tools > Port 選單中,選擇連接 OpenCR 的 USB port
11. upload 圖示或 Ctrl+U 來上傳韌體

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

C7.5. Bringup 啟動實體 TB3 與機器手臂 #
1. 在 TurtleBot3 SBC 開新的 terminal
2. 下列指令來啟動 TurtleBot3 Manipulation
[TurtleBot3 SBC]
$ ros2 launch turtlebot3_manipulation_bringup hardware.launch.py

C7.6. 模擬 #
此節使用 Gazebo 模擬器來模擬 TB3 與 OpenManipulator-X 機器手臂。
C7.6.1. 執行 Gazebo #
在 Gazebo 模擬器內載入 TB3 with OpenManipulator-X 的檔案。
[Remote PC]
$ ros2 launch turtlebot3_manipulation_bringup gazebo.launch.py

[Remote PC]
$ ros2 launch turtlebot3_manipulation_bringup gazebo.launch.py start_rviz:=true
在 Gazebo 模擬時,要控制 TurtleBot3,必須要先啟動 MoveIt servo server node。
[Remote PC]
$ ros2 launch turtlebot3_manipulation_moveit_config servo.launch.py
啟動 keyboard teleoperation node。
[Remote PC]
$ ros2 run turtlebot3_manipulation_teleop turtlebot3_manipulation_teleop
Use o|k|l|; keys to move turtlebot base and use 'space' key to stop the base
Use s|x|z|c|a|d|f|v keys to Cartesian jog
Use 1|2|3|4|q|w|e|r keys to joint jog.
'ESC' to quit.
C7.6.2. 使用 MoveIt 來模擬 #
為了使用 MoveIt 操作 Gazebo 中的 OpenMANIPULATOR-X 手臂,請先終止其他 Gazebo 和 RViz 工具。
輸入以下命令,以使用 MoveIt 配置並啟動 RViz。
[Remote PC]
$ ros2 launch turtlebot3_manipulation_moveit_config moveit_gazebo.launch.py
RViz 上的 MoveIt 介面,將與 Gazebo 模擬器一起啟動。

C7.7. 操作實體的 OpenManipulator-X 手臂 #
要操作實體的 OpenManipulator-X 機器手臂,需要在 TurtleBot3 SBC 先執行 Chap 7.5. Bringup。
請依照下列指示,來啟動 TurtleBot3 Manipulation。
[TurtleBot3 SBC]
$ ros2 launch turtlebot3_manipulation_bringup hardware.launch.py
Remote PC 下列指令,在 RViz 啟動 MoveIt。
[Remote PC]
$ ros2 launch turtlebot3_manipulation_moveit_config moveit_core.launch.py
如要使用鍵盤 keyboard teleoperation node 來操作機器人,必須先終止 RViz。
然後在各自的 terminal 視窗上,各自啟動 servo server node 節點和 teleoperation node 節點。
[Remote PC]
$ ros2 launch turtlebot3_manipulation_moveit_config servo.launch.py
[Remote PC]
$ ros2 run turtlebot3_manipulation_teleop turtlebot3_manipulation_teleop
C7.8. SLAM #
C7.8.1. 執行 Bringup 啟動 TurtleBot3 #
使用下列指令,在實體 TB3 上啟動 TurtleBot3 Manipulation,或是在 Gazebo 模擬器的 TB3 上,啟動 TurtleBot3 Manipulation。
實體 TB3: [TurtleBot3 SBC]
$ ros2 launch turtlebot3_manipulation_bringup hardware.launch.py
Gazebo 模擬器的 TB3: [Remote PC]
$ ros2 launch turtlebot3_manipulation_bringup gazebo.launch.py
C7.8.2. 執行 SLAM node #
下列指令執行 SLAM node。
[Remote PC]
$ ros2 launch turtlebot3_manipulation_cartographer cartographer.launch.py
C7.8.3. 執行 Teleoperation Node #
1. 啟動 servo server node。
[Remote PC]
$ ros2 launch turtlebot3_manipulation_moveit_config servo.launch.py
2. 啟動 teleop node。
[Remote PC]
$ ros2 run turtlebot3_manipulation_teleop turtlebot3_manipulation_teleop
3. 使用鍵盤上的 O,K,L,: 鍵來控制 TurtleBot3 移動。
C7.8.4. 儲存地圖 #
1. 在 Remote PC 開 terminal。
2. 在 RViz,執行 nav2_map_saver 來儲存當前的地圖。
[Remote PC]
$ ros2 run nav2_map_server map_saver_cli -f ~/map

C7.9. Navigation 導航 #
C7.9.1. 執行 Bringup 啟動 TB3 #
使用下列指令,在實體 TB3 上啟動 TurtleBot3 Manipulation,或是在 Gazebo 模擬器的 TB3 上,啟動 TurtleBot3 Manipulation。
實體 TB3: [TurtleBot3 SBC]
$ ros2 launch turtlebot3_manipulation_bringup hardware.launch.py
Gazebo 模擬器的 TB3: [Remote PC]
$ ros2 launch turtlebot3_manipulation_bringup gazebo.launch.py
C7.9.2. 執行 Navigation nodes #
[Remote PC]
1. 在 Remote PC 開 terminal。
2. 下列指令來啟動 navigation 檔。
$ ros2 launch turtlebot3_manipulation_navigation2 navigation2.launch.py map_yaml_file:=$HOME/map.yaml
