Last active
February 18, 2016 18:24
-
-
Save wrenoud/691c8768bb40fcf567e0 to your computer and use it in GitHub Desktop.
Generates some multibeam data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
import math | |
import sqlite3 | |
from matplotlib import pylab as pl | |
conn = sqlite3.connect('data.db') | |
c = conn.cursor() | |
c.execute('DROP TABLE BEAMS') | |
# Create table | |
c.execute('''CREATE TABLE IF NOT EXISTS beams | |
(x real, y real, z real, deflection real, visited real, cluster real)''') | |
beams = 30 | |
sonarWidth = 140 #degrees | |
roll = 5 | |
beamwidth = float(sonarWidth)/float(beams) | |
depth = 10 | |
x = [] | |
y = [] | |
z = [] | |
linePings = 100 | |
for trackOffsetStep in range(3): | |
for alongTrackStep in range(linePings): | |
roll = 5*math.cos( (alongTrackStep + linePings*trackOffsetStep) * 5 / 180.0 * math.pi ) | |
for i in range(beams): | |
angle = i*beamwidth - sonarWidth/2.0 + beamwidth/2.0 + roll | |
y.append( depth*math.tan(angle/180*math.pi) + trackOffsetStep * 50 ) | |
z.append( depth ) | |
x.append( alongTrackStep ) | |
# Insert a row of data | |
c.execute("INSERT INTO beams VALUES (?,?,?,?,0,0)",(x[-1],y[-1],z[-1],angle) ) | |
#https://en.m.wikipedia.org/wiki/DBSCAN | |
# Save (commit) the changes | |
conn.commit() | |
# We can also close the connection if we are done with it. | |
# Just be sure any changes have been committed or they will be lost. | |
conn.close() | |
pl.plot(x,y,'.') | |
pl.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment