目标是开发基于 Azure IoT SDK 的代码,以将数据从我的机械臂实时发送到物联网中心。我发现这些教程非常有帮助,但codebase(在 github 上)理解起来相当乏味,因为提供了许多子目录和示例。
我尝试过的:
我遵循了温度控制器的代码示例,并且能够理解如何发送遥测数据,但我不确定如何为我的机器人开发代码。
我需要什么:
我需要一些关于遵循哪些代码示例/模板来开发代码以实现我的目标的指导。我将感谢任何指导。
欢迎来到社区!为了能够集成或使用来自机械臂的数据,您需要 SKD 或
Promorobotics
为您的 Franka 设备提供的公共 API。查看系统集成支持文档,该设备确实支持与编程集成。然而,他们的网站上没有提供公开文件来分享更多这方面的信息。您可以通过他们的联系页面联系他们并索取此信息。
一旦您可以以编程方式使用机器人遥测数据,您就可以使用 Microsoft.Azure.Devices.Client 类创建一个简单的设备客户端,并以编程方式将数据发送到 Azure IoT 中心。下面是一个用于将数据发送到 Azure IoT Hub 的简化示例程序。
using Microsoft.Azure.Devices.Client;
using System;
using System.Text;
using System.Threading.Tasks;
namespace IoTHubDevice
{
class Program
{
private static DeviceClient deviceClient;
private readonly static string connectionString = "Your IoT Hub device connection string";
static async Task Main(string[] args)
{
Console.WriteLine("IoT Hub Quickstarts #1 - Simulated device\n");
deviceClient = DeviceClient.CreateFromConnectionString(connectionString, TransportType.Mqtt);
while (true)
{
string messageString = "{\"temperature\":" + new Random().Next(20, 30) + ",\"humidity\":" + new Random().Next(60, 80) + "}";
var message = new Message(Encoding.ASCII.GetBytes(messageString));
message.ContentEncoding = "utf-8";
message.ContentType = "application/json";
await deviceClient.SendEventAsync(message);
await Task.Delay(10000);
}
}
}
}
您可以修改 messageString 以包含您的遥测数据。