Skip to content

Commit 4771f6d

Browse files
committed
[FEAT]增加夹爪/示教器参数反馈指令的示教器摩擦系数参数(反馈和发送都增加)并适配协议;[BUG]修复夹爪反馈数值的时间戳为int类型的问题,现改为使用统一的获取时间戳函数;[FEAT]增加ModeCtrl函数和EmergencyStop函数用来设定模式和紧急停止(后续会将所有函数的形参增加字典匹配);[FEAT]修改demo中所有读取数据的文件重命名为read为首字母以方便查找;[FEAT]将C_STD_CAN这个封装类中的rx_message初始化为空Message();[FEAT]新增到0.2.20版本
1 parent 34205d5 commit 4771f6d

33 files changed

+528
-191
lines changed

demo/V1/README.MD

+25-9
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ can模块激活说明[can README](./can_config.MD)
3030

3131
```shell
3232
V1
33+
├── interface_disconnect.py
3334
├── motor_max_acc_limit_config.py
35+
├── multi_interface_instance.py
3436
├── piper_disable.py
3537
├── piper_enable.py
3638
├── piper_end_pose.py
@@ -40,17 +42,24 @@ V1
4042
├── piper_joint_ctrl.py
4143
├── piper_master_config.py
4244
├── piper_moveC.py
43-
├── piper_read_arm_motor_max_acc_limit.py
44-
├── piper_read_arm_motor_max_angle_spd.py
45-
├── piper_read_end_pose.py
4645
├── piper_reset.py
4746
├── piper_set_mit.py
4847
├── piper_slave_config.py
49-
├── piper_status.py
5048
├── piper_stop.py
49+
├── read_all_fps.py
50+
├── read_arm_motor_max_acc_limit.py
51+
├── read_arm_motor_max_angle_spd.py
52+
├── read_crash_protectation.py
53+
├── read_end_pose.py
54+
├── read_fk.py
5155
├── read_gripper_status.py
56+
├── read_high_msg.py
57+
├── read_joint_ctrl.py
5258
├── read_joint_state.py
53-
└── read_piper_hardware.py
59+
├── read_low_msg.py
60+
├── read_piper_hardware.py
61+
├── read_status.py
62+
└── read_version.py
5463
```
5564

5665
|文件 |说明|
@@ -65,16 +74,23 @@ V1
6574
|`piper_joint_ctrl.py`|机械臂关节控制|
6675
|`piper_master_config.py`|机械臂设置为主臂|
6776
|`piper_moveC.py`|机械臂设置为圆弧运动|
68-
|`piper_read_arm_motor_max_acc_limit.py`|读取所有电机的最大加速度限制|
69-
|`piper_read_arm_motor_max_angle_spd.py`|读取机械臂的所有电机的最大加速度限制|
70-
|`piper_read_end_pose.py`|读取末端姿态|
7177
|`piper_reset.py`|机械臂重置,需要在设定为示教模式后执行一次|
7278
|`piper_set_mit.py`|设定机械臂为mit模式,这个模式下机械臂响应最快速|
7379
|`piper_slave_config.py`|机械臂设置为从臂|
74-
|`piper_status.py`|机械臂状态读取|
7580
|`piper_stop.py`|机械臂停止缓慢下落,需要在使用后reset,并重新使能两次|
81+
|`read_all_fps.py`|机械臂读取指定数据的频率|
82+
|`read_arm_motor_max_acc_limit.py`|读取所有电机的最大加速度限制|
83+
|`read_arm_motor_max_angle_spd.py`|读取机械臂的所有电机的最大加速度限制|
84+
|`read_crash_protectation.py`|读取机械臂的碰撞保护等级|
85+
|`read_end_pose.py`|读取末端姿态|
86+
|`read_fk.py`|读取sdk内部通过dh参数解算的末端位姿|
7687
|`read_gripper_status.py`|机械臂夹爪状态读取|
88+
|`read_high_msg.py`|读取机械臂高速消息|
89+
|`read_joint_ctrl.py`|读取关节角的控制消息并打印|
7790
|`read_joint_state.py`|读取关节角消息并打印|
91+
|`read_low_msg.py`|读取机械臂低速消息|
7892
|`read_piper_hardware.py`|读取机械臂主控固件版本|
93+
|`read_status.py`|读取机械臂当前状态|
94+
|`read_version.py`|读取机械臂sdk软件各模块版本|
7995

8096
注意:如果是在机械臂处于主动臂模式下,发送设置为从动臂指令后需要重新启动机械臂,机械臂才会切换到从动臂模式
File renamed without changes.

demo/V1/piper_joint_ctrl.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def enable_fun(piper:C_PiperInterface):
4949
enable_fun(piper=piper)
5050
# piper.DisableArm(7)
5151
piper.GripperCtrl(0,1000,0x01, 0)
52-
factor = 57324.840764 #1000*180/3.14
52+
factor = 57295.7795 #1000*180/3.1415926
5353
# factor =1
5454
position = [0,0,0,0,0,0,0]
5555
count = 0
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

