ev3_vehicle.py 文件源码

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

项目:ev3-python3 作者: ChristophGaukel 项目源码 文件源码
def _drive_to_1(
            self,
            speed: int,
            pos_x: float,
            pos_y: float
    ) -> None:
        diff_x = pos_x - self._pos_x
        diff_y = pos_y - self._pos_y
        if abs(diff_x) > abs(diff_y):
            direct = math.degrees(math.atan(diff_y/diff_x))
        else:
            fract = diff_x / diff_y
            sign = math.copysign(1, fract)
            direct = sign * 90 - math.degrees(math.atan(fract))
        if diff_x < 0:
            direct += 180
        self._rotate_to(speed, direct)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号