-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsonar.h
55 lines (39 loc) · 1.14 KB
/
sonar.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef SONAR_H
#define SONAR_H
#include "audioPlayer.h"
#include "audioRecorder.h"
#include "chrip.h"
struct sonarData{
QList<float> distance;
QList<float> signal;
};
class SONAR
{
public:
SONAR();
QList<float> getDistance();
void startSound();
sonarData getResults();
static const int air_speed = 343; // m/s
static const int max_distance = 4; // meters
int sample_desired_length;
double max_time; // max time duration which take sound to go to and back
static const bool distanceCompensation = true;
static const bool distanceMediumRemoval = true;
static const int distanceInitialisations = 10; // too long name
bool distanceInitialisationDone = false;
int distanceInitialisationRemaining = distanceInitialisations;
private:
AudioPlayer outputPlayer;
AudioRecorder inputPlayer;
Chrip chrip;
QList<float> sound;
// distance related functions
QList<float> correlateToDistance();
int getStart(QList<float> data);
QList<float> getDistance(QList<float> data);
QList<float> distanceThresholdList;
private slots:
void startRecording();
};
#endif // SONAR_H