1,矩阵相关
矩阵求逆和求行列式的值
需求是需要验证视觉给到我的是否和我预期的姿态大致一样
假设视觉给我的姿态是
-0.999986 0.00530258 0
0.00530258 0.999986 0
-0 0 -1
而我预期的姿态是
-1 0 0
0 1 0
0 0 -1
import numpy as np mVis = np.array([ [-0.999986,0.0053,0], [0.00530,0.999986,0], [0,0,-1], ]) mExpected= np.array([ [-1,0,0], [0,1,0], [0,0,-1], ]) mRes = np.sum(np.abs(mExpected - mVis)) if mRes < 0.03: # 这里的阈值0.03视情况调节 print("视觉给的姿态可以使用") else: print("视觉给的姿态和预期的偏差太大了")
其他矩阵操作:
矩阵相乘 np.matmul(A,B)
矩阵求逆 np.linalg.inv(A)
矩阵的行列式的值 np.linalg.det(A)