42 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# import random
# import numpy as np
# random_array = np.random.rand(3) # 生成长度为 3 的数组
# print(random_array/1000)
import math
def __transform_mm_deg_2_m_rad(input_list):
'''
接受列表 [X Y Z RX RY RZ]
将单位 m/rad 转为 mm/deg
'''
if len(input_list) != 6:
raise ValueError("Input list must contain exactly 6 elements [X, Y, Z, RX, RY, RZ]")
# 转换位置单位m -> mm (乘以 1000)
x_mm = input_list[0] * 1000.0
y_mm = input_list[1] * 1000.0
z_mm = input_list[2] * 1000.0
# 转换角度单位rad -> deg (乘以 180/pi)
rx_deg = math.degrees(input_list[3])
ry_deg = math.degrees(input_list[4])
rz_deg = math.degrees(input_list[5])
return [x_mm, y_mm, z_mm, rx_deg, ry_deg, rz_deg]
def __transform_rad_2_deg(input_list):
'''
接受列表 [J1 J2 J3 J4 J5 J6]
将单位rad转为deg
'''
if len(input_list) != 6:
raise ValueError("Input list must contain exactly 6 elements [J1, J2, J3, J4, J5, J6]")
# 转换角度单位: rad -> deg
J_deg = []
for i in range(6):
J_deg.append(math.degrees(input_list[i]))
return J_deg
print(__transform_rad_2_deg([6.283185307179586, 3.141592653589793, 6.283185307179586,6.283185307179586, 3.141592653589793, 6.283185307179586]))