用重叠矩阵计算变换矩阵的问题转换.py

2024-05-15 04:19:51 发布

您现在位置:Python中文网/ 问答频道 /正文

当试图用库变换和函数叠加矩阵计算两个系统之间的变换矩阵时,我得到以下错误:

File "D:\Travail\Dev\projet Jarvis\collisions\Test dans Jarvis\JarvisRobotics_20180717_1937\JarvisRobotics\outils_matrices.py", line 839, in set_frame_passageV000 M = transformations.superimposition_matrix(list_base, list_ext, scale=True, usesvd=True) ValueError: eigenvector_of_symmetric_44() failed

条目中的数据是十个向量(x,y,z)的两个列表:

<class 'list'>: [[2443.9128, -501.7427, -630.8925], [2126.8356, -703.2691, -678.1219], [1534.3236, -757.3283, -678.0219], [1532.8918, -339.4951, -682.6528], [2103.9974, -226.6539, -472.8035], [2297.246, 47.3245, -475.6743], [2429.3814, 88.5478, -476.0224], [2353.675, 614.8282, -447.7145], [1931.7996, 651.5278, -448.4745], [1604.6555, 664.6893, -448.8943]]

<class 'list'>: [[406.93, -373.8, 2559.99], [612.81, -65.74, 2566.76], [679.68, 520.63, 2542.36], [271.24, 532.19, 2612.08], [114.43, -31.73, 2439.24], [-157.93, -220.7, 2490.9], [-200.13, -350.38, 2501.29], [-722.9, -260.64, 2556.52], [-750.43, 160.15, 2551.35], [-759.14, 488.8, 2545.55]]

有人在这里帮助我或引导我走得更远吗?你知道吗


Tags: 函数devtrue系统错误矩阵listclass
2条回答

有关信息,我已找到出现此错误的原因:

模块转换.py我得到的是不完整的,一些函数丢失(特别是引发错误的函数),由于指令“from transformation import*”,显然有一个默认值。。。我只是使用导入我需要的函数(叠加矩阵),我只是测试。你知道吗

所以现在,计算通过了,但是结果不好。你知道吗

通过我们为robots ABB(Robotstudio)使用的另一个软件,我们有一个专门用于计算变换帧的函数,即“DefAccFrame-定义两个系统之间的精确帧”。当我们使用它时,我们得到了正确的值(实际测试过),现在,这个代码不起作用。你知道吗

问题是这个指令只能在ABB机器人上使用,我想找到一种方法在任何控制器上使用它。你知道吗

我今天就在这里。 非常感谢大家的帮助。你知道吗

def set\框架\通道\(list\ pt\ ref\基础,list\ pt\ ref\扩展):

str_erreur = ''

if len(list_pt_ref_base) == len(list_pt_ref_ext):
    nb_pts = len(list_pt_ref_base)

    array_base = np.zeros((nb_pts, 3))
    array_ext = np.zeros((nb_pts, 3))

    lg_array = 0
    for index in range(0, nb_pts):
        array_base[lg_array] = list_pt_ref_base[index][:3]
        array_ext[lg_array] = list_pt_ref_ext[index][:3]
        lg_array += 1

    M = superimposition_matrix(array_base, array_ext, scale=True)

    # valeurs de sortie
    xyzrpw = set_mat4x4_2_xyzrpw(M)
    mat_rdk = mat4x4_numpy_2_rdk(M)

    if not (not np.all(M) and xyzrpw and mat_rdk):
        return False

    return RetVal([True, dt.now, 'matrice de passage calculée avec succès !', M, xyzrpw, mat_rdk])

else:
    str_erreur = 'Les tailles du tableau du référentiel base('
    str_erreur += str(len(list_pt_ref_base))
    str_erreur += ') et du référentiel extérieur('
    str_erreur += str(len(list_pt_ref_ext))
    str_erreur += ') ne sont pas de la même taille !'
    print(str_erreur)
RetVal([False, dt.now, str_erreur])

list_ext_brute = [[406.93, -373.8, 2559.99, 0.0, -0.0, 0.0],
                    [612.81, -65.74, 2566.76, 0.0, -0.0, 0.0],
                    [679.68, 520.63, 2542.36, 0.0, -0.0, 0.0],
                    [271.24, 532.19, 2612.08, 0.0, -0.0, 0.0],
                    [114.43, -31.73, 2439.24, 0.0, -0.0, 0.0],
                    [-157.93, -220.7, 2490.9, 0.0, -0.0, 0.0],
                    [-200.13, -350.38, 2501.29, 0.0, -0.0, 0.0],
                    [-722.9, -260.64, 2556.52, 0.0, -0.0, 0.0],
                    [-750.43, 160.15, 2551.35, 0.0, -0.0, 0.0],
                    [-759.14, 488.8, 2545.55, 0.0, -0.0, 0.0],
                    [-358.39, 151.63, 2416.5, 0.0, -0.0, 0.0],
                    [-289.58, -60.31, 2410.38, 0.0, -0.0, 0.0],
                    [-86.04, 153.06, 2369.19, 0.0, -0.0, 0.0],
                    [-9.05, -92.79, 2361.71, 0.0, -0.0, 0.0]]

list_base_brute = [[2443.9128, -501.7427, -630.8925, -179.0604, 0.4017, 145.2487],
                    [2126.8356, -703.2691, -678.1219, -179.6825, 0.552, 124.2606],
                    [1534.3236, -757.3283, -678.0219, 179.9398, 0.6337, 88.9192],
                    [1532.8918, -339.4951, -682.6528, 179.7809, 0.5975, 74.2169],
                    [2103.9974, -226.6539, -472.8035, -179.4523, 0.3239, 153.7627],
                    [2297.246, 47.3245, -475.6743, -179.4523, 0.3237, 153.7627],
                    [2429.3814, 88.5478, -476.0224, -179.7454, -0.5832, -109.2463],
                    [2353.675, 614.8282, -447.7145, -179.7454, -0.5833, -109.2462],
                    [1931.7996, 651.5278, -448.4745, -179.7454, -0.5835, -109.2461],
                    [1604.6555, 664.6893, -448.8943, -179.7455, -0.5835, -109.2461],
                    [1925.4354, 246.4732, -379.1885, -179.7455, -0.5836, -109.2458],
                    [2137.8614, 172.319, -378.1896, -179.7455, -0.5836, -109.2459],
                    [1919.7934, -31.8006, -376.11, -179.7455, -0.5837, -109.2459],
                    [2164.5074, -117.227, -374.9585, -179.7455, -0.5837, -109.2459]]

mat_ = set_frame_passage_(list_base_brute, list_ext_brute)

if mat_.b_done:
    print('                                                   -')
    print('xyzrpw = ' + str(mat_.res2))
    print('                                                   -')
    print('vecteur translation : x=' + str(mat_.res2[0]) + ', y=' + str(mat_.res2[1]) + ', z=' + str(mat_.res2[2]))
    print('angles de rotation : r=' + str(mat_.res2[3]) + ', p=' + str(mat_.res2[4]) + ', w=' + str(mat_.res2[5]))
    print('                                      ')
    print('Matrice de rotation numpy 4x4:')
    print(mat_.res1)
    print('                                      ')
    print('Matrice de rotation roboDK 4x4:')
    print(mat_.res3)
else:
    print(mat_.str_msg)

相关问题 更多 >

    热门问题