commit 264c972100d47f96754672b98315db8b45a860b8 Author: James Pace Date: Mon Aug 4 08:24:42 2025 -0400 Init commit. diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..f4174fb --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.10.2) +project(logging_debug) + +find_package(catkin REQUIRED COMPONENTS + roscpp +) + +catkin_package( + CATKIN_DEPENDS roscpp +) + +include_directories( + ${catkin_INCLUDE_DIRS} +) + +add_executable(roslog src/roslog.cpp) +target_link_libraries(roslog ${catkin_LIBRARIES}) diff --git a/package.xml b/package.xml new file mode 100644 index 0000000..721131f --- /dev/null +++ b/package.xml @@ -0,0 +1,12 @@ + + + + logging_debug + 0.0.0 + TODO: Package description + jimmy + MPL-2.0 + + catkin + roscpp + diff --git a/src/roslog.cpp b/src/roslog.cpp new file mode 100644 index 0000000..8dac6f5 --- /dev/null +++ b/src/roslog.cpp @@ -0,0 +1,54 @@ +/* Copyright 2025 James Pace + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * This Source Code Form is "Incompatible With Secondary Licenses", as + * defined by the Mozilla Public License, v. 2.0. + */ + +#include +#include +#include + +#include "ros/ros.h" + +using namespace std::chrono_literals; + +class Publisher +{ + public: + Publisher(): + nh_{} + { + timer_ = nh_.createTimer(ros::Duration(0.1), [this](const ros::TimerEvent&) + { + double val = 0; + const auto start = std::chrono::steady_clock::now(); + for(int i = 0; i < 10000; i++) + { + val = val + 0.001*(1.0 - val); + ROS_INFO_STREAM("Val is " << val); + } + const auto end = std::chrono::steady_clock::now(); + + const std::chrono::duration diff = end - start; + ROS_INFO_STREAM("Time delta: " << diff.count()); + + std::exit(0); + }, true); + } + + private: + ros::NodeHandle nh_; + ros::Timer timer_; +}; + +int main(int argc, char * argv[]) +{ + ros::init(argc, argv, "publisher"); + auto node = Publisher(); + ros::spin(); + return 0; +}