UAV-5--链接飞控以及配置SITL以及ardupilot环境
linux系统链接飞控以及配置SITL以及ardupilot环境
先更改本机host到对象的ip
再进行ssh的链接
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-meuTGFrN-1651933771950)(https://s2.loli.net/2022/05/07/eY3L84RVOZF6MrS.png)]
链接成功进入系统
链接飞控
from dronekit import connect # Connect to the Vehicle (in this case a UDP endpoint) 后边那个baud是波特率
vehicle = connect('/dev/ttyUSB0', wait_ready=True, baud=921600) # vehicle is an instance of the Vehicle classprint "Autopilot Firmware version: %s" % vehicle.versionprint "Autopilot capabilities (supports ftp): %s" % vehicle.capabilities.ftpprint "Global Location: %s" % vehicle.location.global_frameprint "Global Location (relative altitude): %s" % vehicle.location.global_relative_frameprint "Local Location: %s" % vehicle.location.local_frame #NEDprint "Attitude: %s" % vehicle.attitudeprint "Velocity: %s" % vehicle.velocityprint "GPS: %s" % vehicle.gps_0print "Groundspeed: %s" % vehicle.groundspeedprint "Airspeed: %s" % vehicle.airspeedprint "Gimbal status: %s" % vehicle.gimbalprint "Battery: %s" % vehicle.batteryprint "EKF OK?: %s" % vehicle.ekf_okprint "Last Heartbeat: %s" % vehicle.last_heartbeatprint "Rangefinder: %s" % vehicle.rangefinderprint "Rangefinder distance: %s" % vehicle.rangefinder.distanceprint "Rangefinder voltage: %s" % vehicle.rangefinder.voltageprint "Heading: %s" % vehicle.headingprint "Is Armable?: %s" % vehicle.is_armableprint "System status: %s" % vehicle.system_status.stateprint "Mode: %s" % vehicle.mode.name # settableprint "Armed: %s" % vehicle.armed # settable
SITL仿真实例
# -*- coding: utf-8 -*- """
© 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# 改为当前连接的pixhawk飞控的端口 下边是IP端口
connection_string = '10.42.0.10:14550'
print('Connecting to vehicle on: %s' % connection_string)
# connect函数将会返回一个Vehicle类型的对象,即此处的vehicle
# 即可认为是无人机的主体,通过vehicle对象,我们可以直接控制无人机
vehicle = connect(connection_string,wait_ready=True,baud=921600)# 定义arm_and_takeoff函数,使无人机解锁并起飞到目标高度
# 参数aTargetAltitude即为目标高度,单位为米
def arm_and_takeoff(aTargetAltitude):# 进行起飞前检查 print("Basic pre-arm checks")# vehicle.is_armable会检查飞控是否启动完成、有无GPS fix、卡曼滤波器 # 是否初始化完毕。若以上检查通过,则会返回True while not vehicle.is_armable:print(" Waiting for vehicle to initialise...")time.sleep(1)# 解锁无人机(电机将开始旋转) print("Arming motors")# 将无人机的飞行模式切换成"GUIDED"(一般建议在GUIDED模式下控制无人机) vehicle.mode = VehicleMode("GUIDED")# 通过设置vehicle.armed状态变量为True,解锁无人机 vehicle.armed = True# 在无人机起飞之前,确认电机已经解锁 while not vehicle.armed:print(" Waiting for arming...")time.sleep(1)# 发送起飞指令 print("Taking off!")# simple_takeoff将发送指令,使无人机起飞并上升到目标高度 vehicle.simple_takeoff(aTargetAltitude)# 在无人机上升到目标高度之前,阻塞程序 while True:print(" Altitude: ", vehicle.location.global_relative_frame.alt)# 当高度上升到目标高度的0.95倍时,即认为达到了目标高度,退出循环 # vehicle.location.global_relative_frame.alt为相对于home点的高度 if vehicle.location.global_relative_frame.alt >= aTargetAltitude * 0.95: print("Reached target altitude")break# 等待1s time.sleep(1)# 调用上面声明的arm_and_takeoff函数,目标高度10m
arm_and_takeoff(10)# 设置在运动时,默认的空速为3m/s
print("Set default/target airspeed to 3")
# vehicle.airspeed变量可读可写,且读、写时的含义不同。
# 读取时,为无人机的当前空速;写入时,设定无人机在执行航点任务时的默认速度
vehicle.airspeed = 3# 发送指令,让无人机前往第一个航点
print("Going towards first point for 30 seconds ...")
# LocationGlobalRelative是一个类,它由经纬度(WGS84)和相对于home点的高度组成
# 这条语句将创建一个位于南纬35.361354,东经149.165218,相对home点高20m的位置
point1 = LocationGlobalRelative(-35.361354, 149.165218, 20)
# simple_goto函数将位置发送给无人机,生成一个目标航点
vehicle.simple_goto(point1)# simple_goto函数只发送指令,不判断有没有到达目标航点
# 它可以被其他后续指令打断,此处延时30s,即让无人机朝向point1飞行30s
time.sleep(30)# 发送指令,让无人机前往第二个航点
print("Going towards second point for 30 seconds (groundspeed set to 10 m/s) ...")
# 与之前类似,这条语句创建了另一个相对home高20m的点
point2 = LocationGlobalRelative(-35.363244, 149.168801, 20)
# simple_goto将目标航点发送给无人机,groundspeed=10设置飞行时的地速为10m/s
vehicle.simple_goto(point2, groundspeed=10)# 与之前一样,延时30s
time.sleep(30)# 发送"返航"指令
print("Returning to Launch")
# 返航,只需将无人机的飞行模式切换成"RTL(Return to Launch)"
# 无人机会自动返回home点的正上方,之后自动降落
vehicle.mode = VehicleMode("RTL")# 退出之前,清除vehicle对象
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)]
基本都是安装一些依赖包
可能会有网络问题装不上什么的
多执行几次更改自己的网络条件
UAV-5--链接飞控以及配置SITL以及ardupilot环境相关推荐
- JDBC.property 配置文件中链接数据库的配置
JDBC.property 配置文件中链接数据库的配置 #sqlserver数据源配置 jdbc.driverClassName=com.microsoft.sqlserver.jdbc.SQLSer ...
- debian重启ssh服务_VScode链接服务器并配置公钥SSH Keys
VScode链接服务器并配置公钥-SSH Keys 一直在用Xshell做SSH连接服务器与虚拟机,但是中文乱码的问题一直找不到解决方案,干脆使用编辑器自带的插件,集成之后用起来也方便 1.概述 做法 ...
- vscode私钥设置_VScode链接服务器并配置公钥-SSH Keys
VScode链接服务器并配置公钥-SSH Keys 一直在用Xshell做SSH连接服务器与虚拟机,但是中文乱码的问题一直找不到解决方案,干脆使用编辑器自带的插件,集成之后用起来也方便 1.概述 做法 ...
- PHP环境搭建:Windows 7下安装配置PHP+Apache+Mysql环境教程(转)
转至:http://www.leapsoul.cn/?p=695 这两天刚装好Windows 7,碰巧前段时间有朋友问我Windows下如何安装搭建PHP环境,所以打算勤劳下,手动一步步搭建PHP环境 ...
- windows 下配置 react native 开发环境
windows 下配置 react native 开发环境 安装nvm 由于react native 需要使用 NodeJs 4.0以上版本,为了方便切换NodeJs,首先我们需要安装nvm. 你可以 ...
- PHP环境搭建:Windows 7下安装配置PHP+Apache+Mysql环境教程
来源:http://www.leapsoul.cn/?p=695 这两天刚装好Windows 7,碰巧前段时间有朋友问我Windows下如何安装搭建PHP环境,所以打算勤劳下,手动一步步搭建PHP环境 ...
- myeclipse怎么运行c语言,windows下MyEclipse安装配置C/C++开发环境
windows下MyEclipse安装配置C/C++开发环境 ,安装MinGW:假设安装路径为c:\MinGW 编辑如下系统变量: 变量名变量值 PATH C:\MinGW\bin; LIBRARY_ ...
- 配置window下python3环境
功能介绍 整理生信小知识库,一些技巧一些知识. 昨天 以下配置环境基于window操作系统,安装python3版本为例,推荐基础版配置. ! METHOD 1 (基础版) 官网下载对应电脑版本的pyt ...
- docker anaconda_深度学习炼丹炉配置[1] Docker+sshfs环境配置
感谢 @田文善 同学供稿 目录 一.需求二.方案(一)docker 配置1.dockerfile 制作2.构建 docker 镜像3.运行 docker 容器4.使用 docker 容器5.环境复用( ...
最新文章
- Android 多媒体综述
- 一个牛逼的 多级缓存 实现方案!
- 【SLAM】卡尔曼滤波:究竟滤了谁?
- [BZOJ4349]最小树形图
- sklearn模型保存
- script标签的加载解析执行
- js parsefloat 精度_javascript中的float运算精度
- 一题多解 —— linux 日志文件(log)reload 重新载入
- 浏览器输入网址回车发生的事情?--
- kubectl apply -f weave.yaml之后dns没有启动起来 weave-net CrashLoopBackOff
- python 期货策略_Python版商品期货跨期对冲策略
- 宏杉MacroSan存储开局指导-流程
- mysql数据库面试题学生表_SQL笔试题:下面是学生表(student)的结构说明
- 牛逼!分享一款基于 SpringBoot 的微信点餐系统(附源码)
- 网站三级域名是什么样?
- Font Awesome 找图标的正确姿势
- 深度学习学习笔记——keras中的verbose
- 我的世界正版服务器客户端,我的世界1.11.2
- python3格式化输出
- 基于深度学习的图像语义编辑