【问题标题】:How to use the Azure IoT Hub node on ROS?如何在 ROS 上使用 Azure IoT Hub 节点?
【发布时间】:2019-05-09 07:52:28
【问题描述】:

我正在做一个结合机器人技术和云计算的项目。 从简单的开始,我目前使用带有 Ubuntu 和 ROS Kinectic 的树莓派,用一些伺服电机和传感器控制 arduino。为了监控传感器数据,我想使用 Python SDK for Azure IoT Hub 将我的 Raspberry 连接到 Microsoft Azure Cloud。

这可以通过创建一个订阅“传感器”主题并将接收到的数据发送到 Azure IoT Hub 的节点来完成。

我在 Github 上找到了一个 Azure IoT Hub 节点,但不知道如何使用它或在上面找到文档:https://github.com/microsoft/ros_azure_iothub

我想知道是否有人对此节点有一些建议/经验?有什么文件吗?

感谢您的帮助!

【问题讨论】:

标签: python c++ ros azure-iot-hub azure-eventhub


【解决方案1】:

以下是使用 python 将树莓派连接到 Azure IOT 集线器所需执行的步骤

1) 设置您的 PI

对于设置,您可以使用此link 在您的 pi 上启用 SSH。

在您的 Pi 上启用 I2C 使用以下链接启用 I2C。 https://www.raspberrypi.org/documentation/configuration/raspi-config.md

2) 将传感器与 PI 连接

3) 下载和设置引用的模块

  1. 将客户端应用克隆到本地:

    sudo apt-get install git-core
    

    git 克隆https://github.com/Azure-Samples/iot-hub-python-raspberrypi-client-app.git

因为用于 Python 的 Azure IoT SDK 是 [SDKs for C][azure-iot-sdk-c] 之上的包装器,因此如果您想要或需要生成 Python 库,则需要编译 C 库源代码。

cd ./iot-hub-python-raspberrypi-client-app
   sudo chmod u+x setup.sh
   sudo ./setup.sh

在上面的脚本中,我们运行./setup.sh不带参数,所以shell会自动检测并使用python安装的版本(搜索顺序2.7->3.4->3.5)。或者,您可以使用参数指定要使用的 python 版本,如下所示:sudo ./setup.sh [--python-version|-p] [2.7|3.4|3.5]

Known build issues:

1.) On building the Python client library (`iothub_client.so`) on Linux devices that have less than **1GB** RAM, you may see build getting **stuck** at **98%** while building `iothub_client_python.cpp` as shown below

``[ 98%] Building CXX object python/src/CMakeFiles/iothub_client_python.dir/iothub_client_python.cpp.o``

If you run into this issue, check the **memory consumption** of the device using `free -m command` in another terminal window during that time. If you are running out of memory while compiling iothub_client_python.cpp file, you may have to temporarily increase the **swap space** to get more available memory to successfully build the Python client side device SDK library.

您可以参考示例代码here

希望对你有帮助。

【讨论】:

    猜你喜欢
    • 2018-04-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多