Sending PCMD commands in a fixed frequency

Hi guys,

I am working in Olympe and I want to send PCMD commands in 20 Hz to ANAFI. When I use ROS to control an AR DRONE 2.0 for example, I can specify the frequency as 50 Hz and create a while loop like while not rospy.is_shutdown(). Then the time interval of each step in this loop is 0.02 seconds. But for Olympe, right now I only have a rough demo like below. Does anyone have any thoughts or ideas?

idx = 0
t_begin = time.time()
while idx < 50:
    t_start = time.time()
    drone(PCMD(1, 50, 0, 0, 10, 0))
    idx += 1
    t_exc_end = time.time() - t_start
    time.sleep(0.05 - t_exc_end)
    t_end = time.time() - t_start
    print("execute time")
    print("time interval for each step")

And I don’t understand the explanation for PCMD’s parameter timestampAndSeqNum. Can anyone post an example for this?


The “timestampAndSeqNum” field was only used for debug purposes, you can safely pass 0, it won’t have any effect on the flight :wink:


Thank you so much, Nicolas!

Just to mention another possibility, there also are the functions
drone.piloting_pcmd(...) and
which allow to send PCMD commands regularly.
I haven’t looked into the frequency with which they are sent, but if you just need regular piloting this seems to be the easiest method.

1 Like

Thank you so much, fisian!