无人机编程donekit及通讯(一)

 读取属性

# 飞控软件版本
print "Autopilot Firmware version: %s" % vehicle.version
# 全球定位信息(经纬度,高度相对于平均海平面)
print "Global Location: %s" % vehicle.location.global_frame
# 全球定位信息(经纬度,高度相对于home点)
print "Global Location (relative altitude): %s" % vehicle.location.global_relative_frame
# 相对home点的位置信息(向北、向东、向下);解锁之前返回None
print "Local Location: %s" % vehicle.location.local_frame
# 无人机朝向(欧拉角:roll,pitch,yaw,单位为rad,范围-π到+π)
print "Attitude: %s" % vehicle.attitude
# 三维速度(m/s)
print "Velocity: %s" % vehicle.velocity
# GPS信息
print "GPS: %s" % vehicle.gps_0
# 地速(m/s)
print "Groundspeed: %s" % vehicle.groundspeed
# 空速(m/s)
print "Airspeed: %s" % vehicle.airspeed
# 云台信息(得到的为当前目标的roll, pitch, yaw,而非测量值。单位为度)
print "Gimbal status: %s" % vehicle.gimbal
# 电池信息
print "Battery: %s" % vehicle.battery
# EKF(拓展卡曼滤波器)状态
print "EKF OK?: %s" % vehicle.ekf_ok
# 超声波或激光雷达传感器状态
print "Rangefinder: %s" % vehicle.rangefinder
# 无人机朝向(度)
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

设置属性

只有以下几个属性可以直接设置

Vehicle.mode
Vehicle.armed
Vehicle.airspeed
Vehicle.groundspeed

#disarm the vehicle
vehicle.armed = False

#set the default groundspeed to be used in movement commands
vehicle.groundspeed = 3.2

 无法确定属性一定设置成功,所以要加循环

vehicle.mode = VehicleMode("GUIDED")
vehicle.armed = True
while not vehicle.mode.name=='GUIDED' and not vehicle.armed and not api.exit:
    print " Getting ready to take off ..."
    time.sleep(1)

 常用函数

起飞
vehicle.simple_takeoff(targetHeight) 
定点
vehicle.simple_goto(targetLocation)

DroneKit-python入门教程教程-SITL仿真-使用自定义MAVLink指令 - 创客智造

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

桦树无泪

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值