Skip to content

Commit 3d4fa89

Browse files
author
HoranTian
committed
增加stop按键,重构文件结构
1 parent 8369c15 commit 3d4fa89

File tree

8 files changed

+104
-60
lines changed

8 files changed

+104
-60
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ src/piper/backup
1313
analytical_solution
1414
oculus_reader
1515
/__pycache__
16+
/scripts/__pycache__

README(EN).md

Lines changed: 82 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -18,109 +18,124 @@ Test:
1818

1919
### 1.1 Installation Environment
2020

21-
Note: Python version is 3.10, it is recommended to use a conda environment, and python-can version should be higher than 4.3.1.
21+
Note: The Python version should be 3.10. It is recommended to use a conda environment, and the python-can version should be higher than 4.3.1.
2222

23-
Create and activate the conda environment
23+
Create and activate the conda environment:
2424

2525
```shell
2626
conda create -n pyqt5 python=3.10
2727
```
28+
2829
```shell
2930
conda activate pyqt5
3031
```
3132

3233
### 1.2 Install Dependencies
3334

34-
Install can and sdk
35+
Install can and sdk:
3536

3637
```shell
3738
pip3 install python-can
3839
```
40+
3941
```shell
4042
pip3 install piper_sdk
4143
```
4244

43-
View the details of piper_sdk, such as installation path, version, etc.
45+
Check the details of piper_sdk, such as installation path, version, etc.:
4446

4547
```shell
4648
pip3 show piper_sdk
4749
```
48-
Ensure that the SDK version is 0.1.9.
4950

50-
0.0.x is the sdk version supported before the robotic arm V1.5-2 firmware.
51+
Ensure the sdk version is 0.1.9.
5152

52-
The last version number of 0.0.x is 0.1.9.
53+
The 0.0.x versions support firmware versions prior to robotic arm V1.5-2.
5354

54-
To uninstall
55+
The last version of 0.0.x is 0.1.9.
56+
57+
To uninstall:
5558

5659
```shell
5760
pip3 uninstall piper_sdk
5861
```
5962

60-
### 1.2 Install can Tools
63+
### 1.3 Install CAN Tools
6164

6265
```shell
6366
sudo apt update && sudo apt install can-utils ethtool
6467
```
6568

66-
If you encounter ip: command not found when executing bash scripts, install the ip command with sudo apt-get install iproute2.
69+
If you encounter the error "ip: command not found" when running a bash script, install the `ip` command by running:
70+
71+
```shell
72+
sudo apt-get install iproute2
73+
```
74+
75+
### 1.4 Install PyQt5
6776

68-
### 1.3 Install PyQt5
77+
Install Qt development tools:
6978

70-
Install Qt development tools
7179
```shell
7280
sudo apt install qt5-qmake qtbase5-dev
7381
```
7482

75-
Install PyQt5
83+
Install PyQt5:
7684

7785
```shell
7886
pip install pyqt5
79-
8087
```
88+
8189
## 2 Quick Start
8290

83-
### 2.1 Run
91+
### 2.1 Running
8492

8593
#### 2.1.1 Regular Run
8694

8795
```shell
8896
cd ~/Piper_sdk_ui
8997
conda activate pyqt5
9098
```
99+
91100
```shell
92101
python piper_ui.py
93102
```
94103

95104
#### 2.1.2 Quick Run
96105