demo/V1/read_joint_ctrl.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env python3
2+
# -*-coding:utf8-*-
3+
# 注意demo无法直接运行,需要pip安装sdk后才能运行
4+
# 读取机械臂消息并打印,需要先安装piper_sdk
5+
from typing import (
6+
Optional,
7+
)
8+
from piper_sdk import *
9+
10+
# 测试代码
11+
if __name__ == "__main__":
12+
piper = C_PiperInterface()
13+
piper.ConnectPort()
14+
while True:
15+
import time
16+
print(piper.GetArmJointCtrl())
17+
time.sleep(0.005)
18+
pass
File renamed without changes.
File renamed without changes.

demo/V2/README.MD

+28-9
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ can模块激活说明[can README](./can_config.MD)
3232

3333
```shell
3434
V2
35+
├── interface_disconnect.py
3536
├── motor_max_acc_limit_config.py
3637
├── piper_disable.py
3738
├── piper_enable.py
@@ -42,25 +43,35 @@ V2
4243
├── piper_joint_ctrl.py
4344
├── piper_master_config.py
4445
├── piper_moveC.py
45-
├── piper_read_arm_motor_max_acc_limit.py
46-
├── piper_read_arm_motor_max_angle_spd.py
47-
├── piper_read_end_pose.py
46+
├── piper_multi_interface_instance.py
4847
├── piper_reset.py
4948
├── piper_set_mit.py
5049
├── piper_slave_config.py
5150
├── piper_status.py
5251
├── piper_stop.py
52+
├── read_all_fps.py
53+
├── read_arm_motor_max_acc_limit.py
54+
├── read_arm_motor_max_angle_spd.py
55+
├── read_crash_protectation.py
56+
├── read_end_pose.py
57+
├── read_fk.py
5358
├── read_gripper_status.py
59+
├── read_high_msg.py
60+
├── read_joint_ctrl.py
5461
├── read_joint_state.py
62+
├── read_low_msg.py
5563
├── read_piper_hardware.py
64+
├── read_version.py
5665
├── V2_gripper_param_config.py
5766
├── V2_installation_pos.py
5867
├── V2_joint_mit_ctrl.py
59-
└── V2_motor_max_spd_set.py
68+
├── V2_motor_max_spd_set.py
69+
└── V2_read_gripper_param_feedback.py
6070
```
6171

6272
|文件 |说明|
6373
|---|---|
74+
6475
|`motor_max_acc_limit_config.py`|电机单独设定某个关节电机的最大加速度限制|
6576
|`piper_disable.py`|机械臂失能|
6677
|`piper_enable.py`|机械臂使能|
@@ -70,21 +81,29 @@ V2
7081
|`piper_init_default.py`|机械臂 设置全部关节限位、关节最大速度、关节加速度为默认值|
7182
|`piper_joint_ctrl.py`|机械臂关节控制|
7283
|`piper_master_config.py`|机械臂设置为主臂|
73-
|`piper_moveC.py`|机械臂设置为主臂|
74-
|`piper_read_arm_motor_max_acc_limit.py`|读取所有电机的最大加速度限制|
75-
|`piper_read_arm_motor_max_angle_spd.py`|读取机械臂的所有电机的最大加速度限制|
76-
|`piper_read_end_pose.py`|读取末端姿态|
84+
|`piper_moveC.py`|机械臂设置为圆弧运动|
7785
|`piper_reset.py`|机械臂重置,需要在设定为示教模式后执行一次|
7886
|`piper_set_mit.py`|设定机械臂为mit模式,这个模式下机械臂响应最快速|
7987
|`piper_slave_config.py`|机械臂设置为从臂|
80-
|`piper_status.py`|机械臂状态读取|
8188
|`piper_stop.py`|机械臂停止缓慢下落,需要在使用后reset,并重新使能两次|
89+
|`read_all_fps.py`|机械臂读取指定数据的频率|
90+
|`read_arm_motor_max_acc_limit.py`|读取所有电机的最大加速度限制|
91+
|`read_arm_motor_max_angle_spd.py`|读取机械臂的所有电机的最大加速度限制|
92+
|`read_crash_protectation.py`|读取机械臂的碰撞保护等级|
93+
|`read_end_pose.py`|读取末端姿态|
94+
|`read_fk.py`|读取sdk内部通过dh参数解算的末端位姿|
8295
|`read_gripper_status.py`|机械臂夹爪状态读取|
96+
|`read_high_msg.py`|读取机械臂高速消息|
97+
|`read_joint_ctrl.py`|读取关节角的控制消息并打印|
8398
|`read_joint_state.py`|读取关节角消息并打印|
99+
|`read_low_msg.py`|读取机械臂低速消息|
84100
|`read_piper_hardware.py`|读取机械臂主控固件版本|
101+
|`read_status.py`|读取机械臂当前状态|
102+
|`read_version.py`|读取机械臂sdk软件各模块版本|
85103
|`V2_gripper_param_config.py`|V2版本夹爪参数设定|
86104
|`V2_installation_pos.py`|V2版本设定安装位置为水平正装|
87105
|`V2_joint_mit_ctrl.py`|V2版本sdk单独电机mit参数设定|
88106
|`V2_motor_max_spd_set.py`|V2版本sdk电机单独设定某个关节电机的最大速度限制|
107+
|`V2_read_gripper_param_feedback.py`|V2版本读取夹爪参数反馈|
89108

