概述
视频链接如下:
Ardupilot 伴飞,追击
简单介绍:
采用2个ArduPilot固件才实现的,放在不同的路径下,启动即可。
注意事项:
- 两架飞机需要采用不同的句柄。–instance=X.
- 两架飞机需要设置不同的ID, 对应参数sysidXXX =X
- 采用dronekit-python 分别连接上两个端口。然后通过句柄读出第一架飞机的GPS信息,并经过算法处理发送给2号飞机。
- 下面给出demo历程。可以二次修改。
- 第二架飞机在启动仿真的时候,不需要打开14550以及14551端口,否则两个仿真都共用这个端口。对应参数为 --no-extra-ports
存在的问题:
- 无法在一个软件包中启动,没有找到./sim_vehicle启动时候加载的参数文件位置,否则通过加载不通的参数文件,应该可以直接完成
- python-socket没有仔细研究,没有完成2台电脑,每一台分别控制一架飞机的情况。
- 在mavproxy的地图中没有显示两架飞机。
- 没有尝试gazebo仿真。
#!/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 伴飞,追击demo所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复