Controlling velocity while using topic /mavros/setpoint_raw/global

Hi, I was doing the flight with my drone using python and rospy, the plan is to fly the drone to a certain coordinate (global coordinate, latitude and longitude), land there, wait a couple second, and then fly back to home, then land the drone. I was using “/mavros/setpoint_raw/global” topic to fly the drone, here’s my message to fly the drone (lat and long variable is input coodinate):
msg = GlobalPositionTarget()
msg.header.stamp =
msg.coordinate_frame = GlobalPositionTarget().FRAME_GLOBAL_REL_ALT
msg.latitude = lat
msg.longitude = long
msg.altitude = 4.0
msg.type_mask = 4088
msg.velocity.x = 0.0
msg.velocity.y = 0.0
msg.velocity.z = 0.0
msg.acceleration_or_force.x = 0.0
msg.acceleration_or_force.y = 0.0
msg.acceleration_or_force.z = 0.0
msg.yaw = 0
msg.yaw_rate = 0

On the first flight, the acceleration or force values are ignored by type_mask, and I observed that the drone flew too fast to the goal coordinate, then I change the type_mask to accept the acceleration values, and change the acceleration x and y value to 0.01. In the next flight the drone was indeed fly slower than the first flight and reach the destination safely, but when the drone flew back to the home coordinate, the drone flew fast again and crash. So I’m not really sure how to reduce the velocity of the drone. I need the drone to move slowly to avoid lost contact with the drone and make the observation easier.

Is there any way to reduce or limit the velocity of the drone while using setpoint_raw/global? As any autonomous drone program using mavros I’ve found in the internet using cmd_vel and such so the program itself controls the speed, but I haven’t seen the usage of the setpoint_raw/global topic with additional speed limit aside from coordinate input.

Also I’ve tried to change the velocity value (x and y) in the message by 0.2 for each x and y, but I think it didn’t work because when I tried it the drone flipped itself while it tried to takeoff.


Hi,may i view the code of that you control the drone to certain coordinate(lat &long). I recently turn to use ardupilot ,there are some different from PX4. Ardupilot can use GlobalPositionTarget message ,so i would like to view the usage .Tks!

@khancyr can give some good advice re mavros and ArduPilot, but it would be better for you to open a new thread so that it is clearer what the discussion is about