Circle in guided mode

So I sort of managed to get the copter to do a circle in guided mode (on Gazebo / ROS SITL).

This is the code:

def fly_in_circles (centre, radius, loops = 1):
print ('Circling')
points =  24 # specified points in circle
bearing_step = 360/points

print ('centre: '+str(centre))

for loop in range (0, loops):
    print("starting loop")
    for point in range (1, points+1):
        bearing = point*bearing_step
        print("Bearing ok")
        target_coordinates = radius.destination(point = centre, bearing = bearing) #geopy .destination: destination point using a starting point, bearing and a distance. This method works for non-abstract distances only.

        print ('target_cooordinate: '+str(target_coordinates))

        x =  int((target_coordinates.latitude) *1e7)
        y =  int((target_coordinates.longitude) *1e7)
        z =  int((takeoff_height))

        print('X = '+str(x)+' Y = ' +str(y)+' Z = ' +str(z))

        go_msg = vehicle.message_factory.set_position_target_global_int_encode(
                0, 0,
                0b0000111111111000, # use position
                x, y, z, #X, Y, Z Positions in WGS84 frame in 1e7 * meters

        print ("Heading to loc")
        time.sleep (2)

My concern is that as the circle radius gets smaller the 2 second wait becomes more prominent, in fact below a certain distance between points you can see the drone “slowing down”. There is also the assumption that the message gets uploaded and executed, but I don’t know how to verify this between steps and whether there is a need to resend the same message in case for some reason one step does not get executed (?). I wish I could do without the 2 second wait and have it replaced with something more “robust”.

I am also conscious of the fact that the GPS is not as accurate in real life as it is in the simulation so the circle is likely to be more of a random-shaped polygon.

I’d like to know what the opinion of others is regarding my method here.

I managed to fly a circle with a 2Hz update rate by setting velocities. This was over a SiK radio telemetry link so I would hope that faster than this would be possible over a serial link.

I would increase the loop speed to twice a second and see if you get better results.

You can check that your drone is flying to the correct location by requesting it to send you certain messages. Have a look at what Mavlink messages are available but the ones that come to mind are MAVLINK_MSG_ID_LOCAL_POSITION_NED and MAVLINK_MSG_ID_GLOBAL_POSITION_INT. I’m still getting to know all this stuff myself mind you.

I did think about setting velocities, and I think it would work out smoother that way but I could not think of a good way to implement that with a moving target for the centre of the “circle”. How did you go
about that? Do you have any code you are willing to show/share please?