## 工具控制
注意:請在 studio 界面選擇已安裝的末端執行器后再使用調用接口控制末端執行器。
接口文件: gauss/gauss_python_api/src/gauss_python_api/gauss_api.py
- 接口: gauss/commander/robot_action
- ROS 接口類型: Action
- 接口內容: RobotMoveAction
工具接口支持: gripper、air_vacuum、electromagnet、DCMOTOR、laser 等工具
- gripper 為電機控制
- electromagnet、DCMOTOR、laser、air_vacuum 為 digital_io 控制
end_effectors.yaml 文件列出了各種工具的參數等信息:
```
command_list:
# Gripper
open_gripper: 1
close_gripper: 2
# Vacuump pump
pull_air_vacuum_pump: 10
push_air_vacuum_pump: 11
# Tools controlled by digital I/Os
setup_digital_io: 20
activate_digital_io: 21
deactivate_digital_io: 22
tool_list:
- name: "Gripper 1"
type: "gripper"
id: 11
available_commands:
- open_gripper
- close_gripper
specs:
open_position: 600
open_hold_torque: 404
close_position: 350
close_hold_torque: 404
close_max_torque: 1023
open_speed: 300
close_speed: 300
- name: "Gripper 2"
type: "gripper"
id: 12
available_commands:
- open_gripper
- close_gripper
specs:
open_position: 640
open_hold_torque: 128
close_position: 400
close_hold_torque: 128
close_max_torque: 1023
open_speed: 300
close_speed: 300
- name: "Gripper 3"
type: "gripper"
id: 13
available_commands:
- open_gripper
- close_gripper
specs:
open_position: 450
open_hold_torque: 128
close_position: 220
close_hold_torque: 160
close_max_torque: 1023
open_speed: 300
close_speed: 300
- name: "Electromagnet 1"
type: "electromagnet"
id: 30
available_commands:
- activate_digital_io
- deactivate_digital_io
- setup_digital_io
specs:
[]
- name: "Vacuum Pump 1"
type: "vacuum_pump"
id: 31
available_commands:
- pull_air_vacuum_pump
- push_air_vacuum_pump
specs:
[]
- name: "Laser 1"
type: "laser"
id: 32
available_commands:
- activate_digital_io
- deactivate_digital_io
- setup_digital_io
specs:
[]
- name: "DC Motor 1"
type: "dc_motor"
id: 33
available_commands:
- activate_digital_io
- deactivate_digital_io
- setup_digital_io
specs:
[]
```
示例代碼參考`gauss/gauss_python_api/src/gauss_python_api/gauss_api.py`文件:
```python
def open_gripper(self, gripper_id, speed):
goal = RobotMoveGoal()
goal.cmd.cmd_type = MoveCommandType.TOOL
goal.cmd.tool_cmd.tool_id = int(gripper_id)
goal.cmd.tool_cmd.cmd_type = self.tool_command_list['open_gripper']
goal.cmd.tool_cmd.gripper_open_speed = speed
return self.execute_action('gauss/commander/robot_action', RobotMoveAction, goal)
def close_gripper(self, gripper_id, speed):
goal = RobotMoveGoal()
goal.cmd.cmd_type = MoveCommandType.TOOL
goal.cmd.tool_cmd.tool_id = int(gripper_id)
goal.cmd.tool_cmd.cmd_type = self.tool_command_list['close_gripper']
goal.cmd.tool_cmd.gripper_close_speed = speed
return self.execute_action('gauss/commander/robot_action', RobotMoveAction, goal)
def pull_air_vacuum_pump(self, vacuum_pump_id):
goal = RobotMoveGoal()
goal.cmd.cmd_type = MoveCommandType.TOOL
goal.cmd.tool_cmd.tool_id = int(vacuum_pump_id)
goal.cmd.tool_cmd.cmd_type = self.tool_command_list['pull_air_vacuum_pump']
return self.execute_action('gauss/commander/robot_action', RobotMoveAction, goal)
def push_air_vacuum_pump(self, vacuum_pump_id):
goal = RobotMoveGoal()
goal.cmd.cmd_type = MoveCommandType.TOOL
goal.cmd.tool_cmd.tool_id = int(vacuum_pump_id)
goal.cmd.tool_cmd.cmd_type = self.tool_command_list['push_air_vacuum_pump']
return self.execute_action('gauss/commander/robot_action', RobotMoveAction, goal)
def setup_electromagnet(self, electromagnet_id, pin):
goal = RobotMoveGoal()
goal.cmd.cmd_type = MoveCommandType.TOOL
goal.cmd.tool_cmd.tool_id = int(electromagnet_id)
goal.cmd.tool_cmd.cmd_type = self.tool_command_list['setup_digital_io']
goal.cmd.tool_cmd.gpio = pin
return self.execute_action('gauss/commander/robot_action', RobotMoveAction, goal)
def activate_electromagnet(self, electromagnet_id, pin):
goal = RobotMoveGoal()
goal.cmd.cmd_type = MoveCommandType.TOOL
goal.cmd.tool_cmd.tool_id = int(electromagnet_id)
goal.cmd.tool_cmd.cmd_type = self.tool_command_list['activate_digital_io']
goal.cmd.tool_cmd.gpio = pin
return self.execute_action('gauss/commander/robot_action', RobotMoveAction, goal)
def deactivate_electromagnet(self, electromagnet_id, pin):
goal = RobotMoveGoal()
goal.cmd.cmd_type = MoveCommandType.TOOL
goal.cmd.tool_cmd.tool_id = int(electromagnet_id)
goal.cmd.tool_cmd.cmd_type = self.tool_command_list['deactivate_digital_io']
goal.cmd.tool_cmd.gpio = pin
return self.execute_action('gauss/commander/robot_action', RobotMoveAction, goal)
```
## 可選接口(一)
- gauss/tool_action 控制末端執行器執行動作
- gauss/change_tool 改變末端的工具
- /gauss/current_tool_id
## 可選接口(二)
注意:該接口為最底層的接口,一般只用于調試。
- gauss/tools/open_gripper
- gauss/tools/close_gripper
- 引言
- 第一章 開關機和網絡配置
- 開關機和網絡連接
- 開機啟動腳本
- 多機通信
- 安裝必要的ROS包
- 第二章 軟件架構
- 第三章 機械臂模型
- 第四章 Python API
- calibrate_auto
- learning_mode
- move_joints
- move_pose
- gripper
- air_vacuum_pump
- electromagnet
- 第五章 ROS接口
- 示教模式
- 關節空間
- 笛卡爾空間
- 運動規劃
- 工具控制
- 自定義消息
- 重新校準
- 自動校準
- 硬件狀態
- 第六章 參數說明
- rpi_ros_processes
- gauss_motors
- robot_command_validation
- stepper_params
- gauss_driver
- end_effectors
- 第七章 launch文件
- rpi_setup
- controllers
- robot_commander
- user_interface
- 第八章 視覺抓取
- 第九章 常見問題