Delay in position controller tracking

Hello all,

I am trying to do offboard flight using PX4 v1.9.0, ROS (in Higher-level) and Optitrack for motion capture. I do not use MAVROS but have another way of sending associated MAVLink messages. I switch from manual to POSCTL and then to offboard. When switching to offboard, I have configured it in such a way that the drone hovers at the starting point of the desired trajectory. In this case, its a circular trajectory with starting point as (3,0). I am sending both position and velocity setpoints but from the log files, PixHawk seems to command its own velocity.

When the drone begins to actually track the trajectory I noticed the controller lags behind its setpoint.

It would be great if you guys could please help with:
a. Quantifying the delay - I think i need to convert timestamp into time and I guess the log frequency is 10 Hz although I am not sure how to calculate the delay in ms.
b. Is this delay existing because of the offboard setup and from the network? I do have a 5G enabled gaming based router. Is there a way to compensate for this constant delay? From my experience testing other trajectories, the delay exists and is constant but its magnitude varies with trajectory I believe although still not sure.

Also, this is my first time posting here so I apologize if I haven’t conveyed information properly the way its supposed to. Feel free to ask for additional plots or clarifications.

Thanks.

@ksathya Is offboard setpoints being passed over a network or a serial interface? If it is through a network, this will depend highly on your network setup.

You need to quantify delay separately from the tracking performance. Tracking lag can be caused not only by delay but from the controller itself and also the type of setpoints you are sending(feedforward such as velocity, acceleration)