八协解城市擦擦

using System;
using System.IO;

internal class Program
{
static void Main(string[] args)
{
// 设置输出重定向到文件
string outputPath = @"output.txt";
FileStream fileStream = new FileStream(outputPath, FileMode.Create);
StreamWriter streamWriter = new StreamWriter(fileStream);
Console.SetOut(streamWriter);

FileStream fs = new FileStream(@"C:\Users\lx192\Desktop\NetAssist.bin", FileMode.Open);
MAVLink.MavlinkParse parse = new MAVLink.MavlinkParse();
while (fs.Position < fs.Length)
{
    var msg = parse.ReadPacket(fs);
    if (msg != null && msg.msgid == 33)
    {
        MAVLink.mavlink_global_position_int_t p = (MAVLink.mavlink_global_position_int_t)msg.data;
        Console.WriteLine("Latitude: {0}, Longitude: {1}, Altitude: {2}", p.lat, p.lon, p.relative_alt);
        // 还可以执行其他操作...
    }
    else if (msg.msgid == 30)
    {
        // 处理姿态数据
        MAVLink.mavlink_attitude_t attitude = (MAVLink.mavlink_attitude_t)msg.data;
        double roll_deg = attitude.roll * (180 / Math.PI); // 将弧度转换为度
        double pitch_deg = attitude.pitch * (180 / Math.PI); // 将弧度转换为度
        double yaw_deg = attitude.yaw * (180 / Math.PI); // 将弧度转换为度
        Console.WriteLine("Roll: {0}, Pitch: {1}, Yaw: {2}", roll_deg, pitch_deg, yaw_deg);
    }
    else if (msg.msgid == 0) // 假定的心跳消息ID,请根据实际情况替换
    {
        MAVLink.mavlink_heartbeat_t n = (MAVLink.mavlink_heartbeat_t)msg.data;
        // 假设data中存在载具ID的字段,这里仅为示意
        int vehicletype = n.type;
        Console.WriteLine("vehicle type : " + vehicletype);
    }

}
fs.Close();

// 关闭文件流
streamWriter.Close();
fileStream.Close();
}
}
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值