首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在我的胡椒机器人上激活naoqi_navigation_samples?

如何在我的胡椒机器人上激活naoqi_navigation_samples?
EN

Stack Overflow用户
提问于 2020-08-28 13:35:43
回答 1查看 101关注 0票数 0

这个项目的目标之一是让胡椒机器人“自主”地在医院病房巡逻。因此,我下载了一些基本应用程序,以便从导航(https://github.com/aldebaran/naoqi_navigation_samples)开始。“探索”应用程序是关键的,因为它是需要其他两个(地点和巡逻)。我试着在Choregraphe上启动“探索”,但是机器人不会移动(很明显,它不会探索,也不会创建地图),应用程序以最后一句结束。特别是,块"Get map“给出了一个错误。因此,应用程序启动正确,但不能正常工作。

我把“探索”作为一个机器人应用程序保存下来,并尝试了自主生活和非自主生活。

我不明白我错在哪里,你能帮我一下吗?

EN

回答 1

Stack Overflow用户

发布于 2022-08-25 16:00:23

在你跑步的时候,确保充电盖没有打开。同样,尝试下面的代码,它将创建一个映射。

代码语言:javascript
运行
复制
#! /usr/bin/env python
# -*- encoding: UTF-8 -*-

"""Example: Use explore method."""

import qi
import argparse
import sys
import numpy
from PIL import Image


def main(session):
    """
    This example uses the explore method.
    """
    # Get the services ALNavigation and ALMotion.
    navigation_service = session.service("ALNavigation")
    motion_service = session.service("ALMotion")

    # Wake up robot
    motion_service.wakeUp()

    # Explore the environement, in a radius of 2 m.
    radius = 5.0
    error_code = navigation_service.explore(radius)
    if error_code != 0:
        print ("Exploration failed.")
        return
    # Saves the exploration on disk
    path = navigation_service.saveExploration()
    print ("Exploration saved at path: \"" + path + "\"")
    # Start localization to navigate in map
    navigation_service.startLocalization()
    # Come back to initial position
    navigation_service.navigateToInMap([0., 0., 0.])
    # Stop localization
    navigation_service.stopLocalization()
    # Retrieve and display the map built by the robot
    result_map = navigation_service.getMetricalMap()
    map_width = result_map[1]
    map_height = result_map[2]
    img = numpy.array(result_map[4]).reshape(map_width, map_height)
    img = (100 - img) * 2.55 # from 0..100 to 255..0
    img = numpy.array(img, numpy.uint8)
    Image.frombuffer('L',  (map_width, map_height), img, 'raw', 'L', 0, 1).show()

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--ip", type=str, default="127.0.0.1",
                        help="Robot IP address. On robot or Local Naoqi: use '127.0.0.1'.")
    parser.add_argument("--port", type=int, default=9559,
                        help="Naoqi port number")

    args = parser.parse_args()
    session = qi.Session()
    try:
        session.connect("tcp://" + args.ip + ":" + str(args.port))
    except RuntimeError:
        print ("Can't connect to Naoqi at ip \"" + args.ip + "\" on port " + str(args.port) +".\n"
            "Please check your script arguments. Run with -h option for help.")
        sys.exit(1)
    main(session)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63634856

复制
相关文章

相似问题

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