90109
注意:如果是在机械臂处于主动臂模式下,发送设置为从动臂指令后需要重新启动机械臂,机械臂才会切换到从动臂模式

demo/V2/V2_gripper_param_config.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@
77
# 一般情况下 GripperTeachingPendantParamConfig 函数第二个参数 max_range_config 是70
88

99
from piper_sdk import *
10-
10+
import time
1111
if __name__ == "__main__":
1212
piper = C_PiperInterface_V2("can0")
1313
piper.ConnectPort()
14-
piper.GripperTeachingPendantParamConfig(100, 70)
14+
piper.GripperTeachingPendantParamConfig(100, 70, 1)
15+
piper.ArmParamEnquiryAndConfig(4)
16+
while True:
17+
print(piper.GetGripperTeachingPendantParamFeedback())
18+
time.sleep(0.05)
1519

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env python3
2+
# -*-coding:utf8-*-
3+
# 注意demo无法直接运行,需要pip安装sdk后才能运行
4+
# V2版本sdk
5+
# 夹爪/示教器参数设置指令
6+
# 第一次使用夹爪或者示教器时,需要设定一下这两个末端执行器参数,否则会出现数据没有反馈并且执行器无法控制的情况
7+
# 一般情况下 GripperTeachingPendantParamConfig 函数第二个参数 max_range_config 是70
8+
9+
from piper_sdk import *
10+
import time
11+
if __name__ == "__main__":
12+
piper = C_PiperInterface_V2("can0")
13+
piper.ConnectPort()
14+
while True:
15+
piper.ArmParamEnquiryAndConfig(4)
16+
print(piper.GetGripperTeachingPendantParamFeedback())
17+
time.sleep(0.05)
18+

demo/V2/piper_joint_ctrl.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def enable_fun(piper:C_PiperInterface_V2):
4949
enable_fun(piper=piper)
5050
# piper.DisableArm(7)
5151
piper.GripperCtrl(0,1000,0x01, 0)
52-
factor = 57324.840764 #1000*180/3.14
52+
factor = 57295.7795 #1000*180/3.1415926
5353
# factor =1
5454
position = [0,0,0,0,0,0,0]
5555
count = 0
File renamed without changes.
File renamed without changes.
File renamed without changes.

demo/V2/piper_read_high_msg.py demo/V2/read_high_msg.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
while True:
1515
import time
1616
print(piper.GetArmHighSpdInfoMsgs())
17-
time.sleep(0.5)
17+
time.sleep(0.005)
1818
pass

demo/V2/read_joint_ctrl.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env python3
2+
# -*-coding:utf8-*-
3+
# 注意demo无法直接运行,需要pip安装sdk后才能运行
4+
# 读取机械臂消息并打印,需要先安装piper_sdk
5+
from typing import (
6+
Optional,
7+
)
8+
from piper_sdk import *
9+
10+
# 测试代码
11+
if __name__ == "__main__":
12+
piper = C_PiperInterface_V2()
13+
piper.ConnectPort()
14+
while True:
15+
import time
16+
print(piper.GetArmJointCtrl())
17+
time.sleep(0.005)
18+
pass
File renamed without changes.

hardware_port/can_encapsulation.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def __init__(self,
5252
self.channel_name = channel_name
5353
self.bustype = bustype
5454
self.expected_bitrate = expected_bitrate
55-
self.rx_message:Optional[Message] #创建消息接收类
55+
self.rx_message:Optional[Message] = Message() #创建消息接收类
5656
self.callback_function = callback_function #接收回调函数
5757
self.bus = None
5858
if(judge_flag):
@@ -129,7 +129,7 @@ def JudgeCanInfo(self):
129129
def GetBirtrate(self):
130130
return self.expected_bitrate
131131

132-
def GetRxMessage(self):
132+
def GetRxMessage(self) -> Message:
133133
return self.rx_message
134134

135135
def ReadCanMessage(self):
@@ -266,13 +266,15 @@ def get_can_bitrate(self, channel_name: str) -> str:
266266
print(f"Error while getting bitrate: {e}")
267267
return "Unknown"
268268

269-
# 示例代码
269+
## 示例代码
270270
# if __name__ == "__main__":
271271
# try:
272272
# can_obj = C_STD_CAN(channel_name="can0")
273273
# print("CAN bus initialized successfully.")
274274
# print(can_obj.get_can_ports())
275275
# print(can_obj.can_port_info("can0"))
276+
# print(can_obj.ReadCanMessage())
277+
# print(can_obj.GetRxMessage())
276278
# except ValueError as e:
277279
# print(e)
278280
# except Exception as e:

0 commit comments

Comments
 (0)