如何在ROS上使用Azure IoT Hub节点?

2024-10-01 00:35:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在做一个机器人技术和云计算相结合的项目。 简单地说,我现在使用的是一个带有Ubuntu和ROS Kinectic的raspberry py,通过一些伺服电机和传感器来控制一个arduino。为了监视传感器数据,我想使用pythonsdk for Azure IoT Hub将我的Raspberry连接到microsoftazure云。你知道吗

这可以通过创建订阅“传感器”主题并将接收到的数据发送到Azure IoT Hub的节点来实现。你知道吗

我在Github上找到了一个Azure IoT HuB节点,但无法找到如何使用它或找到它的文档:https://github.com/microsoft/ros_azure_iothub

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

谢谢你的帮助!你知道吗


Tags: 数据项目py节点ubuntu机器人ros传感器
1条回答
网友
1楼 · 发布于 2024-10-01 00:35:56

下面是使用python将raspberry pi连接到Azure IOT hub所需的步骤

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

因为Azure IoT sdk for Python是[sdk for C][Azure-IoT-sdk-C]之上的包装器,所以如果您想要或需要从源代码生成Python库,您将需要编译C库。你知道吗

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

在上面的脚本中,我们运行/设置.sh不带参数,因此shell将自动检测并使用已安装的python版本(搜索序列2.7->;3.4->;3.5)。或者,可以使用一个参数来指定要使用的python版本,如下所示:sudo/设置.sh[python版本|-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。你知道吗

希望有帮助。你知道吗

相关问题 更多 >