linux系统链接飞控以及配置SITL以及ardupilot环境
先更改本机host到对象的ip
再进行ssh的链接
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-meuTGFrN-1651933771950)(https://s2.loli.net/2022/05/07/eY3L84RVOZF6MrS.png)]
链接成功进入系统
链接飞控
from dronekit import connect
vehicle = connect('/dev/ttyUSB0', wait_ready=True, baud=921600)
print "Autopilot Firmware version: %s" % vehicle.version
print "Autopilot capabilities (supports ftp): %s" % vehicle.capabilities.ftp
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 "Groundspeed: %s" % vehicle.groundspeed
print "Airspeed: %s" % vehicle.airspeed
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 "Mode: %s" % vehicle.mode.name
print "Armed: %s" % vehicle.armed
SITL仿真实例
"""
© Copyright 2015-2016, 3D Robotics.
simple_goto.py: GUIDED mode "simple goto" example (Copter Only)
Demonstrates how to arm and takeoff in Copter and how to navigate to points using Vehicle.simple_goto.
"""
from __future__ import print_function
import time
from dronekit import connect, VehicleMode, LocationGlobalRelative
connection_string = '10.42.0.10:14550'
print('Connecting to vehicle on: %s' % connection_string)
vehicle = connect(connection_string,wait_ready=True,baud=921600)
def arm_and_takeoff(aTargetAltitude):
print("Basic pre-arm checks")
while not vehicle.is_armable:
print(" Waiting for vehicle to initialise...")
time.sleep(1)
print("Arming motors")
vehicle.mode = VehicleMode("GUIDED")
vehicle.armed = True
while not vehicle.armed:
print(" Waiting for arming...")
time.sleep(1)
print("Taking off!")
vehicle.simple_takeoff(aTargetAltitude)
while True:
print(" Altitude: ", vehicle.location.global_relative_frame.alt)
if vehicle.location.global_relative_frame.alt >= aTargetAltitude * 0.95:
print("Reached target altitude")
break
time.sleep(1)
arm_and_takeoff(10)
print("Set default/target airspeed to 3")
vehicle.airspeed = 3
print("Going towards first point for 30 seconds ...")
point1 = LocationGlobalRelative(-35.361354, 149.165218, 20)
vehicle.simple_goto(point1)
time.sleep(30)
print("Going towards second point for 30 seconds (groundspeed set to 10 m/s) ...")
point2 = LocationGlobalRelative(-35.363244, 149.168801, 20)
vehicle.simple_goto(point2, groundspeed=10)
time.sleep(30)
print("Returning to Launch")
vehicle.mode = VehicleMode("RTL")
print("Close vehicle object")
vehicle.close()
仿真会使用到git docker以及ardupilot组件
所以我们对本机进行环境配置
https://github.com/ArduPilot/ardupilot
前往仓库
获取git链接
gitclone
git clone -b Copter-4.0.7 https://github.com/ArduPilot/ardupilot.git
接着再拉取子模块
eleven@shiyideMacBook-Pro-2 ardupilot % git branch
* (非分支)
eleven@shiyideMacBook-Pro-2 ardupilot % git checkout -b Copter-4.0.7
切换到一个新分支 'Copter-4.0.7'
eleven@shiyideMacBook-Pro-2 ardupilot % git branch
* Copter-4.0.7
eleven@shiyideMacBook-Pro-2 ardupilot % git submodule update --init --recursive
如果遇到失败fail情况
可以直接前往地址下载
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-g376B5aj-1651933771956)(https://s2.loli.net/2022/05/07/MUqCL1YdlKXyN4u.png)]
下载完毕后
进行环境自安装
eleven@shiyideMacBook-Pro-2 ardupilot % cd Tools
eleven@shiyideMacBook-Pro-2 Tools % cd environment_install
eleven@shiyideMacBook-Pro-2 environment_install % cat install-prereqs-mac.sh
因为我是用的是mac所以选择mac的.sh文件
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-3Y1A88zs-1651933771957)(https://s2.loli.net/2022/05/07/hsMUHcziSAVIeKa.png)]
基本都是安装一些依赖包
可能会有网络问题装不上什么的
多执行几次更改自己的网络条件
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)