Simulating GPS input to pixhawk using target tracking sonar

There are a lot of ways to approach this, and spoofing GPS may be a good and easy way to do what you want, after all. The problem I see with this is that the navigation filter really doesn’t like discontinuities in the GPS position, so if the object is going in and out of sight, then you might have trouble dealing with that.

What I was initially thinking was this:

  • You have a distance and angle to the closest object in front of you.
  • Turn to face the object (get the angle to zero).
  • Lock in the forward distance to the object by controlling the forward/backward outputs.
  • Pilot can override yaw or forward at any point, when the pilot releases manual control, the current forward distance target is reset.

If you were in a current, with no inputs, then the ROV may do a sort of half circle around the target as it is pushed by the current, then hang out down-stream from the pylon. You would need some extra information to control your angle relative to the pylon as well, I don’t know if we have enough information to do that, but it may be possible by combining the sonar data with the compass data from the ROV.

To do this, I would copy depth hold mode, then do something like the rangefinder code (bottom following) found in depth hold mode, or add a P or PI controller instead.

1 Like