summaryrefslogtreecommitdiffstats
path: root/Master/Real-Time Systems/RTS_A8/src/main.cpp
diff options
context:
space:
mode:
authorSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
committerSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
commit33613a85afc4b1481367fbe92a17ee59c240250b (patch)
tree670b842326116b376b505ec2263878912fca97e2 /Master/Real-Time Systems/RTS_A8/src/main.cpp
downloadStudium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.gz
Studium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.bz2
add new repoHEADmaster
Diffstat (limited to 'Master/Real-Time Systems/RTS_A8/src/main.cpp')
-rw-r--r--Master/Real-Time Systems/RTS_A8/src/main.cpp78
1 files changed, 78 insertions, 0 deletions
diff --git a/Master/Real-Time Systems/RTS_A8/src/main.cpp b/Master/Real-Time Systems/RTS_A8/src/main.cpp
new file mode 100644
index 0000000..fc3feed
--- /dev/null
+++ b/Master/Real-Time Systems/RTS_A8/src/main.cpp
@@ -0,0 +1,78 @@
+/*
+ * main.cpp
+ *
+ * Created on: 30.11.2010
+ * Author: istsveise
+ */
+#include "Task.h"
+#include "Display.h"
+#include "Fahren.h"
+#ifndef POS_H_
+ #include "POS.h"
+#endif
+#ifndef NOTBREMSE_H_
+ #include "Notbremse.h"
+#endif
+
+#include <iostream>
+#include <stdlib.h>
+#include <pthread.h>
+#include <semaphore.h>
+#include <cmath>
+
+using namespace std;
+
+// global mutex to protect vehicle
+pthread_mutex_t vehicleMutex;
+
+POS vehiclePosition;
+double lineDir;
+const double PI = 3.14159265359;
+
+double Abstand(POS p,double Ldir)
+{
+ vector3d origin;
+ vector3d point(p.x,p.y);
+ double polx = 1.0;
+ double ldirRad = Ldir*PI/180;
+ double m = tan(ldirRad);
+ double poly = polx*m;
+ vector3d pointOnLine(polx,poly);
+ vector3d normVec;
+ origin.crossProduct(pointOnLine,normVec);
+ normVec.normalize();
+ double d = normVec.scalarProduct(point);
+ return d;
+}
+
+void InitAll(int x)
+{
+ pthread_mutex_init(&vehicleMutex,NULL);
+ pthread_mutex_lock(&vehicleMutex);
+ lineDir = x;
+ vehiclePosition.x = 0;
+ vehiclePosition.y = 0;
+ pthread_mutex_unlock(&vehicleMutex);
+}
+
+int main(int argc,char* argv[])
+{
+ InitAll(30); // direction of line [0, 90]
+
+ sleep(1);
+
+ Display D(100);
+ Notbremse N(100);
+
+ cout << "Los geht's...!" << endl;
+ Fahren F(/* period in ms */ 100,
+ /* speed in pixels per second */ 20,
+ /* start direction [0, 90] */ 0);
+
+ //sleep for ever
+ sem_t block;
+ sem_init(&block,0,0);
+ sem_wait(&block);
+
+ return EXIT_SUCCESS;
+}