SITL GPS spoofing - how to do it?

Hi there,

I’m trying to simulate GPS spoofing for the SITL and it doesn’t work as intended. It looks possible if you are looking at the data from this site https://ieee-dataport.org/open-access/uav-attack-dataset.

What I’m have done is disable GPS(SIM_GPS_BLOCK=1) and sent the GPS msg to the hil_gps.
But the drone gets some errors in the compas or other sensors.

Note:
I use the newest stable release for the PX4

So my question is:
(1) Can I do it in a different way?
(2) Is the way I’m doing it the only way?

You can hack it in place in the simulator module. https://github.com/PX4/PX4-Autopilot/blob/f571b29ae8152cc0b3d0f6bb7f160e3a44a8d9ed/src/modules/simulator/simulator_mavlink.cpp#L324-L341

If there are specific ways you want to spoof GPS or simulate failures we can extend it as needed.

In general, I should overwrite the GPS msg when I want to spoof the drone. So when I spoof the drone should it get false GPS messages. The behavior of the drone should be something like this when I spoof the drone( See the image below)
image

@dagar, how can I be sure that the drone will accept the new GPS msgs from the topic ‘/mavros/hil/gps’.
I can’t see my way out of that?

Any updates on this ?

I have linket to my master thesis where I did it in this link:

I hope you can figure out how i did it

1 Like