C5. Controller 控制器 #
由 ROBOTIS 開發的 open_manipulator_controller 套件,可用來控制 OpenManipulator-X 每個關節 ,以及經由 ROS messages 來檢查手臂的狀態。為了能夠操作 OpenManipulator-X 機器手臂,controller 套件必須首先執行。
其他實驗性的控制器,請參考 C 5.4. Experimental 章節。
C5.1. 啟動 controller #
開新 terminal,啟動 open_manipulator_controller。
- 如是使用 U2D2
$ roslaunch open_manipulator_controller open_manipulator_controller.launch
- 如是使用 OpenCR
$ roslaunch open_manipulator_controller open_manipulator_controller.launch usb_port:=/dev/ttyACM0 baud_rate:=1000000
open_manipulator_controller.launch 檔內有幾個參數,可啟動 controller 套件。請參考 Parameter Descriptions。

啟動 controller 成功後,在 terminal 顯示輸出結果會類似於
SUMMARY
========
PARAMETERS
* /open_manipulator_controller/control_period: 0.01
* /open_manipulator_controller/using_platform: True
* /rosdistro: noetic
* /rosversion: 1.15.9
NODES
/
open_manipulator_controller (open_manipulator_controller/open_manipulator_controller)
auto-starting new master
process[master]: started with pid [5454]
ROS_MASTER_URI=http://localhost:11311
setting /run_id to da579122-f0fa-11eb-9d7a-0790f3842b2b
process[rosout-1]: started with pid [5464]
started core service [/rosout]
process[open_manipulator_controller-2]: started with pid [5467]
port_name and baud_rate are set to /dev/ttyUSB0, 1000000
Joint Dynamixel ID : 11, Model Name : XM430-W350
Joint Dynamixel ID : 12, Model Name : XM430-W350
Joint Dynamixel ID : 13, Model Name : XM430-W350
Joint Dynamixel ID : 14, Model Name : XM430-W350
Gripper Dynamixel ID : 15, Model Name :XM430-W350
[INFO] Succeeded to init /open_manipulator_controller
C5.1.1. Parameter 參數的說明 #
- usb_port: 指定 USB 連接埠。分配給設備的實際連接埠號碼,可能因系統而異,但如果沒有其他設備,則通常該數字從 0 開始。 $ ls /dev/tty* 指令,會列出所有連接埠。
- 使用 U2D2: /dev/ttyUSB0
- 使用 OpenCR: /dev/ttyACM0
- baud_rate: 指定 DYNAMIXEL 智能馬達的 baud rate 速率。OpenMANIPULATOR-X 的預設 baud rate 是 1,000,000
- control_period: 用於指定 DYNAMIXEL 智能馬達,和 PC 之間的通訊週期的參數(控制 loop time)
- use_platform: 跑 simulation 的條件參數
- true : 使用實體 OpenManipulator-X 機器手臂來操作
- false : 在 3D 模擬器 Gazebo 內使用虛擬的 OpenManipulator-X 手臂
C5.2. 檢查設定 #
C5.2.1. Manipulator Description 手臂描述 #
公布一個 topic message 來檢查 OpenManipulator-X 設定。
$ rostopic pub /option std_msgs/String "print_open_manipulator_setting"
當執行 open_manipulator_controller 時,Manipulator Description 就會顯示在 terminal 視窗上,會顯示 OpenMANIPULATOR-X 的當前設置。
在 open_manipulator_libs 套件中,open_manipulator.cpp 檔內,跟 description 有關的參數,會被載入。
~/catkin_ws/src/open_manipulator/open_manipulator_libs/src/open_manipulator.cpp
--------------------
4.000
5.000
[Name]
-World Name : world
-Child Name : joint1
[Static Pose]
-Position :
(0.000, 0.000, 0.000)
-Orientation :
(1.000, 0.000, 0.000
0.000, 1.000, 0.000
0.000, 0.000, 1.000)
[Dynamic Pose]
-Linear Velocity :
(0.000, 0.000, 0.000)
-Linear acceleration :
(0.000, 0.000, 0.000)
-Angular Velocity :
(0.000, 0.000, 0.000)
-Angular acceleration :
(0.000, 0.000, 0.000)
[Component Type]
Tool
[Name]
-Parent Name : joint4
[Actuator]
-Actuator Name : tool_dxl
-ID : 15
-Joint Axis :
(0.000, 0.000, 0.000)
-Coefficient : -0.015
-Limit :
Maximum : 0.010, Minimum : -0.010
[Actuator Value]
-Value : 0.008
-Velocity : 0.000
-Acceleration : 0.000
-Effort : 0.000
[Constant]
-Relative Position from parent component :
(0.130, 0.000, 0.000)
-Relative Orientation from parent component :
(1.000, 0.000, 0.000
0.000, 1.000, 0.000
0.000, 0.000, 1.000)
-Mass : 0.000
-Inertia Tensor :
(1.000, 0.000, 0.000
0.000, 1.000, 0.000
0.000, 0.000, 1.000)
-Center of Mass :
(0.000, 0.000, 0.000)
[Variable]
-Position :
(0.138, -0.005, 0.015)
-Orientation :
(-0.006, 0.043, 0.999
0.000, 0.999, -0.043
-1.000, 0.000, -0.006)
-Linear Velocity :
(0.000, 0.000, 0.000)
-Linear acceleration :
(0.000, 0.000, 0.000)
-Angular Velocity :
(0.000, 0.000, 0.000)
-Angular acceleration :
(0.000, 0.000, 0.000)
[Component Type]
Active Joint
[Name]
-Parent Name : world
-Child Name 1 : joint2
[Actuator]
-Actuator Name : joint_dxl
-ID : 11
-Joint Axis :
(0.000, 0.000, 1.000)
-Coefficient : 1.000
-Limit :
Maximum : 3.142, Minimum : -3.142
[Actuator Value]
-Value : -0.043
-Velocity : 0.000
-Acceleration : 0.000
-Effort : 0.000
[Constant]
-Relative Position from parent component :
(0.012, 0.000, 0.017)
-Relative Orientation from parent component :
(1.000, 0.000, 0.000
0.000, 1.000, 0.000
0.000, 0.000, 1.000)
-Mass : 0.000
-Inertia Tensor :
(1.000, 0.000, 0.000
0.000, 1.000, 0.000
0.000, 0.000, 1.000)
-Center of Mass :
(0.000, 0.000, 0.000)
[Variable]
-Position :
(0.012, 0.000, 0.017)
-Orientation :
(0.999, 0.043, 0.000
-0.043, 0.999, 0.000
0.000, 0.000, 1.000)
-Linear Velocity :
(0.000, 0.000, 0.000)
-Linear acceleration :
(0.000, 0.000, 0.000)
-Angular Velocity :
(0.000, 0.000, 0.000)
-Angular acceleration :
(0.000, 0.000, 0.000)
[Component Type]
Active Joint
[Name]
-Parent Name : joint1
-Child Name 1 : joint3
[Actuator]
-Actuator Name : joint_dxl
-ID : 12
-Joint Axis :
(0.000, 1.000, 0.000)
-Coefficient : 1.000
-Limit :
Maximum : 1.571, Minimum : -2.050
[Actuator Value]
-Value : -0.052
-Velocity : 0.000
-Acceleration : 0.000
-Effort : 0.000
[Constant]
-Relative Position from parent component :
(0.000, 0.000, 0.058)
-Relative Orientation from parent component :
(1.000, 0.000, 0.000
0.000, 1.000, 0.000
0.000, 0.000, 1.000)
-Mass : 0.000
-Inertia Tensor :
(1.000, 0.000, 0.000
0.000, 1.000, 0.000
0.000, 0.000, 1.000)
-Center of Mass :
(0.000, 0.000, 0.000)
[Variable]
-Position :
(0.012, 0.000, 0.075)
-Orientation :
(0.998, 0.043, -0.052
-0.043, 0.999, 0.002
0.052, 0.000, 0.999)
-Linear Velocity :
(0.000, 0.000, 0.000)
-Linear acceleration :
(0.000, 0.000, 0.000)
-Angular Velocity :
(0.000, 0.000, 0.000)
-Angular acceleration :
(0.000, 0.000, 0.000)
[Component Type]
Active Joint
[Name]
-Parent Name : joint2
-Child Name 1 : joint4
[Actuator]
-Actuator Name : joint_dxl
-ID : 13
-Joint Axis :
(0.000, 1.000, 0.000)
-Coefficient : 1.000
-Limit :
Maximum : 1.530, Minimum : -1.571
[Actuator Value]
-Value : 0.546
-Velocity : 0.000
-Acceleration : 0.000
-Effort : 0.000
[Constant]
-Relative Position from parent component :
(0.024, 0.000, 0.128)
-Relative Orientation from parent component :
(1.000, 0.000, 0.000
0.000, 1.000, 0.000
0.000, 0.000, 1.000)
-Mass : 0.000
-Inertia Tensor :
(1.000, 0.000, 0.000
0.000, 1.000, 0.000
0.000, 0.000, 1.000)
-Center of Mass :
(0.000, 0.000, 0.000)
[Variable]
-Position :
(0.029, -0.001, 0.204)
-Orientation :
(0.880, 0.043, 0.474
-0.038, 0.999, -0.020
-0.474, 0.000, 0.880)
-Linear Velocity :
(0.000, 0.000, 0.000)
-Linear acceleration :
(0.000, 0.000, 0.000)
-Angular Velocity :
(0.000, 0.000, 0.000)
-Angular acceleration :
(0.000, 0.000, 0.000)
[Component Type]
Active Joint
[Name]
-Parent Name : joint3
-Child Name 1 : gripper
[Actuator]
-Actuator Name : joint_dxl
-ID : 14
-Joint Axis :
(0.000, 1.000, 0.000)
-Coefficient : 1.000
-Limit :
Maximum : 2.000, Minimum : -1.800
[Actuator Value]
-Value : 1.083
-Velocity : 0.000
-Acceleration : 0.000
-Effort : -2.690
[Constant]
-Relative Position from parent component :
(0.124, 0.000, 0.000)
-Relative Orientation from parent component :
(1.000, 0.000, 0.000
0.000, 1.000, 0.000
0.000, 0.000, 1.000)
-Mass : 0.000
-Inertia Tensor :
(1.000, 0.000, 0.000
0.000, 1.000, 0.000
0.000, 0.000, 1.000)
-Center of Mass :
(0.000, 0.000, 0.000)
[Variable]
-Position :
(0.138, -0.005, 0.145)
-Orientation :
(-0.006, 0.043, 0.999
0.000, 0.999, -0.043
-1.000, 0.000, -0.006)
-Linear Velocity :
(0.000, 0.000, 0.000)
-Linear acceleration :
(0.000, 0.000, 0.000)
-Angular Velocity :
(0.000, 0.000, 0.000)
-Angular acceleration :
(0.000, 0.000, 0.000)
---------------------------------------------
C5.2.2. RViz #
在 RViz 載入 OpenManipulator-X。
$ roslaunch open_manipulator_description open_manipulator_rviz.launch
- 安裝 Install the joint_state_publisher_gui
$ sudo apt-get install ros-noetic-joint-state-publisher-gui
- 啟動 RViz with the GUI option
$ roslaunch open_manipulator_description open_manipulator_rviz.launch use_gui:=true

