Particle_dumbRobot.py 文件源码

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

项目:Udacity_Robotics_cs373 作者: lijiyao111 项目源码 文件源码
def move(self, turn, forward):
        if forward < 0:
            raise ValueError('Robot cant move backwards')         

        # turn, and add randomness to the turning command
        orientation = self.orientation + float(turn) + random.gauss(0.0, self.turn_noise)
        orientation %= 2 * pi

        # move, and add randomness to the motion command
        dist = float(forward) + random.gauss(0.0, self.forward_noise)
        x = self.x + (cos(orientation) * dist)
        y = self.y + (sin(orientation) * dist)
        x %= world_size    # cyclic truncate
        y %= world_size

        # set particle
        res = robot()
        res.set(x, y, orientation)
        res.set_noise(self.forward_noise, self.turn_noise, self.sense_noise)
        return res
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号