diff --git a/modules/catkin_ws/src/PC/CMakeLists.txt b/modules/catkin_ws/src/PC/CMakeLists.txt index 5f14c3727f35f41489cb15ccb87347f44636c9f3..e93747f30b391b192e6a3c8b34413510a5fab3ac 100644 --- a/modules/catkin_ws/src/PC/CMakeLists.txt +++ b/modules/catkin_ws/src/PC/CMakeLists.txt @@ -1,9 +1,18 @@ cmake_minimum_required(VERSION 3.5.1) project(PC) +set(CMAKE_CXX_FLAGS "-pthread") + set(CMAKE_CXX_STANDARD 14) +set(LOCAL_INSTALL_DIR ${CMAKE_CURRENT_LIST_DIR}/../../install) + +set(CMAKE_PREFIX_PATH "${LOCAL_INSTALL_DIR}") + find_package(Boost REQUIRED COMPONENTS regex system) +find_package(NetworkingLib REQUIRED) +find_package(PlatoonProtocolLib REQUIRED) +find_package(PC2CarLib REQUIRED) set(SOURCE_FILES src/main.cpp @@ -13,3 +22,8 @@ set(SOURCE_FILES add_executable(PC ${SOURCE_FILES}) target_link_libraries(PC ${Boost_LIBRARIES}) + +target_include_directories(PC PUBLIC ${PC2CarLib_INCLUDE_DIRS}) +target_link_libraries(PC NetworkingLib) +target_link_libraries(PC PlatoonProtocolLib) +target_link_libraries(PC PC2CarLib) \ No newline at end of file diff --git a/modules/catkin_ws/src/PC/src/main.cpp b/modules/catkin_ws/src/PC/src/main.cpp index 3594c9a7b8e3ecc385ca834fe8df14ffc690aea2..c46bd101cb8839b84ad1de755df571f745b55a32 100644 --- a/modules/catkin_ws/src/PC/src/main.cpp +++ b/modules/catkin_ws/src/PC/src/main.cpp @@ -1,8 +1,24 @@ #include "../include/Logging.h" +#include "PC2CarLib/CommandSender.h" int main() { + networking::Networking net; pc::Logging logging{10207}; + pc2car::CommandSender commandSender{net, "127.0.0.1"}; + + std::thread commandThread{ + [&commandSender] + { + float speed = 0.0f; + while (true) + { + using namespace std::chrono_literals; + commandSender.setPlatoonSpeed(speed++); + std::this_thread::sleep_for(1s); + } + }}; + logging.start(); return 0; } \ No newline at end of file diff --git a/modules/catkin_ws/src/PlatoonProtocolLib/include/PlatoonProtocolLib/Protocol.h b/modules/catkin_ws/src/PlatoonProtocolLib/include/PlatoonProtocolLib/Protocol.h index 5a72146142b1c66771251cdb1aec2cbcbf702074..3a9478b0bc8af0909a0dab5806456ff71d16704a 100644 --- a/modules/catkin_ws/src/PlatoonProtocolLib/include/PlatoonProtocolLib/Protocol.h +++ b/modules/catkin_ws/src/PlatoonProtocolLib/include/PlatoonProtocolLib/Protocol.h @@ -22,6 +22,10 @@ using InnerPlatoonDistance = float; struct PlatoonConfig { + PlatoonConfig(PlatoonSpeed platoonSpeed, InnerPlatoonDistance innerPlatoonDistance) + : platoonSpeed(platoonSpeed), innerPlatoonDistance(innerPlatoonDistance) + {} + PlatoonSpeed platoonSpeed; InnerPlatoonDistance innerPlatoonDistance; };