1

I need help figuring out how to set groundspeed in AUTO mode (which is apparently implemented with the Mavlink command "MAV_CMD_DO_CHANGE_SPEED"—but I can't find any examples of this). What I thought would work:

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))

Based off of: https://pixhawk.ethz.ch/mavlink/ and https://github.com/mavlink/mavlink/blob/master/message_definitions/v1.0/common.xml

But it does not work.

Can anyone help me out?

Charlie Fish
  • 18,491
  • 19
  • 86
  • 179
Amy Chen
  • 11
  • 3

3 Answers3

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()
squilter
  • 400
  • 1
  • 6
  • Correct. This only works in GUIDED mode. To control the speed in AUTO, it must be part of the mission. So add a `MAV_CMD_DO_CHANGE_SPEED` as a mission item. – squilter Jul 24 '16 at 05:51
  • Do you have an example implementing this? I've already tried adding this command as a mission item but I printed the groundspeed while the drone went through the mission and it didn't seem to work. – Amy Chen Jul 25 '16 at 17:20
0

You can set the parameter 'WPNAV_SPEED' to the desired speed (in cm) before setting the mode to AUTO. Something like this:

vehicle.parameters['WPNAV_SPEED'] = 500    
epinal
  • 1,415
  • 1
  • 13
  • 27
0

The following will work:

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) )

You can double check it by running the code then connecting to a GCS and downloading the mission from the vehicle.

armadillo
  • 3
  • 3