sensor.py 文件源码

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

项目:prototype 作者: chutsu 项目源码 文件源码
def feature_inview_2d(f, x, theta, rmax, thmax):
    """Checks to see wheter features is in view of robot

    Parameters
    ----------
    f : np.array of size 2
        Feature position
    x : np.array of size 2
        Robot position
    theta : float
        Robot's current heading in radians
    rmax : float
        Max sensor range
    thmax : float
        Max sensor bearing

    Returns
    -------

        Boolean to denote whether feature is in view of robot

    """
    # Distance in x and y
    dx = f[0] - x[0]
    dy = f[1] - x[1]

    # Calculate range and bearing
    r = sqrt(dx**2 + dy**2)
    th = fmod(atan2(dy, dx) - theta, 2 * pi)
    if th > pi:
        th = th - 2 * pi

    # Check to see if range and bearing is within view
    if ((r < rmax) and (abs(th) < thmax)):
        return True
    else:
        return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号