简体   繁体   English

Dronekit 上传到 Pixhawk 4 - 舍入问题

[英]Dronekit upload to Pixhawk 4 - rounding issue

When I upload to the Pixhawk via Mission Planner, and then download it again, there doesn't seem to be any issue.当我通过 Mission Planner 上传到 Pixhawk,然后再次下载时,似乎没有任何问题。 But when I use Dronekit to upload a mission file, it comes back looking very strange.但是当我使用 Dronekit 上传任务文件时,它看起来很奇怪。

Here's the (simplified) code I use to upload:这是我用来上传的(简化)代码:

upload_mission_file("D:\TestMission.txt")
# Upload mission file
def upload_mission_file(file_name):
    mission_list = load_mission(file_name)

    # Clear existing mission from vehicle
    print(' Clear mission')
    cmds = communications_global.vehicle.commands
    cmds.clear()

    # Add new mission to vehicle
    for command in mission_list:
        cmds.add(command)

    #for command in cmds:
    #    print(str(command))

    print('Upload mission')
    communications_global.vehicle.commands.upload()
    print("Uploaded mission")

# Load mission from file
def load_mission(file_name):
    # Load a mission from a file into a list. The mission definition is in the Waypoint file
    # format (http://qgroundcontrol.org/mavlink/waypoint_protocol#waypoint_file_format).
    # This function is used by upload_mission().

    print("\nReading mission from file: %s" % file_name)
    cmds = communications_global.vehicle.commands
    missionlist = []
    with open(file_name) as f:
        for i, line in enumerate(f):
            if i == 0:
                if not line.startswith('QGC WPL 110'):
                    raise Exception('File is not supported WP version')
            else:
                linearray = line.split('\t')
                ln_index = int(linearray[0])
                ln_currentwp = int(linearray[1])
                ln_frame = int(linearray[2])
                ln_command = int(linearray[3])
                ln_param1 = float(linearray[4])
                ln_param2 = float(linearray[5])
                ln_param3 = float(linearray[6])
                ln_param4 = float(linearray[7])
                ln_param5 = float(linearray[8])
                ln_param6 = float(linearray[9])
                ln_param7 = float(linearray[10])
                ln_autocontinue = int(linearray[11].strip())
                cmd = Command(0, 0, 0, ln_frame, ln_command, ln_currentwp, ln_autocontinue, ln_param1, ln_param2,
                              ln_param3, ln_param4, ln_param5, ln_param6, ln_param7)
                missionlist.append(cmd)
    return missionlist

-- ——

Here's what I upload:这是我上传的内容:

QGC WPL 110
0   1   0   16  0   0   0   0   -41.5066668 173.7577779 100 1
1   0   0   178 0.00000000  0.50000000  50.00000000 0.00000000  0.00000000  0.00000000  0.000000    1
2   0   3   16  0   0   0   0   -41.5066668 173.7577779 100 0
3   0   3   16  0   0   0   0   -41.5066667 173.7577778 100 0
4   0   3   16  0   0   0   0   -41.5066666 173.7577777 100 0
5   0   3   16  0   0   0   0   -41.5066665 173.7577776 100 0
6   0   3   16  0   0   0   0   -41.5066664 173.7577775 100 0
7   0   3   16  0   0   0   0   -41.5066663 173.7577774 100 0
8   0   3   16  0   0   0   0   -41.5066662 173.7577773 100 0
9   0   3   16  0   0   0   0   -41.5066661 173.7577772 100 0
10  0   3   16  0   0   0   0   -41.5066660 173.7577771 100 0

And here's what comes back when I download it via mission planner:这是我通过任务规划器下载它时返回的内容:

QGC WPL 110
0   1   0   16  0   0   0   0   -35.363262  149.165237  1168.000000 1
1   0   0   178 0.00000000  0.50000000  50.00000000 0.00000000  0.00000000  0.00000000  0.000000    1
2   0   3   16  0.00000000  0.00000000  0.00000000  0.00000000  -41.50666880    173.75778560    100.000000  1
3   0   3   16  0.00000000  0.00000000  0.00000000  0.00000000  -41.50666880    173.75778560    100.000000  1
4   0   3   16  0.00000000  0.00000000  0.00000000  0.00000000  -41.50666880    173.75778560    100.000000  1
5   0   3   16  0.00000000  0.00000000  0.00000000  0.00000000  -41.50666880    173.75778560    100.000000  1
6   0   3   16  0.00000000  0.00000000  0.00000000  0.00000000  -41.50666880    173.75778560    100.000000  1
7   0   3   16  0.00000000  0.00000000  0.00000000  0.00000000  -41.50666880    173.75778560    100.000000  1
8   0   3   16  0.00000000  0.00000000  0.00000000  0.00000000  -41.50666880    173.75778560    100.000000  1
9   0   3   16  0.00000000  0.00000000  0.00000000  0.00000000  -41.50666560    173.75778560    100.000000  1
10  0   3   16  0.00000000  0.00000000  0.00000000  0.00000000  -41.50666560    173.75778560    100.000000  1

I've read about rounding issues in the official dronekit documentation: https://dronekit-python.readthedocs.io/en/latest/examples/mission_import_export.html我已经阅读了官方dronekit 文档中的舍入问题: https ://dronekit-python.readthedocs.io/en/latest/examples/mission_import_export.html

However, I've checked right up to the final upload, and there don't seem to be any rounding issues.但是,我一直检查到最终上传,似乎没有任何舍入问题。 So unless its something deep in the pymavlink library or on the pixhawk itself (which I doubt because uploading and downloading via mission planner does not cause this issue), I don't think this is the issue.因此,除非它在 ​​pymavlink 库或 pixhawk 本身的深处(我对此表示怀疑,因为通过任务规划器上传和下载不会导致此问题),否则我认为这不是问题。

Anyone has any ideas?任何人有任何想法?

I have made a post on the dronekit github explaining how to fix this issue.我在dronekit github 上发表了一篇文章,解释了如何解决这个问题。 The issue linked below is one I created myself with the same question as above and I have answered it with the solution to this problem.下面链接的问题是我用与上面相同的问题创建的问题,我已经用这个问题的解决方案回答了它。

https://github.com/dronekit/dronekit-python/issues/1005 https://github.com/dronekit/dronekit-python/issues/1005

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM