From 25fe0091e68b974028d6a62c600afb6b816013ba Mon Sep 17 00:00:00 2001 From: yul Date: Mon, 5 Feb 2024 06:24:36 +0100 Subject: [PATCH] . --- src/tutorial_pkg/launch/my_launch_file.launch | 13 +++++++++++++ src/tutorial_pkg/src/my_first_node.cpp | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/tutorial_pkg/launch/my_launch_file.launch b/src/tutorial_pkg/launch/my_launch_file.launch index b5cdd5d..9819592 100644 --- a/src/tutorial_pkg/launch/my_launch_file.launch +++ b/src/tutorial_pkg/launch/my_launch_file.launch @@ -1,5 +1,18 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/tutorial_pkg/src/my_first_node.cpp b/src/tutorial_pkg/src/my_first_node.cpp index 864288a..3aed9aa 100644 --- a/src/tutorial_pkg/src/my_first_node.cpp +++ b/src/tutorial_pkg/src/my_first_node.cpp @@ -2,6 +2,9 @@ #include #include #include +#include + +uint saved_imgs = 0; ros::Publisher brightness_pub; ros::ServiceClient client; @@ -26,6 +29,14 @@ void timerCallback(const ros::TimerEvent&) std_srvs::Empty srv; client.call(srv); + saved_imgs++; +} + +bool saved_img(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res) +{ + res.success = 1; + res.message = "Saved images: " + std::to_string(saved_imgs); + return true; } int main(int argc, char **argv) @@ -40,6 +51,7 @@ int main(int argc, char **argv) brightness_pub = n.advertise("brightness", 1); ros::Timer timer = n.createTimer(ros::Duration(timer_period_s), timerCallback); client = n.serviceClient("/image_saver/save"); + ros::ServiceServer service = n.advertiseService("image_counter", saved_img); ROS_INFO("Node started!"); ros::spin();