File tree Expand file tree Collapse file tree 2 files changed +67
-0
lines changed
include/beginner_tutorials Expand file tree Collapse file tree 2 files changed +67
-0
lines changed Original file line number Diff line number Diff line change 1+ /* *
2+ * @file publisher_function.hpp
3+ * @author Bharadwaj Chukkala (bchukkal@umd.edu)
4+ * @brief Object Oriented publisher Implementation for ROS2
5+ * @version 0.1
6+ * @date 2022-11-10
7+ *
8+ * @copyright Copyright (c) 2022
9+ *
10+ */
11+
12+ #pragma once
13+
14+ #include < chrono>
15+ #include < memory>
16+ #include " rclcpp/rclcpp.hpp"
17+ #include " std_msgs/msg/string.hpp"
18+
19+ using namespace std ::chrono_literals;
20+
21+ /* *
22+ * @brief Class (subclass of Node) and uses std::bind() to register a member function as a callback from the timer.
23+ *
24+ */
25+ class MinimalPublisher : public rclcpp ::Node {
26+ public:
27+ MinimalPublisher ();
28+
29+ private:
30+ void timer_callback ();
31+ rclcpp::TimerBase::SharedPtr timer_;
32+ rclcpp::Publisher<std_msgs::msg::String>::SharedPtr publisher_;
33+ size_t count_;
34+ };
Original file line number Diff line number Diff line change 1+
2+ #pragma once
3+
4+ /* *
5+ * @file subscriber_function.hpp
6+ * @author Bharadwaj Chukkala (bchukkal@umd.edu)
7+ * @brief Object Oriented Subscriber Implementation for ROS2
8+ * @version 0.1
9+ * @date 2022-11-10
10+ *
11+ * @copyright Copyright (c) 2022
12+ *
13+ */
14+
15+
16+ #include < memory>
17+ #include " rclcpp/rclcpp.hpp"
18+ #include " std_msgs/msg/string.hpp"
19+
20+ using std::placeholders::_1;
21+
22+ /* *
23+ * @brief Class (subclass of Node) and registers a member function as a callback from the topic.
24+ *
25+ */
26+ class MinimalSubscriber : public rclcpp ::Node {
27+ public:
28+ MinimalSubscriber ();
29+
30+ private:
31+ void topic_callback (const std_msgs::msg::String::SharedPtr msg) const ;
32+ rclcpp::Subscription<std_msgs::msg::String>::SharedPtr subscription_;
33+ };
You can’t perform that action at this time.
0 commit comments