97-
Configuration (Note: Bash terminal required)
106+
Configure (make sure it's a bash terminal).
98107

99-
Check the conda environment location
108+
Check the location of your conda environment:
100109

101110
```shell
102111
conda env list
103112
```
104-
Output the environment location, for example
113+
114+
Example output:
115+
105116
```
106117
# conda environments:
107118
#
108119
base /home/tian/miniconda3
109120
pyqt /home/tian/miniconda3/envs/pyqt
110121
```
111-
Add a shortcut command in ./bashrc
122+
123+
Add a shortcut command to `~/.bashrc`:
124+
112125
```shell
113126
echo "alias pui='~/miniconda3/envs/pyqt5/bin/python ~/Piper_sdk_ui/piper_ui.py'" >> ~/.bashrc && source ~/.bashrc
114127
```
115-
Make sure to change the conda environment and piper_ui.py paths to your own.
116128

117-
Run
129+
Make sure to change the conda environment and piper_ui.py paths to your own paths.
130+
131+
Run:
118132

119-
source ~/.bashrc can automatically source upon restarting the terminal
120133
```shell
121134
source ~/.bashrc
122135
```
123136

137+
Then execute:
138+
124139
```shell
125140
pui
126141
```
@@ -129,41 +144,51 @@ pui
129144

130145
|Operation |Action|
131146
|---|---|
132-
|Find CAN Port button|Find the current CAN port, requires root password|
133-
| (can0 / can*) options| Select the corresponding port to operate the robotic arm and display whether the port is activated. |
134-
| CAN port rename input box | Enter or change the port name, apply after activation. |
135-
|Activate CAN Port button|Activate the port (after this, all subsequent functions can only be used after the port is activated)|
136-
|Enable button|Enable the robotic arm|
137-
|Disable button|Disable the robotic arm|
138-
|Reset button|Reset the robotic arm, needs to be executed once after setting to teach mode (Note: after reset, the robotic arm will fall)|
139-
|Gripper Zero button|Set the zero point for the robotic arm's gripper|
140-
|Go Zero button|Move the robotic arm to the zero point|
141-
|(Slave / Master)option|Set the robotic arm as Slave/Master (Master refers to teach mode)|
142-
|Config init button|Set all joint limits, maximum joint speed, and joint acceleration to default values|
143-
|Hardware version button|Output (update) the firmware version of the robotic arm controller in the top-right text box|
144-
|Teach pendant stroke slider|Adjust teach pendant gripper percentage from 100%-200% (set to master arm, value displayed in the text box on the right)|
145-
|Gripper stroke option|Set the stroke of the gripper currently in use (default is 70, select and confirm after choice)|
146-
|Gripper control slider|Enable and control the opening/closing of the gripper, value displayed in the text box on the right|
147-
|Gripper disable and clear err|Disable the gripper and clear errors (used when the gripper overheats and triggers an error)|
148-
|Status information reading option|Start button begins/Stop button stops (prints in the lower-right text box and continuously updates)|
149-
| |Angle Speed Limit: Read the maximum angle and speed limits of all the robotic arm's motors|
150-
| |Joint Status: Read the joint angle message|
151-
| |Gripper Status: Read the robotic arm's gripper status|
152-
| |Piper Status: Read the robotic arm's status (different mode statuses)|
153-
| |FK: Read the forward kinematics (FK) of the robot arm control and feedback for each joint|
154-
|Max Acc Limit button|Print the current joint maximum acceleration limit in the lower-right text box|
155-
|Installation position option|Select the installation direction of the robotic arm (select and confirm after choice)|
156-
| |Parallel: Horizontal standard installation|
157-
| |Left: Left side installation|
158-
| |Right: Right side installation|
159-
|Joint enable status text box|Displays the enable status of six joints (1 for enabled, 0 for disabled, starting from the first joint on the base)|
160-
|Cancel button|Cancel the current operation|
161-
|Exit button|Close the window|
147+
|Find CAN Port Button|Search for the current CAN port, root password is required|
148+
|(can0 / can*) Options|Select the robotic arm to operate based on the corresponding port, and check if the port is activated|
149+
|CAN Port Rename Input Box|Enter or change the port name, apply after activation|
150+
|Activate CAN Port Button|Activate the port (all subsequent functions can only be used after activation)|
151+
|Enable Button|Enable the robotic arm|
152+
|Disable Button|Disable the robotic arm|
153+
|Reset Button|Reset the robotic arm, needs to be done after setting to teach mode (note: the arm will fall after reset)|
154+
|Gripper Zero Button|Set the gripper's zero point|
155+
|Go Zero Button|Move the robotic arm to the zero point|
156+
|(Slave / Master) Option|Set the robotic arm to Slave/Master (Master is the teach mode)|
157+
|Config Init Button|Set all joint limits, max speed, and max acceleration to default values|
158+
|Stop button|The robotic arm slowly drops. After use, it needs to be reset and enabled twice again|
159+
|Hardware Version Button|Display (update) the main control firmware version of the robotic arm in the top-right corner|
160+
|Teach Pendant Stroke Slider|Zoom in/out the teach pendant stroke from 100%-200% (set to master arm, value displayed on the right)|
161+
|Gripper Stroke Option|Set the current gripper stroke (default is 70, select and confirm)|
162+
|Gripper Control Slider|Enable and control the gripper, value displayed on the right|
163+
|Gripper Disable and Clear Error|Disable gripper and clear errors (use if gripper overheats)|
164+
|Status Information Reading Option|Start/Stop button (prints in the lower-right text box, constantly updating)|
165+
| |Angle Speed Limit: Read the maximum angle and speed limits of all the motors|
166+
| |Joint Status: Read joint angle messages|
167+
| |Gripper Status: Read the gripper status|
168+
| |Piper Status: Read the robotic arm status (different modes)|
169+
| |FK: Read the forward kinematics feedback for each joint|
170+
|Max Acc Limit Button|Display the current joint max acceleration limit in the lower-right text box|
171+
|Installation Position Option|Select the robotic arm installation direction (confirm after selection)|
172+
| |Parallel: Horizontal installation|
173+
| |Left: Left-side installation|
174+
| |Right: Right-side installation|
175+
|Joint Enable Status Text Box|Displays the joint enable status for all six joints (1 for enabled, 0 for disabled, first joint is the base)|
176+
|Cancel Button|Cancel the current operation|
177+
|Exit Button|Close the window|
178+
179+
## Q&A
180+
181+
- **Error**: libGL error: MESA-LOADER: failed to open iris: /usr/lib/dri/iris_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
182+
183+
- **Solution**:
184+
```
185+
conda install -c conda-forge gcc
186+
```
162187
163188
## Notes
164189
165-
- CAN devices must be activated first, and the correct baud rate should be set before reading messages or controlling the robotic arm.
166-
- The C_PiperInterface interface class can pass the activated CAN route name during instantiation, which can be obtained via ifconfig.
167-
- Sometimes when executing CAN send, the terminal may show "Message NOT sent," meaning the CAN module has not successfully connected to the device. Check the module's connection to the robotic arm, then power cycle the robotic arm before retrying.
168-
- After creating an instance of the SDK interface, it will check if the built-in CAN module is activated. For other CAN devices, set the second parameter to False, e.g., piper = C_PiperInterface_V2("can0", False).
169-
- **The mit protocol for controlling individual joint motors of the robotic arm is an advanced feature. Improper use of this protocol may lead to damage to the robotic arm!**
190+
- You need to first activate the CAN device and set the correct baud rate before reading or controlling the robotic arm messages.
191+
- The `C_PiperInterface` interface class allows passing the activated CAN route name when instantiating, which can be obtained via `ifconfig`.
192+
- If you receive the "Message NOT sent" error when trying to send a CAN message, the CAN module may not be connected to the device. Check the connection, power cycle the robotic arm, and try again.
193+
- The sdk interface checks for the activation of its internal CAN module upon instantiation. If using another CAN device, set the second argument to `False`, e.g., `piper = C_PiperInterface_V2("can0", False)`.
194+
- **The advanced feature of controlling individual motors of the robotic arm via the MIT protocol should be used with caution, as improper use may damage the arm!**

README.MD

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ pui
142142
|Go Zero按钮|机械臂前往零点|
143143
|(Slave / Master)选项|机械臂设置为从臂/主臂(主臂即为示教模式)|
144144
|Config init按钮|机械臂设置全部关节限位、关节最大速度、关节加速度为默认值|
145+
|Stop按钮|机械臂缓慢下落,使用后需要reset,并重新使能两次|
145146
|hardware version按钮|输出(更新)机械臂主控固件版本在右上方文字框|
146147
|Teach pendant stroke滑块|示教夹抓百分比放大100%-200%(设置主臂,值显示在右侧文字框)|
147148
|Gripper stroke选项|设定正在使用夹爪的行程(默认为70,选择后confirm确认)|
@@ -162,6 +163,14 @@ pui
162163
|Cancel按钮|取消当前操作|
163164
|Exit按钮|关闭窗口|
164165

166+
## Q$A
167+
168+
- **报错** :libGL error: MESA-LOADER: failed to open iris: /usr/lib/dri/iris_dri.so: 无法打开共享目标文件: 没有那个文件或目录 (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
169+
170+
- **解决**
171+
```
172+
conda install -c conda-forge gcc
173+
```
165174
166175
## 注意事项
167176
File renamed without changes.

piper_ui.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
from PyQt5.QtCore import Qt, QProcess
99

1010
from piper_sdk import C_PiperInterface_V2
11-
from thread_module import MyClass
12-
from WidgetCreator import WidgetCreator
11+
from scripts.thread_module import MyClass
12+
from scripts.WidgetCreator import WidgetCreator
1313

1414
class MainWindow(QWidget):
1515
def __init__(self):
@@ -81,6 +81,7 @@ def init_layout(self):
8181
self.layout.addWidget(self.button_go_zero, 1, 2)
8282
self.layout.addWidget(self.arm_combobox, 1, 3)
8383
self.layout.addWidget(self.button_config_init, 1, 4)
84+
self.layout.addWidget(self.button_piper_stop, 1, 5)
8485
# 第三行:添加 夹爪示教器参数设置框 和 信息读取框
8586
self.layout.addWidget(self.gripper_teaching_frame, 2, 0, 5, 3)
8687
self.layout.addWidget(self.read_frame, 2, 3, 5, 5)
@@ -107,6 +108,7 @@ def init_connections(self):
107108
self.button_go_zero.clicked.connect(self.run_go_zero)
108109
self.button_gripper_zero.clicked.connect(self.run_gripper_zero)
109110
self.button_config_init.clicked.connect(self.run_config_init)
111+
self.button_piper_stop.clicked.connect(self.run_piper_stop)
110112
self.slider.valueChanged.connect(self.update_stroke)
111113
self.button_confirm.clicked.connect(self.confirm_gripper_teaching_pendant_param_config)
112114
self.button_gripper_clear_err.clicked.connect(self.gripper_clear_err)
@@ -147,6 +149,7 @@ def create_activation_widgets(self):
147149
self.button_go_zero = self.widget_creator.create_button(text="Go Zero", enabled=self.is_found and self.is_activated)
148150
self.button_gripper_zero = self.widget_creator.create_button(text="Gripper Zero", enabled=self.is_found and self.is_activated)
149151
self.button_config_init = self.widget_creator.create_button(text="Config Init", enabled=self.is_found and self.is_activated)
152+
self.button_piper_stop = self.widget_creator.create_button(text="Stop", enabled=self.is_found and self.is_activated)
150153

151154
def create_gripper_teaching_widgets(self):
152155
# 夹爪及示教器参数设置框
@@ -235,7 +238,7 @@ def create_logo(self):
235238
# 添加 Logo 图片
236239
self.label = self.widget_creator.create_label('', size=(150, 40))
237240
main_dir = os.path.dirname(os.path.abspath(__file__))
238-
image_path = os.path.join(main_dir, 'logo-white.png')
241+
image_path = os.path.join(main_dir, 'image', 'logo-white.png')
239242
pixmap = QPixmap(image_path)
240243
pixmap = pixmap.scaled(150, 40, Qt.KeepAspectRatio) # 调整图片大小
241244
self.label.setPixmap(pixmap)
@@ -253,6 +256,7 @@ def update_ui_states(self):
253256
self.button_go_zero.setEnabled(self.base_state and not self.master_flag)
254257
self.button_gripper_zero.setEnabled(self.base_state and not self.master_flag)
255258
self.button_config_init.setEnabled(self.base_state and not self.master_flag)
259+
self.button_piper_stop.setEnabled(self.base_state and not self.master_flag)
256260
self.slider.setEnabled(self.base_state and not self.master_flag)
257261
self.gripper_combobox.setEnabled(self.base_state and not self.master_flag)
258262
self.button_confirm.setEnabled(self.base_state and not self.master_flag)
@@ -478,6 +482,10 @@ def run_disable(self):
478482
def run_reset(self):
479483
self.piper.MotionCtrl_1(0x02, 0, 0)
480484
self.text_edit.append("[Info]: Arm reset.")
485+
486+
def run_piper_stop(self):
487+
self.piper.MotionCtrl_1(0x01, 0, 0)
488+
self.text_edit.append("[Info]: Arm stop.")
481489

482490
def run_go_zero(self):
483491
self.piper.MotionCtrl_2(0x01, 0x01, 100, 0x00)
@@ -679,6 +687,7 @@ def update_ui_states_master(self):
679687
self.button_go_zero.setEnabled(self.base_state and not self.master_flag)
680688
self.button_gripper_zero.setEnabled(self.base_state and not self.master_flag)
681689
self.button_config_init.setEnabled(self.base_state and not self.master_flag)
690+
self.button_piper_stop.setEnabled(self.base_state and not self.master_flag)
682691
self.slider.setEnabled(self.base_state and not self.master_flag)
683692
self.gripper_combobox.setEnabled(self.base_state and not self.master_flag)
684693
self.button_confirm.setEnabled(self.base_state and not self.master_flag)
File renamed without changes.

scripts/__init__.py

Whitespace-only changes.
File renamed without changes.

0 commit comments

Comments
 (0)