From 5292b34f3add90a43b564f4e29e3632400fcc4ac Mon Sep 17 00:00:00 2001 From: Andrew Ealovega Date: Tue, 3 Oct 2023 23:58:14 -0400 Subject: [PATCH] Update from template --- CMakeLists.txt | 14 +++++++------- README.md | 16 ++++++++-------- .../ObjTrackerNode_node.hpp} | 4 ++-- package.xml | 2 +- src/{TODO_NODE_NAME.cpp => ObjTrackerNode.cpp} | 4 ++-- ...ODE_NAME_node.cpp => ObjTrackerNode_node.cpp} | 8 ++++---- tests/unit.cpp | 4 ++-- 7 files changed, 26 insertions(+), 26 deletions(-) rename include/{TODO_PACKAGE_NAME/TODO_NODE_NAME_node.hpp => obj_tracker/ObjTrackerNode_node.hpp} (75%) rename src/{TODO_NODE_NAME.cpp => ObjTrackerNode.cpp} (72%) rename src/{TODO_NODE_NAME_node.cpp => ObjTrackerNode_node.cpp} (68%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 39e95cc..77dbc59 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.8) -project(TODO_PACKAGE_NAME) +project(obj_tracker) include(FetchContent) if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") @@ -18,11 +18,11 @@ find_package(cv_bridge REQUIRED) find_package(OpenCV 4.2.0 REQUIRED) # Add source for node executable (link non-ros dependencies here) -add_executable(TODO_PACKAGE_NAME src/TODO_NODE_NAME.cpp src/TODO_NODE_NAME_node.cpp) -target_include_directories(TODO_PACKAGE_NAME PUBLIC +add_executable(obj_tracker src/ObjTrackerNode.cpp src/ObjTrackerNode_node.cpp) +target_include_directories(obj_tracker PUBLIC $ $) -target_compile_features(TODO_PACKAGE_NAME PUBLIC c_std_99 cxx_std_17) # Require C99 and C++17 +target_compile_features(obj_tracker PUBLIC c_std_99 cxx_std_17) # Require C99 and C++17 # Make ros deps a variable so they get linked to tests as well set(dependencies @@ -38,11 +38,11 @@ set(dependencies # Link ros dependencies ament_target_dependencies( - TODO_PACKAGE_NAME + obj_tracker ${dependencies} ) -install(TARGETS TODO_PACKAGE_NAME +install(TARGETS obj_tracker DESTINATION lib/${PROJECT_NAME}) # Uncomment below to make launch files available if created @@ -62,7 +62,7 @@ if (BUILD_TESTING) ament_add_gtest(${PROJECT_NAME}-test tests/unit.cpp # Remember to add node source files - src/TODO_NODE_NAME_node.cpp + src/ObjTrackerNode_node.cpp ) ament_target_dependencies(${PROJECT_NAME}-test ${dependencies}) target_include_directories(${PROJECT_NAME}-test PUBLIC diff --git a/README.md b/README.md index 3369c0a..e169803 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ An opinionated ROS2 C++ node template, optimised for ISC. 2. `rosdep install --from-paths . --ignore-src -r -y` to install deps 3. `colcon build` to make sure the repo builds before you mess with it 4. Replace the following in both file names and code exactly and consistently. - 1. TODO_PACKAGE_NAME: Replace with the package name. Use snake case. Ex. `data_logger` - 2. TODO_NODE_NAME: Replace with the node name. Use Pascal case. Ex. `DataLogger` + 1. obj_tracker: Replace with the package name. Use snake case. Ex. `data_logger` + 2. ObjTrackerNode: Replace with the node name. Use Pascal case. Ex. `DataLogger` 5. `colcon build` again. If it builds, you are done 6. Rename outer folder 7. Review the optional dependencies, and remove what you do not need @@ -29,19 +29,19 @@ These are marked with TODO_EXTRA. ``` . ├── include -│   └── TODO_PACKAGE_NAME -│   └── TODO_NODE_NAME_node.hpp +│   └── obj_tracker +│   └── ObjTrackerNode_node.hpp ├── package.xml ├── README.md ├── src -│   ├── TODO_NODE_NAME.cpp -│   └── TODO_NODE_NAME_node.cpp +│   ├── ObjTrackerNode.cpp +│   └── ObjTrackerNode_node.cpp └── tests └── unit.cpp ``` -TODO_NODE_NAME_node: Source files for the ROS2 node object itself, and only itself +ObjTrackerNode_node: Source files for the ROS2 node object itself, and only itself -TODO_NODE_NAME.cpp: Source for the main function of the node, and only the main function +ObjTrackerNode.cpp: Source for the main function of the node, and only the main function tests/unit.cpp: Example file for unit tests. This is linked to the node and ros, so both can be used \ No newline at end of file diff --git a/include/TODO_PACKAGE_NAME/TODO_NODE_NAME_node.hpp b/include/obj_tracker/ObjTrackerNode_node.hpp similarity index 75% rename from include/TODO_PACKAGE_NAME/TODO_NODE_NAME_node.hpp rename to include/obj_tracker/ObjTrackerNode_node.hpp index d8fe4d5..e91da38 100644 --- a/include/TODO_PACKAGE_NAME/TODO_NODE_NAME_node.hpp +++ b/include/obj_tracker/ObjTrackerNode_node.hpp @@ -3,14 +3,14 @@ #include "rclcpp/rclcpp.hpp" #include "std_msgs/msg/string.hpp" -class TODO_NODE_NAME : public rclcpp::Node { +class ObjTrackerNode : public rclcpp::Node { private: rclcpp::Publisher::SharedPtr pub; rclcpp::Subscription::SharedPtr sub; public: - TODO_NODE_NAME(const rclcpp::NodeOptions& options); + ObjTrackerNode(const rclcpp::NodeOptions& options); /// subscriber callback void sub_cb(std_msgs::msg::String::SharedPtr msg); diff --git a/package.xml b/package.xml index 62544a7..7a85a04 100644 --- a/package.xml +++ b/package.xml @@ -1,7 +1,7 @@ - TODO_PACKAGE_NAME + obj_tracker 0.1.0 A node template Andrew Ealovega diff --git a/src/TODO_NODE_NAME.cpp b/src/ObjTrackerNode.cpp similarity index 72% rename from src/TODO_NODE_NAME.cpp rename to src/ObjTrackerNode.cpp index 9ec0141..6b60c28 100644 --- a/src/TODO_NODE_NAME.cpp +++ b/src/ObjTrackerNode.cpp @@ -1,4 +1,4 @@ -#include "TODO_PACKAGE_NAME/TODO_NODE_NAME_node.hpp" +#include "obj_tracker/ObjTrackerNode_node.hpp" int main(int argc, char** argv) { // Setup runtime @@ -7,7 +7,7 @@ int main(int argc, char** argv) { rclcpp::NodeOptions options; // Add nodes to executor - auto node = std::make_shared(options); + auto node = std::make_shared(options); exec.add_node(node); // Run diff --git a/src/TODO_NODE_NAME_node.cpp b/src/ObjTrackerNode_node.cpp similarity index 68% rename from src/TODO_NODE_NAME_node.cpp rename to src/ObjTrackerNode_node.cpp index 3f7bc6e..843da1f 100644 --- a/src/TODO_NODE_NAME_node.cpp +++ b/src/ObjTrackerNode_node.cpp @@ -1,15 +1,15 @@ -#include "TODO_PACKAGE_NAME/TODO_NODE_NAME_node.hpp" +#include "obj_tracker/ObjTrackerNode_node.hpp" // For _1 using namespace std::placeholders; -TODO_NODE_NAME::TODO_NODE_NAME(const rclcpp::NodeOptions& options) : Node("TODO_NODE_NAME", options) { +ObjTrackerNode::ObjTrackerNode(const rclcpp::NodeOptions& options) : Node("ObjTrackerNode", options) { // Parameters float x = this->declare_parameter("foo", -10.0); // Pub Sub this->sub = - this->create_subscription("/str", 1, std::bind(&TODO_NODE_NAME::sub_cb, this, _1)); + this->create_subscription("/str", 1, std::bind(&ObjTrackerNode::sub_cb, this, _1)); this->pub = this->create_publisher("/run_folder", 1); // Log a sample log @@ -21,7 +21,7 @@ TODO_NODE_NAME::TODO_NODE_NAME(const rclcpp::NodeOptions& options) : Node("TODO_ pub->publish(msg); } -void TODO_NODE_NAME::sub_cb(const std_msgs::msg::String::SharedPtr msg) { +void ObjTrackerNode::sub_cb(const std_msgs::msg::String::SharedPtr msg) { // Echo message this->pub->publish(*msg); } diff --git a/tests/unit.cpp b/tests/unit.cpp index e28e06d..8e6981a 100644 --- a/tests/unit.cpp +++ b/tests/unit.cpp @@ -2,9 +2,9 @@ #include -#include "TODO_PACKAGE_NAME/TODO_NODE_NAME_node.hpp" +#include "obj_tracker/ObjTrackerNode_node.hpp" -TEST(TODO_NODE_NAME, Test1) {} +TEST(ObjTrackerNode, Test1) {} int main(int argc, char** argv) { rclcpp::init(0, nullptr);