From 43b55aaa37c49700e2772d4e5174cefde19f2a93 Mon Sep 17 00:00:00 2001 From: Estefania Correa-Mendez Date: Wed, 16 Sep 2026 17:50:04 +0000 Subject: [PATCH] feat: add Estefania onboarding package --- .github/CODEOWNERS | 1 + src/estefania_pkg/CMakeLists.txt | 44 +++++++++++++++ src/estefania_pkg/README.md | 9 +++ src/estefania_pkg/launch/all.xml | 5 ++ src/estefania_pkg/package.xml | 21 +++++++ src/estefania_pkg/src/estefania_publisher.cpp | 45 +++++++++++++++ .../src/estefania_subscriber.cpp | 56 +++++++++++++++++++ src/onboarding/launch/all.xml | 2 + 8 files changed, 183 insertions(+) create mode 100644 src/estefania_pkg/CMakeLists.txt create mode 100644 src/estefania_pkg/README.md create mode 100644 src/estefania_pkg/launch/all.xml create mode 100644 src/estefania_pkg/package.xml create mode 100644 src/estefania_pkg/src/estefania_publisher.cpp create mode 100644 src/estefania_pkg/src/estefania_subscriber.cpp diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index bd452bd..bc764a1 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -10,6 +10,7 @@ src/oliver_pkg @GoldenGuy1000 src/james_pkg @jhaddixcodes src/ben_pkg @benvrao src/cole_pkg @cole-wilson +src/estefania_pkg @EstefaniaC-M .clang-format @ryden-handsaker Dockerfile @andy-sorge diff --git a/src/estefania_pkg/CMakeLists.txt b/src/estefania_pkg/CMakeLists.txt new file mode 100644 index 0000000..11940a9 --- /dev/null +++ b/src/estefania_pkg/CMakeLists.txt @@ -0,0 +1,44 @@ +cmake_minimum_required(VERSION 3.8) +project(estefania_pkg) + +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wall -Wextra -Wpedantic) +endif() + +# find dependencies +find_package(ament_cmake REQUIRED) +# uncomment the following section in order to fill in +# further dependencies manually. +# find_package( REQUIRED) + +find_package(onboarding_msgs REQUIRED) +find_package(rclcpp REQUIRED) +find_package(std_msgs REQUIRED) + +add_executable(estefania_publisher src/estefania_publisher.cpp) +add_executable(estefania_subscriber src/estefania_subscriber.cpp) + +ament_target_dependencies(estefania_publisher rclcpp std_msgs) +ament_target_dependencies(estefania_subscriber rclcpp onboarding_msgs std_msgs) +install(TARGETS + estefania_publisher + estefania_subscriber + DESTINATION lib/${PROJECT_NAME}) + +install(DIRECTORY + launch + DESTINATION share/${PROJECT_NAME}) + +if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + # the following line skips the linter which checks for copyrights + # comment the line when a copyright and license is added to all source files + set(ament_cmake_copyright_FOUND TRUE) + # the following line skips cpplint (only works in a git repo) + # comment the line when this package is in a git repo and when + # a copyright and license is added to all source files + set(ament_cmake_cpplint_FOUND TRUE) + ament_lint_auto_find_test_dependencies() +endif() + +ament_package() diff --git a/src/estefania_pkg/README.md b/src/estefania_pkg/README.md new file mode 100644 index 0000000..36ee8a0 --- /dev/null +++ b/src/estefania_pkg/README.md @@ -0,0 +1,9 @@ +# estefania_pkg + +This package contains a publisher and subscriber. + +The publisher publishes random `std_msgs/msg/Float32` values to the +`estefania_topic` topic at 0.5 Hz. + +The subscriber listens to `estefania_topic`, summarizes the received +value, and sends the summary to the `echo_string` service. \ No newline at end of file diff --git a/src/estefania_pkg/launch/all.xml b/src/estefania_pkg/launch/all.xml new file mode 100644 index 0000000..ece4e1c --- /dev/null +++ b/src/estefania_pkg/launch/all.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/estefania_pkg/package.xml b/src/estefania_pkg/package.xml new file mode 100644 index 0000000..85545b1 --- /dev/null +++ b/src/estefania_pkg/package.xml @@ -0,0 +1,21 @@ + + + + estefania_pkg + 0.0.0 + Publisher and subscriber for the Estefania onboarding task. + Estefania Correa-Mendez + MIT + + onboarding_msgs + rclcpp + std_msgs + + ament_cmake + ament_lint_auto + ament_lint_common + + + ament_cmake + + \ No newline at end of file diff --git a/src/estefania_pkg/src/estefania_publisher.cpp b/src/estefania_pkg/src/estefania_publisher.cpp new file mode 100644 index 0000000..f6687aa --- /dev/null +++ b/src/estefania_pkg/src/estefania_publisher.cpp @@ -0,0 +1,45 @@ +#include +#include +#include + +#include "rclcpp/rclcpp.hpp" +#include "std_msgs/msg/float32.hpp" + +using namespace std::chrono_literals; + +class EstefaniaPublisher : public rclcpp::Node { + public: + EstefaniaPublisher() : + Node("estefania_publisher"), generator_(std::random_device{}()), + distribution_(0.0f, 100.0f) { + publisher_ = this->create_publisher( + "estefania_topic", 10 + ); + + timer_ = this->create_wall_timer( + 2s, std::bind(&EstefaniaPublisher::publish_message, this) + ); + } + + private: + void publish_message() { + std_msgs::msg::Float32 message; + message.data = distribution_(generator_); + + publisher_->publish(message); + } + + rclcpp::Publisher::SharedPtr publisher_; + rclcpp::TimerBase::SharedPtr timer_; + + std::mt19937 generator_; + std::uniform_real_distribution distribution_; +}; + +int main(int argc, char* argv[]) { + rclcpp::init(argc, argv); + rclcpp::spin(std::make_shared()); + rclcpp::shutdown(); + + return 0; +} diff --git a/src/estefania_pkg/src/estefania_subscriber.cpp b/src/estefania_pkg/src/estefania_subscriber.cpp new file mode 100644 index 0000000..58a07aa --- /dev/null +++ b/src/estefania_pkg/src/estefania_subscriber.cpp @@ -0,0 +1,56 @@ +#include +#include +#include + +#include "onboarding_msgs/srv/echo_string.hpp" +#include "rclcpp/rclcpp.hpp" +#include "std_msgs/msg/float32.hpp" + +class EstefaniaSubscriber : public rclcpp::Node { + public: + EstefaniaSubscriber() : Node("estefania_subscriber") { + subscription_ = this->create_subscription( + "estefania_topic", 10, + std::bind( + &EstefaniaSubscriber::topic_callback, this, + std::placeholders::_1 + ) + ); + + client_ = this->create_client( + "echo_string" + ); + } + + private: + void topic_callback(const std_msgs::msg::Float32::SharedPtr message) { + std::string summary = + "Estefania received the value: " + std::to_string(message->data); + + if (!client_->wait_for_service(std::chrono::seconds(1))) { + RCLCPP_WARN(this->get_logger(), "Echo service is not available."); + return; + } + + auto request = + std::make_shared(); + + request->data = summary; + + client_->async_send_request(request); + } + + rclcpp::Subscription::SharedPtr subscription_; + + rclcpp::Client::SharedPtr client_; +}; + +int main(int argc, char* argv[]) { + rclcpp::init(argc, argv); + + rclcpp::spin(std::make_shared()); + + rclcpp::shutdown(); + + return 0; +} diff --git a/src/onboarding/launch/all.xml b/src/onboarding/launch/all.xml index 8c2efd7..0dd9c1c 100644 --- a/src/onboarding/launch/all.xml +++ b/src/onboarding/launch/all.xml @@ -10,4 +10,6 @@ + + \ No newline at end of file