RollPitchYaw.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:StratoBalloon 作者: delattreb 项目源码 文件源码
def calcYaw(self, magnet, roll, pitch):
        magX = magnet[0]
        magY = magnet[1]
        magZ = magnet[2]
        rowX = magX
        rowY = -magY
        rowZ = -magZ
        row = np.matrix([[rowX], [rowY], [rowZ]])
        A = np.matrix([ \
            [math.cos(roll), math.sin(roll) * math.sin(pitch), math.cos(pitch) * math.sin(roll)] \
            , [0, math.cos(pitch), -math.sin(pitch)] \
            , [-math.sin(roll), math.sin(pitch) * math.cos(roll), math.cos(roll) * math.cos(pitch)] \
            ])
        calib = A * row
        calibX = row[0]
        calibY = row[1]
        calibZ = row[2]
        try:
            yaw = math.atan(calibY / calibX)
        except:
            if calibY > 0:
                yaw = 1.0
            else:
                yaw = -1.0
        return yaw
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号