@@ -29,6 +29,9 @@ class C_PiperInterface():
29
29
judge_flag(bool): Determines if the CAN port is functioning correctly.
30
30
When using a PCIe-to-CAN module, set to false.
31
31
can_auto_init(bool): Determines if the CAN port is automatically initialized.
32
+ dh_is_offset([0,1] -> default 0): Does the j1-j2 offset by 2° in the DH parameters?
33
+ 0 -> No offset
34
+ 1 -> Offset applied
32
35
'''
33
36
class ArmStatus ():
34
37
'''
@@ -352,7 +355,8 @@ def __new__(cls,
352
355
def __init__ (self ,
353
356
can_name :str = "can0" ,
354
357
judge_flag = True ,
355
- can_auto_init = True ) -> None :
358
+ can_auto_init = True ,
359
+ dh_is_offset : int = 0 ) -> None :
356
360
if getattr (self , "_initialized" , False ):
357
361
return # 避免重复初始化
358
362
self .__can_channel_name :str
@@ -363,7 +367,8 @@ def __init__(self,
363
367
self .__can_judge_flag = judge_flag
364
368
self .__can_auto_init = can_auto_init
365
369
self .__arm_can = C_STD_CAN (can_name , "socketcan" , 1000000 , judge_flag , can_auto_init , self .ParseCANFrame )
366
- self .__piper_fk = C_PiperForwardKinematics ()
370
+ self .__dh_is_offset = dh_is_offset
371
+ self .__piper_fk = C_PiperForwardKinematics (self .__dh_is_offset )
367
372
# protocol
368
373
self .__parser : Type [C_PiperParserBase ] = C_PiperParserV1 ()
369
374
# thread
@@ -1114,55 +1119,61 @@ def __UpdateDriverInfoHighSpdFeedback(self, msg:PiperMessage):
1114
1119
with self .__arm_motor_info_high_spd_mtx :
1115
1120
if (msg .type_ == ArmMsgType .PiperMsgHighSpdFeed_1 ):
1116
1121
self .__fps_counter .increment ("ArmMotorDriverInfoHighSpd_1" )
1117
- self .__arm_time_stamp .time_stamp_motor_low_spd_1 = time .time_ns ()
1122
+ self .__arm_time_stamp .time_stamp_motor_high_spd_1 = time .time_ns ()
1118
1123
self .__arm_motor_info_high_spd .motor_1 .can_id = msg .arm_high_spd_feedback_1 .can_id
1119
1124
self .__arm_motor_info_high_spd .motor_1 .motor_speed = msg .arm_high_spd_feedback_1 .motor_speed
1120
1125
self .__arm_motor_info_high_spd .motor_1 .current = msg .arm_high_spd_feedback_1 .current
1121
1126
self .__arm_motor_info_high_spd .motor_1 .pos = msg .arm_high_spd_feedback_1 .pos
1127
+ self .__arm_motor_info_high_spd .motor_1 .effort = msg .arm_high_spd_feedback_1 .cal_effort ()
1122
1128
elif (msg .type_ == ArmMsgType .PiperMsgHighSpdFeed_2 ):
1123
1129
self .__fps_counter .increment ("ArmMotorDriverInfoHighSpd_2" )
1124
- self .__arm_time_stamp .time_stamp_motor_low_spd_2 = time .time_ns ()
1130
+ self .__arm_time_stamp .time_stamp_motor_high_spd_2 = time .time_ns ()
1125
1131
self .__arm_motor_info_high_spd .motor_2 .can_id = msg .arm_high_spd_feedback_2 .can_id
1126
1132
self .__arm_motor_info_high_spd .motor_2 .motor_speed = msg .arm_high_spd_feedback_2 .motor_speed
1127
1133
self .__arm_motor_info_high_spd .motor_2 .current = msg .arm_high_spd_feedback_2 .current
1128
1134
self .__arm_motor_info_high_spd .motor_2 .pos = msg .arm_high_spd_feedback_2 .pos
1135
+ self .__arm_motor_info_high_spd .motor_2 .effort = msg .arm_high_spd_feedback_2 .cal_effort ()
1129
1136
elif (msg .type_ == ArmMsgType .PiperMsgHighSpdFeed_3 ):
1130
1137
self .__fps_counter .increment ("ArmMotorDriverInfoHighSpd_3" )
1131
- self .__arm_time_stamp .time_stamp_motor_low_spd_3 = time .time_ns ()
1138
+ self .__arm_time_stamp .time_stamp_motor_high_spd_3 = time .time_ns ()
1132
1139
self .__arm_motor_info_high_spd .motor_3 .can_id = msg .arm_high_spd_feedback_3 .can_id
1133
1140
self .__arm_motor_info_high_spd .motor_3 .motor_speed = msg .arm_high_spd_feedback_3 .motor_speed
1134
1141
self .__arm_motor_info_high_spd .motor_3 .current = msg .arm_high_spd_feedback_3 .current
1135
1142
self .__arm_motor_info_high_spd .motor_3 .pos = msg .arm_high_spd_feedback_3 .pos
1143
+ self .__arm_motor_info_high_spd .motor_3 .effort = msg .arm_high_spd_feedback_3 .cal_effort ()
1136
1144
elif (msg .type_ == ArmMsgType .PiperMsgHighSpdFeed_4 ):
1137
1145
self .__fps_counter .increment ("ArmMotorDriverInfoHighSpd_4" )
1138
- self .__arm_time_stamp .time_stamp_motor_low_spd_4 = time .time_ns ()
1146
+ self .__arm_time_stamp .time_stamp_motor_high_spd_4 = time .time_ns ()
1139
1147
self .__arm_motor_info_high_spd .motor_4 .can_id = msg .arm_high_spd_feedback_4 .can_id
1140
1148
self .__arm_motor_info_high_spd .motor_4 .motor_speed = msg .arm_high_spd_feedback_4 .motor_speed
1141
1149
self .__arm_motor_info_high_spd .motor_4 .current = msg .arm_high_spd_feedback_4 .current
1142
1150
self .__arm_motor_info_high_spd .motor_4 .pos = msg .arm_high_spd_feedback_4 .pos
1151
+ self .__arm_motor_info_high_spd .motor_4 .effort = msg .arm_high_spd_feedback_4 .cal_effort ()
1143
1152
elif (msg .type_ == ArmMsgType .PiperMsgHighSpdFeed_5 ):
1144
1153
self .__fps_counter .increment ("ArmMotorDriverInfoHighSpd_5" )
1145
- self .__arm_time_stamp .time_stamp_motor_low_spd_5 = time .time_ns ()
1154
+ self .__arm_time_stamp .time_stamp_motor_high_spd_5 = time .time_ns ()
1146
1155
self .__arm_motor_info_high_spd .motor_5 .can_id = msg .arm_high_spd_feedback_5 .can_id
1147
1156
self .__arm_motor_info_high_spd .motor_5 .motor_speed = msg .arm_high_spd_feedback_5 .motor_speed
1148
1157
self .__arm_motor_info_high_spd .motor_5 .current = msg .arm_high_spd_feedback_5 .current
1149
1158
self .__arm_motor_info_high_spd .motor_5 .pos = msg .arm_high_spd_feedback_5 .pos
1159
+ self .__arm_motor_info_high_spd .motor_5 .effort = msg .arm_high_spd_feedback_5 .cal_effort ()
1150
1160
elif (msg .type_ == ArmMsgType .PiperMsgHighSpdFeed_6 ):
1151
1161
self .__fps_counter .increment ("ArmMotorDriverInfoHighSpd_6" )
1152
- self .__arm_time_stamp .time_stamp_motor_low_spd_6 = time .time_ns ()
1162
+ self .__arm_time_stamp .time_stamp_motor_high_spd_6 = time .time_ns ()
1153
1163
self .__arm_motor_info_high_spd .motor_6 .can_id = msg .arm_high_spd_feedback_6 .can_id
1154
1164
self .__arm_motor_info_high_spd .motor_6 .motor_speed = msg .arm_high_spd_feedback_6 .motor_speed
1155
1165
self .__arm_motor_info_high_spd .motor_6 .current = msg .arm_high_spd_feedback_6 .current
1156
1166
self .__arm_motor_info_high_spd .motor_6 .pos = msg .arm_high_spd_feedback_6 .pos
1167
+ self .__arm_motor_info_high_spd .motor_6 .effort = msg .arm_high_spd_feedback_6 .cal_effort ()
1157
1168
else :
1158
1169
pass
1159
1170
# 更新时间戳,取筛选ID的最新一个
1160
- self .__arm_motor_info_high_spd .time_stamp = max (self .__arm_time_stamp .time_stamp_motor_low_spd_1 ,
1161
- self .__arm_time_stamp .time_stamp_motor_low_spd_2 ,
1162
- self .__arm_time_stamp .time_stamp_motor_low_spd_3 ,
1163
- self .__arm_time_stamp .time_stamp_motor_low_spd_4 ,
1164
- self .__arm_time_stamp .time_stamp_motor_low_spd_5 ,
1165
- self .__arm_time_stamp .time_stamp_motor_low_spd_6 ) / 1_000_000_000
1171
+ self .__arm_motor_info_high_spd .time_stamp = max (self .__arm_time_stamp .time_stamp_motor_high_spd_1 ,
1172
+ self .__arm_time_stamp .time_stamp_motor_high_spd_2 ,
1173
+ self .__arm_time_stamp .time_stamp_motor_high_spd_3 ,
1174
+ self .__arm_time_stamp .time_stamp_motor_high_spd_4 ,
1175
+ self .__arm_time_stamp .time_stamp_motor_high_spd_5 ,
1176
+ self .__arm_time_stamp .time_stamp_motor_high_spd_6 ) / 1_000_000_000
1166
1177
# print(self.__arm_motor_info_high_spd)
1167
1178
return self .__arm_motor_info_high_spd
1168
1179
0 commit comments