C5.3. Message List #
OpenMANIPULATOR-X Controller 控制器提供 topic 和 service 訊息,來控制機器手臂並檢查機器手臂的狀態。
C5.3.1. Topic #
C5.3.1.1. Topic Monitor #
要檢視 OpenManipulator-X controller 的 topics,可使用 ROS 提供的 rqt GUI 工具,它是一個 Qt-based 框架,做為在 ROS 內開發 GUI 圖形介面使用。它是一個工具,可以在 GUI 圖形介面內單一的 topic list 上,顯示所有 topics 及附加訊息,包含 topic name,type,bandwidth,Hz,value 等資訊。
$ rqt

預設 topic values 是沒有監控的。點擊每個 topic 前的 checkbox 方塊框打 V 來開始監控。

點擊 checkbox 前的 ▶ 三角箭號圖示,來查看詳細的 topic 資訊。

C5.3.1.2. Published Topic List (發布 Topic) #
open_manipulator_controller 可發布的 topic 列表。

/states
- open_manipulator_msgs/OpenManipulatorState
- 此訊息是表示 OpenMANIPULATOR 的狀態。
- “open_manipulator_actuator_state” 表示,智能馬達是否啟用(“ACTUATOR_ENABLE”),或停用(“ACTUATOR_DISABLE”)。
- “open_manipulator_moving_state” 表示, 是否 OpenMANIPULATOR-X 正在沿軌跡移動(“IS_MOVING”)還是停止(“STOPPED”)。
/joint_states
- sensor_msgs/JointState
- 此訊息是表示 OpenMANIPULATOR-X 的關節狀態。
- “name” 表示關節組件名稱。
- “effort” 表示每個 Dynamixel 關節的電流消耗。
- “position” 和 “velocity” 表示關節的角度和角速度
/gripper/kinematics_pose
- open_manipulator_msgs/KinematicsPose
- 此訊息是表示,任務空間(task space)中的方位(位置和方向)。
- “Position” 表示終端工具(end-effector)中心的 x,y 和 z 值。
- “Orientation” 表示終端工具(end-effector)的旋轉,以 quaternion 四元數表示。
C5.3.1.3. Subscribed Topic List (訂閱 Topic) #
open_manipulator_controller 可訂閱的 topic 列表。
/option
- std_msgs/String
- 用於設置 OpenMANIPULATOR-X 選項。
- “print_open_manipulator_setting”:是請求 open_manipulator_controller 顯示 “Manipulator Description”。
/joint_states
- sensor_msgs/JointState
- 此訊息是表示 OpenMANIPULATOR-X 的關節狀態。
- “name” 表示關節組件名稱。
- “effort” 表示每個 Dynamixel 關節的電流消耗。
- “position” 和 “velocity” 表示關節的角度和角速度
/gripper/kinematics_pose
- open_manipulator_msgs/KinematicsPose
- 此訊息是表示,任務空間(task space)中的方位(位置和方向)。
- “Position” 表示終端工具(end-effector)中心的 x,y 和 z 值。
- “Orientation” 表示終端工具(end-effector)的旋轉,以 quaternion 四元數表示。
C5.3.2. Service #
C5.3.2.1. Service Server List #
open_manipulator_controller 可提供的 service servers 列表。
/goal_joint_space_path
- open_manipulator_msgs/SetJointPosition
- 用戶可以使用此服務,在關節空間(joint space)中創建軌跡(trajectory)。
- 用戶輸入目標關節的角度,和軌跡的總時間。
/goal_joint_space_path_to_kinematics_pose
- open_manipulator_msgs/SetKinematicsPose
- 用戶可以使用此服務,在關節空間(joint space)中創建軌跡(trajectory)。
- 用戶在任務空間(task space)中,輸入 OpenMANIPULATOR-X 終端工具的運動學方位(kinematics pose),和軌跡的總時間。
/goal_joint_space_path_to_kinematics_position
- open_manipulator_msgs/SetKinematicsPose
- 用戶可以使用此服務,在關節空間中創建軌跡(trajectory)。
- 用戶在任務空間(task space)中,輸入 OpenMANIPULATOR-X 終端工具的運動學方位(僅位置 position)和軌跡的總時間。
/goal_joint_space_path_to_kinematics_orientation
- open_manipulator_msgs/SetKinematicsPose
- 用戶可以使用此服務,在關節空間(joint space)中創建軌跡(trajectory)。
- 用戶在任務空間(task space)中,輸入 OpenMANIPULATOR-X 終端工具的運動學方位(僅方向 orientation)和軌跡的總時間。
/goal_task_space_path
- open_manipulator_msgs/SetKinematicsPose
- 用戶可以使用此服務,在任務空間(task space)中創建軌跡。
- 用戶在任務空間中,輸入 OpenMANIPULATOR-X 終端工具的運動學方位,和軌跡的總時間。
/goal_task_space_path_position_only
- open_manipulator_msgs/SetKinematicsPose
- 用戶可以使用此服務,在任務空間(task space)中創建軌跡。
- 用戶在任務空間中,輸入OpenMANIPULATOR-X 終端工具的運動學方位(僅位置 position)以及軌跡的總時間。
/goal_task_space_path_orientation_only
- open_manipulator_msgs/SetKinematicsPose
- 用戶可以使用此服務,在任務空間(task space)中創建軌跡。
- 用戶在任務空間中,輸入OpenMANIPULATOR-X 終端工具的運動學方位(僅方向 orientation)以及軌跡的總時間。
/goal_joint_space_path_from_present
- open_manipulator_msgs/SetJointPosition
- 用戶可以使用此服務,從關節空間(joint space)中的當前關節角度,來創建軌跡。
- 用戶輸入要改變的目標關節的角度,和軌跡的總時間。
/goal_task_space_path_from_present
- open_manipulator_msgs/SetKinematicsPose
- 用戶可以使用此服務,從任務空間(task space)中的當前運動學方位,來創建軌跡。
- 用戶輸入要在任務空間中改變的 OpenMANIPULATOR-X 終端工具的運動學方位,和軌跡的總時間。
/goal_task_space_path_from_present_position_only
- open_manipulator_msgs/SetKinematicsPose
- 用戶可以使用此服務,從任務空間(task space)中的當前運動學方位,來創建軌跡。
- 用戶輸入在任務空間中的 OpenMANIPULATOR-X 終端工具的運動學方位(僅位置 position),和軌跡的總時間。
/goal_task_space_path_from_present_orientation_only
- open_manipulator_msgs/SetKinematicsPose
- 用戶可以使用此服務,從任務空間(task space)中的當前運動學方位,來創建軌跡。
- 用戶輸入在任務空間中的 OpenMANIPULATOR-X 終端工具的運動學方位(僅方向 orientation),和軌跡的總時間。
/goal_tool_control
- open_manipulator_msgs/SetJointPosition
- 用戶可以使用此服務,來移動OpenMANIPULATOR-X 的終端工具。
/set_actuator_state
- open_manipulator_msgs/SetActuatorState
- 用戶可以使用此服務,來控制智能馬達的狀態。
- 如果用戶設置 set_actuator_state 值為 true,則啟用智能馬達。
- 如果用戶設置 set_actuator_state 值為 false,則停用智能馬達。
/goal_drawing_trajectory
- open_manipulator_msgs/SetDrawingTrajectory
- 用戶可以使用此服務,來創建繪圖軌跡。
- 用戶可以創建圓形,菱形,心形和直線軌跡。
C5.4.1.1. 安裝 MoveIt 套件 #
$ cd ~/catkin_ws/src/
$ git clone https://github.com/ROBOTIS-GIT/open_manipulator_controls.git
$ git clone -b noetic https://github.com/ROBOTIS-GIT/open_manipulator_dependencies.git
$ cd ~/catkin_ws && catkin_make
C5.4.1.2. 啟動 MoveIt! #
下列指令啟動 MoveIt!。
$ roslaunch open_manipulator_controllers joint_trajectory_controller.launch sim:=false

