我需要帮助搞清楚如何在AUTO模式下设置地速(这显然是使用Mavlink命令“MAV_CMD_DO_CHANGE_SPEED”实现的 - 但我找不到任何这方面的例子)。我认为会起作用:
vehicle.commands.add(Command( 0, 0, 0, mavutil.mavlink.MAV_FRAME_GLOBAL_RELATIVE_ALT, mavutil.mavlink.MAV_CMD_DO_CHANGE_SPEED, 0, 0, 1, 0.25, 0, 0, 0, 0, 0))
基于: https://pixhawk.ethz.ch/mavlink/ 和 https://github.com/mavlink/mavlink/blob/master/message_definitions/v1.0/common.xml
但它不起作用。
任何人都可以帮助我吗?
答案 0 :(得分:0)
msg = vehicle.message_factory.command_long_encode(
0, 0, # target system, target component
mavutil.mavlink.MAV_CMD_DO_CHANGE_SPEED, #command
0, #confirmation
0, #speed type, ignore on ArduCopter
speed, # speed
0, 0, 0, 0, 0 #ignore other parameters
)
# send command to vehicle
vehicle.send_mavlink(msg)
vehicle.flush()
答案 1 :(得分:0)
您可以设置参数' WPNAV_SPEED'在将模式设置为AUTO之前,以所需的速度(以cm为单位)。 像这样:
vehicle.parameters['WPNAV_SPEED'] = 500
答案 2 :(得分:0)
以下将起作用:
speed_type = 1 # 0 is airspeed (for plane with airspeed sensor), 1 is groundspeed
speed = 15
throttle_setting = 0
cmds.add( Command( 0, 0, 0, mavutil.mavlink.MAV_FRAME_GLOBAL_RELATIVE_ALT, mavutil.mavlink.MAV_CMD_DO_CHANGE_SPEED, 0, 0, speed_type, speed, throttle_setting, 0, 0, 0, 0) )
您可以通过运行代码再次检查它,然后连接到GCS并从车辆下载任务。