首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >寻找一种机器人导航算法

寻找一种机器人导航算法
EN

Stack Overflow用户
提问于 2016-04-12 09:27:39
回答 1查看 593关注 0票数 2

我有一个移动机器人,有一个距离传感器连接到一个摇摄伺服电机。电机连续旋转,将传感器从0度移动到180度,然后向后移动。

距离传感器每隔几毫秒发送一个信号,扫描周围的障碍物。我们可以像这样可视化距离传感器生成的数据:

我希望创建一种算法,允许机器人向有最多可用空间(或最小障碍)的方向移动。

更正式地说,我可以表示输入和输出,例如:

  • 输入:在电机旋转的每个角度上,距离最近的物体的距离的阵列。
  • 输出:表示最佳角度的单个值。

该算法的要求是:

  • 不应易受数据中异常值的影响(传感器有时无法预测)
  • 不需要绝对最优,1-2%的折扣是可以接受的。
  • 高效(这将在一个小型微处理器上运行)
  • 爱好者可以理解(我不是ML专家;)
EN

回答 1

Stack Overflow用户

发布于 2016-04-21 20:23:42

我不知道您正在使用的语言(我是一个Java和C#的家伙),所以我只使用伪代码:

代码语言:javascript
复制
EPSILON : Float = .02f -> this is our margin of error

DIRECTION : Integer = 0 -> the best direction to go

DISTANCE : Float = 0 -> the furthest distance from the robot

DISTANCES : Float[181] -> the values you get from your sensor

DISTANCE = DISTANCES[DIRECTION] // set the first distance

     for(int index = 1; index < size_of(DISTANCES)-1; index++) {
        //we are checking if the value is within 2% of the previous and next values
        if((DISTANCES[index-1] * (1+EPSILON) >= DISTANCES[index] AND
            DISTANCES[index-1] * (1-EPSILON) <= DISTANCES[index]) OR 
           (DISTANCES[index+1] * (1+EPSILON) >= DISTANCES[index] AND
            DISTANCES[index+1] * (1-EPSILON) <= DISTANCES[index])) {
       //if the distance at index is greater than the current max distance,
       //we set that to be the new max distance
        if(DISTANCES[index] > DISTANCE) {
           DISTANCE = DISTANCES[index]
           DIRECTION = index
          }
        }
     }

你也可以用传感器做两次扫描,并比较每个点的距离,看看是否有尖峰,但是根据你列出的规格,这应该是可行的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36569078

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档