Skip to content

Commit

Permalink
Funktionen zum Abrufen des letzen Abstandswertes hinzugefügt
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusWichelmann committed Jul 28, 2015
1 parent ceb8df9 commit 06491ce
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
18 changes: 15 additions & 3 deletions LaserMeasurement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,25 @@ int LaserMeasurement::GetDistanceFromImage(cv::Mat frame)
// Laserposition abrufen
float laserPosition = GetLaserPosition(frame, BAR_START, BAR_START + BAR_HEIGHT);

// LaserPosition merken
_lastLaserPosition = laserPosition;
// LaserPosition merken
_lastLaserPosition = laserPosition;

// Wert auf Gültigkeit überprüfen
if(laserPosition < 0)
{
// Abstandswert merken
_lastDistance = -1;

// Spar dir die Berechnung, kommt sowieso Müll raus
return 0;
return -1;
}

// Distanz berechnen
float distance = (-LASER_DISTANCE / tan(ALPHA)) / (2 * (CAMERA_WIDTH / 2 - laserPosition) / CAMERA_WIDTH * tan(GAMMA / 2) / tan(ALPHA) - 1);

// Abstandswert merken
_lastDistance = distance;

// Distanz zurückgeben
return distance;
}
Expand Down Expand Up @@ -156,6 +162,12 @@ int LaserMeasurement::GetLastLaserPosition()
return _lastLaserPosition;
}

int LaserMeasurement::GetLastDistance()
{
// Letzen Abstandswert zurückgeben
return _lastDistance;
}

int LaserMeasurement::GetBrightnessAvg(std::vector<int> bar, int avgStart, int avgStop)
{
// Division durch 0 verhindern
Expand Down
6 changes: 6 additions & 0 deletions LaserMeasurement.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ namespace THOMAS
// Die letzte Laserposition
int _lastLaserPosition = -1;

// Der letzte Abstandswert
int _lastDistance = -1;

public:
// Konstruktor
LaserMeasurement();
Expand All @@ -83,5 +86,8 @@ namespace THOMAS
// Gibt die letzte Laserposition zurück
int GetLastLaserPosition();

// Gibt den letzten Abstandswert zurück
int GetLastDistance();

};
}

0 comments on commit 06491ce

Please sign in to comment.