我是靠谱客的博主 陶醉舞蹈,这篇文章主要介绍Ardupilot 伴飞,追击demo,现在分享给大家,希望可以做个参考。

视频链接如下:
Ardupilot 伴飞,追击

简单介绍:
采用2个ArduPilot固件才实现的,放在不同的路径下,启动即可。
注意事项:

  1. 两架飞机需要采用不同的句柄。–instance=X.
  2. 两架飞机需要设置不同的ID, 对应参数sysidXXX =X
  3. 采用dronekit-python 分别连接上两个端口。然后通过句柄读出第一架飞机的GPS信息,并经过算法处理发送给2号飞机。
  4. 下面给出demo历程。可以二次修改。
  5. 第二架飞机在启动仿真的时候,不需要打开14550以及14551端口,否则两个仿真都共用这个端口。对应参数为 --no-extra-ports

存在的问题:

  1. 无法在一个软件包中启动,没有找到./sim_vehicle启动时候加载的参数文件位置,否则通过加载不通的参数文件,应该可以直接完成
  2. python-socket没有仔细研究,没有完成2台电脑,每一台分别控制一架飞机的情况。
  3. 在mavproxy的地图中没有显示两架飞机。
  4. 没有尝试gazebo仿真。
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env python # -*- coding: utf-8 -*- """ © Copyright 2015-2016, 3D Robotics. vehicle_state.py: Demonstrates how to get and set vehicle state and parameter information, and how to observe vehicle attribute (state) changes. Full documentation is provided at http://python.dronekit.io/examples/vehicle_state.html """ from __future__ import print_function from dronekit import connect, VehicleMode, LocationGlobalRelative import time #Set up option parsing to get connection string import argparse parser = argparse.ArgumentParser(description='Print out vehicle state information. Connects to SITL on local PC by default.') parser.add_argument('--connect', help="vehicle connection target string. If not specified, SITL automatically started and used.") args = parser.parse_args() connection_string1 = args.connect sitl = None #Start SITL if no connection string specified if not connection_string1: import dronekit_sitl sitl = dronekit_sitl.start_default() connection_string = sitl.connection_string() connection_string2 = '127.0.0.1:8888' # Connect to the Vehicle. # Set `wait_ready=True` to ensure default attributes are populated before `connect()` returns. print("nConnecting to vehicle on: %s" % connection_string1) vehicle = connect(connection_string1, wait_ready=True) vehicle2 = connect(connection_string2, wait_ready=True) vehicle.wait_ready('autopilot_version') # Get all vehicle attributes (state) print("nGet all vehicle attribute values:") print(" Autopilot Firmware version: %s" % vehicle.version) print(" Major version number: %s" % vehicle.version.major) print(" Minor version number: %s" % vehicle.version.minor) print(" Patch version number: %s" % vehicle.version.patch) print(" Release type: %s" % vehicle.version.release_type()) print(" Release version: %s" % vehicle.version.release_version()) print(" Stable release?: %s" % vehicle.version.is_stable()) print(" Autopilot capabilities") print(" Supports MISSION_FLOAT message type: %s" % vehicle.capabilities.mission_float) print(" Supports PARAM_FLOAT message type: %s" % vehicle.capabilities.param_float) print(" Supports MISSION_INT message type: %s" % vehicle.capabilities.mission_int) print(" Supports COMMAND_INT message type: %s" % vehicle.capabilities.command_int) print(" Supports PARAM_UNION message type: %s" % vehicle.capabilities.param_union) print(" Supports ftp for file transfers: %s" % vehicle.capabilities.ftp) print(" Supports commanding attitude offboard: %s" % vehicle.capabilities.set_attitude_target) print(" Supports commanding position and velocity targets in local NED frame: %s" % vehicle.capabilities.set_attitude_target_local_ned) print(" Supports set position + velocity targets in global scaled integers: %s" % vehicle.capabilities.set_altitude_target_global_int) print(" Supports terrain protocol / data handling: %s" % vehicle.capabilities.terrain) print(" Supports direct actuator control: %s" % vehicle.capabilities.set_actuator_target) print(" Supports the flight termination command: %s" % vehicle.capabilities.flight_termination) print(" Supports mission_float message type: %s" % vehicle.capabilities.mission_float) print(" Supports onboard compass calibration: %s" % vehicle.capabilities.compass_calibration) print(" Global Location: %s" % vehicle.location.global_frame) print(" Global Location (relative altitude): %s" % vehicle.location.global_relative_frame) print(" Local Location: %s" % vehicle.location.local_frame) print(" Attitude: %s" % vehicle.attitude) print(" Velocity: %s" % vehicle.velocity) print(" GPS: %s" % vehicle.gps_0) print(" Gimbal status: %s" % vehicle.gimbal) print(" Battery: %s" % vehicle.battery) print(" EKF OK?: %s" % vehicle.ekf_ok) print(" Last Heartbeat: %s" % vehicle.last_heartbeat) print(" Rangefinder: %s" % vehicle.rangefinder) print(" Rangefinder distance: %s" % vehicle.rangefinder.distance) print(" Rangefinder voltage: %s" % vehicle.rangefinder.voltage) print(" Heading: %s" % vehicle.heading) print(" Is Armable?: %s" % vehicle.is_armable) print(" System status: %s" % vehicle.system_status.state) print(" Groundspeed: %s" % vehicle.groundspeed) # settable print(" Airspeed: %s" % vehicle.airspeed) # settable print(" Mode: %s" % vehicle.mode.name) # settable print(" Armed: %s" % vehicle.armed) # settable while True: print("vehicle1 Global Location: %s" % vehicle.location.global_frame) print("vehicle1 Global Location: %s" % vehicle2.location.global_frame) print(" Mode: %s" % vehicle.mode.name) # settable print(" Armed: %s" % vehicle.armed) # settable print(" Local Location: %s" % vehicle.location.local_frame) time.sleep(1) if vehicle.armed and vehicle.location.local_frame.down<-10: point1 = LocationGlobalRelative(vehicle.location.global_frame.lat,vehicle.location.global_frame.lon, 20) vehicle2.simple_goto(point1) print("simple goto")

最后

以上就是陶醉舞蹈最近收集整理的关于Ardupilot 伴飞,追击demo的全部内容,更多相关Ardupilot内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(80)

评论列表共有 0 条评论

立即
投稿
返回
顶部