From dc02d9f6d49824214d27aa7dd7b9397a91ff3b75 Mon Sep 17 00:00:00 2001
From: Hoop77 <p.badenhoop@gmx.de>
Date: Thu, 10 May 2018 12:59:45 +0200
Subject: [PATCH] SpeedMeasure

---
 .../src/VeloxProtocolLib/CMakeLists.txt       |  4 +++
 .../VeloxProtocolLib/test/SpeedMeasure.cpp    | 35 +++++++++++++++++++
 2 files changed, 39 insertions(+)
 create mode 100644 modules/catkin_ws/src/VeloxProtocolLib/test/SpeedMeasure.cpp

diff --git a/modules/catkin_ws/src/VeloxProtocolLib/CMakeLists.txt b/modules/catkin_ws/src/VeloxProtocolLib/CMakeLists.txt
index 7fae0258..cde5ee08 100644
--- a/modules/catkin_ws/src/VeloxProtocolLib/CMakeLists.txt
+++ b/modules/catkin_ws/src/VeloxProtocolLib/CMakeLists.txt
@@ -149,7 +149,11 @@ endif()
 # Test
 #######
 add_executable(TerminalControl ${SOURCE_FILES} test/TerminalControl.cpp)
+add_executable(SpeedMeasure ${SOURCE_FILES} test/SpeedMeasure.cpp)
 
 # NetworkingLib
 target_include_directories(TerminalControl PUBLIC ${NetworkingLib_INCLUDE_DIRS})
 target_link_libraries(TerminalControl NetworkingLib)
+
+target_include_directories(SpeedMeasure PUBLIC ${NetworkingLib_INCLUDE_DIRS})
+target_link_libraries(SpeedMeasure NetworkingLib)
\ No newline at end of file
diff --git a/modules/catkin_ws/src/VeloxProtocolLib/test/SpeedMeasure.cpp b/modules/catkin_ws/src/VeloxProtocolLib/test/SpeedMeasure.cpp
new file mode 100644
index 00000000..a0e89053
--- /dev/null
+++ b/modules/catkin_ws/src/VeloxProtocolLib/test/SpeedMeasure.cpp
@@ -0,0 +1,35 @@
+//
+// Created by philipp on 10.05.18.
+//
+
+#include "../include/VeloxProtocolLib/Connection.h"
+
+int main(int argc, char ** argv)
+{
+    using namespace veloxProtocol;
+    using namespace std::chrono_literals;
+    networking::Networking net;
+    std::atomic<bool> running{true};
+    auto conn = Connection::create(net);
+    conn->open(
+        "/dev/ttySAC0",
+        []
+        {},
+        []
+        {});
+
+    auto timer = networking::time::Timer::create(net);
+    conn->setSteeringAngle(-4.0f);
+    conn->setSpeed(1.0f);
+    timer->startTimeout(
+        10s,
+        [&]
+        {
+            conn->setSpeed(0.0f);
+            running = false;
+        });
+
+    while (running);
+    sleep(1);
+    return 0;
+}
\ No newline at end of file
-- 
GitLab