ArduPilot / ArduPilot/MAVProxy
fakegps does not modify data in drone
- Dominant language
- Python
- Stars
- 595
- Forks
- 773
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 18
Description
Hi,
I am having issues with the fakegps module. I tried using: `mavproxy.py --master=udp:127.0.0.1:14540 --load-module fakegps` to connect to my drone (PX4 Autopilot, jMavSim Simulator and QGroundControl) and then followed with `fakegps set lon xxx` `fakegps set lat xxx` `fakegps set alt xxx` but this does not modify any values from the drone (as far as I can tell from QGroundControl and jMavSim).
My second try was to use this script:
```python
import time
from pymavlink import mavutil
from MAVProxy.modules.lib import mp_module
from MAVProxy.modules.lib import mp_settings
master = mavutil.mavlink_connection('udpin:127.0.0.1:14540') # Create the connection
master.wait_heartbeat() # Wait a heartbeat before sending commands
def get_gps_time(tnow):
'''return gps_week and gps_week_ms for current time'''
leapseconds = 18
SEC_PER_WEEK = 7 * 86400
epoch = 86400*(10*365 + (1980-1969)/4 + 1 + 6 - 2) - leapseconds
epoch_seconds = int(tnow - epoch)
week = int(epoch_seconds) // SEC_PER_WEEK
t_ms = int(tnow * 1000) % 1000
week_ms = (epoch_seconds % SEC_PER_WEEK) * 1000 + ((t_ms//200) * 200)
return week, week_ms
FakeGPS_settings = mp_settings.MPSettings([("nsats", int, 16),
("lat", float, 47.3977),
("lon", float, 8.5456),
("alt", float, 1.0),
("rate", float, 5)])
gps_lat = FakeGPS_settings.lat
gps_lon = FakeGPS_settings.lon
gps_alt = FakeGPS_settings.alt
gps_vel = [0, 0, 0]
gps_week, gps_week_ms = get_gps_time(now)
time_us = int(now*1.0e6)
nsats = FakeGPS_settings.nsats
if nsats >= 6:
fix_type = 3
else:
fix_type = 1
master.mav.gps_input_send(time_us, 0, 0, gps_week_ms, gps_week, fix_type,
int(gps_lat*1.0e7), int(gps_lon*1.0e7), gps_alt,
1.0, 1.0,
gps_vel[0], gps_vel[1], gps_vel[2],
0.2, 1.0, 1.0,
nsats)
```
Does anyone have a clue on how to properly set spoofed GPS data on the drone?
Thanks a lot.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the `fakegps` module commands with the stated MAVProxy, PX4, jMavSim, and QGroundControl setup. Inspect the fakegps entry point and the `gps_input_send` path, then compare the emitted GPS values with the telemetry shown by QGroundControl and jMavSim; done means the spoofed latitude, longitude, and altitude are reflected by the drone.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100