Skip to content

Commit

Permalink
#9 update CMakeLists and basic structure
Browse files Browse the repository at this point in the history
  • Loading branch information
dongdongO committed May 6, 2024
1 parent 3dce46c commit 9b75e2a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 27 deletions.
38 changes: 18 additions & 20 deletions control_ws/src/stanley/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
cmake_minimum_required(VERSION 3.5)
project(stanley)

# Default to C99
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()

# Default to C++20
# 기본 C++20 설정
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 20)
endif()
Expand All @@ -15,7 +10,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
# ROS 2 패키지 의존성 찾기
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(nav_msgs REQUIRED)
Expand All @@ -24,21 +19,20 @@ find_package(tf2 REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)
find_package(example_interfaces REQUIRED)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# uncomment the line when a copyright and license is not present in all source files
#set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# uncomment the line when this package is not in a git repo
#set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()

ament_package()
include(ExternalProject)
# ExternalProject_Add을 사용하여 dbcppp 라이브러리 빌드
ExternalProject_Add(dbcppp_build
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include/stanley/dbcppp
BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include/stanley/dbcppp/build
CONFIGURE_COMMAND ${CMAKE_COMMAND} ..
BUILD_COMMAND ${MAKE}
INSTALL_COMMAND ""
TEST_COMMAND ""
)

include_directories(
include/${PROJECT_NAME}
include/stanley/dbcppp/include # dbcppp 헤더 파일 위치
)

add_executable(${PROJECT_NAME}
Expand All @@ -47,6 +41,8 @@ add_executable(${PROJECT_NAME}
src/controller/stanley.cpp
)

add_dependencies(${PROJECT_NAME} dbcppp_build) # dbcppp가 먼저 빌드되도록 의존성 추가

ament_target_dependencies(${PROJECT_NAME}
rclcpp
nav_msgs
Expand All @@ -59,4 +55,6 @@ ament_target_dependencies(${PROJECT_NAME}
install(TARGETS
${PROJECT_NAME}
DESTINATION lib/${PROJECT_NAME}
)
)

ament_package()
4 changes: 2 additions & 2 deletions control_ws/src/stanley/include/stanley/control.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include "controller/stanley.hpp"

#include "canprotocol/can_protocol.hpp"
// #include "canprotocol/can_protocol.hpp"

#include "rclcpp/rclcpp.hpp"
#include "nav_msgs/msg/path.hpp"
Expand All @@ -27,7 +27,7 @@ class Control : public rclcpp::Node {
private:
Stanley controller;

std::unique_ptr<CANReceiver> can_receiver;
// std::unique_ptr<CANReceiver> can_receiver;

std::vector<Path> refPoses;
Pose currPose;
Expand Down
6 changes: 3 additions & 3 deletions control_ws/src/stanley/include/stanley/dbcppp/tests/Config.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#define TEST_DBC "/home/dongdongo/seame/ECU-Control/test_cpp/dbcppp/tests/Test.dbc"
constexpr const char* TEST_FILES_PATH = "/home/dongdongo/seame/ECU-Control/test_cpp/dbcppp/tests/test_files";
#define TEST_DBC_WITH_SINGLE_COMMENTS "/home/dongdongo/seame/ECU-Control/test_cpp/dbcppp/tests/Test_single_comments.dbc"
#define TEST_DBC "/home/dongdongo/seame/Control/control_ws/src/stanley/include/stanley/dbcppp/tests/Test.dbc"
constexpr const char* TEST_FILES_PATH = "/home/dongdongo/seame/Control/control_ws/src/stanley/include/stanley/dbcppp/tests/test_files";
#define TEST_DBC_WITH_SINGLE_COMMENTS "/home/dongdongo/seame/Control/control_ws/src/stanley/include/stanley/dbcppp/tests/Test_single_comments.dbc"
4 changes: 2 additions & 2 deletions control_ws/src/stanley/src/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Control::Control() : rclcpp::Node("vehicle_control") {
this->controller = Stanley(k, ks);

// Initialize CAN receiver
this->can_receiver = std::make_unique<CANReceiver>("../example.dbc", "vcan0");
// this->can_receiver = std::make_unique<CANReceiver>("../example.dbc", "vcan0");

// Subscribe
path_subscription_ = this->create_subscription<nav_msgs::msg::Path>(
Expand Down Expand Up @@ -84,7 +84,7 @@ void Control::publisher_timer_callback() {

this->publish_drive(this->speedCommand, this->steerCommand);

this->can_receiver->receiveMessages();
// this->can_receiver->receiveMessages();
}

void Control::publish_drive(float speed, float steer) {
Expand Down

0 comments on commit 9b75e2a

Please sign in to comment.