CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_Declination/generate/testvectors.py
Views: 1799
1
#!/usr/bin/env python3
2
'''
3
generate some test vectors for autotest
4
'''
5
6
7
from pymavlink import mavextra
8
import random
9
import argparse
10
parser = argparse.ArgumentParser(description='generate test vectors')
11
parser.add_argument('--num-samples', type=int, default=100, help='number of samples')
12
13
args = parser.parse_args()
14
15
for i in range(args.num_samples):
16
lat = random.uniform(-89,89)
17
lon = random.uniform(-180,180)
18
mavextra.earth_field = None
19
m = mavextra.expected_earth_field_lat_lon(lat, lon)
20
print("{%f, %f, {%.3f, %.3f, %.3f}}," % (lat, lon, m.x, m.y, m.z))
21
22