C5.4.1.3. 在 Gazebo 模擬器使用 MoveIt! #
Gazebo 是一個軟體工具,它無需實體機器人,就可以在一個虛擬環境中,模擬及測試你的機器人。
你可以用下列指令,在 Gazebo 虛擬環境中,使用 MoveIt 功能來操作虛擬機器人。
更多 Gazebo 資訊,可參考 Chap 7. Simulation 章節。
1. 啟動 Gazebo 模擬器及 RViz 可視化工具。
$ roslaunch open_manipulator_controllers joint_trajectory_controller.launch
2. 點擊 Gazebo 模擬器底部的 Play ▶
按鈕。
C5.4.2. Gravity Compensation 重力補償 #
讓 OpenMANIPULATOR-X 使用Gravity Compensation 套件,來補償重力。
本節介紹,如何安裝和使用 OpenMANIPULATOR-X 的 Gravity Compensation 重力補償功能。
C5.4.2.1. 安裝 Gravity Compensation 套件 #
$ cd ~/catkin_ws/src/
$ git clone https://github.com/ROBOTIS-GIT/open_manipulator_controls.git
$ cd ~/catkin_ws && catkin_make
C5.4.2.2. 設定操作模式為 Current Mode 電流模式 #
使用 Dynamixel Wizard 2.0 工具軟體,將 Dynamixel 智能馬達 Operating Mode 設為 Current Mode。

C5.4.2.3. 執行 Gravity Compensation 套件 #
使用 OpenManipulator-X 機器手臂的 Gravity Compensation 套件。
$ roslaunch open_manipulator_controllers gravity_compensation_controller.launch