|
| 1 | +[](https://opensource.org/licenses/Apache-2.0) |
| 2 | +--- |
1 | 3 | # ROS2 Publisher and Subscriber |
2 | 4 |
|
| 5 | +## Overview |
| 6 | + |
| 7 | +A Package built using ```colcon``` build as a part of ROS2 Tutorials. It contains the implementation of a Talker and a Listener node. |
| 8 | + |
| 9 | +## Contents |
| 10 | +. |
| 11 | +├── include |
| 12 | +│ └── beginner_tutorials |
| 13 | +| ├── publisher_function.hpp |
| 14 | +│ └── subscriber_function.hpp |
| 15 | +├── package.xml |
| 16 | +├── CMakeLists.txt |
| 17 | +├── README.md |
| 18 | +└── src |
| 19 | + ├── publisher_member_function.cpp |
| 20 | + └── subscriber_member_function.cpp |
| 21 | + |
| 22 | +## Instructions to Build the Package |
| 23 | +``` |
| 24 | +cd <path-to-ROS2-workspace>/ros2_ws/src |
| 25 | +git clone https://github.com/bharadwaj-chukkala/beginner_tutorials.git |
| 26 | +cd .. |
| 27 | +rosdep install -i --from-path src --rosdistro humble -y |
| 28 | +colcon build --packages-select beginner_tutorials |
| 29 | +``` |
| 30 | + |
| 31 | +## Run Instructions |
| 32 | + |
| 33 | +### Run the Publisher |
| 34 | +In a new terminal, navigate to your ROS2 workspace (```ros2_ws```) and source the setup files, |
| 35 | +``` |
| 36 | +cd <path-to-ROS2-workspace>/ros2_ws |
| 37 | +. install/setup.bash |
| 38 | +ros2 run beginner_tutorials talker |
| 39 | +``` |
| 40 | + |
| 41 | +### Run the Subscriber |
| 42 | +In another terminal, navigate to your ROS2 workspace (```ros2_ws```) and source the setup files, |
| 43 | +``` |
| 44 | +cd <path-to-ROS2-workspace>/ros2_ws |
| 45 | +. install/setup.bash |
| 46 | +ros2 run beginner_tutorials listener |
| 47 | +``` |
| 48 | + |
| 49 | +Enter ```Ctrl+c``` in each terminal to stop the nodes from spinning. |
| 50 | + |
| 51 | +## Results |
| 52 | + |
| 53 | +### cpplint |
| 54 | +Change to the root directory of the package, ```/beginner_tutorials```, and run: |
| 55 | +``` |
| 56 | +cpplint --filter=-build/c++11,+build/c++17,-build/namespaces,-build/include_order ./src/*.cpp ./include/beginner_tutorials/*.hpp > ./results/cpplint.txt |
| 57 | +``` |
| 58 | +The results of running ```cpplint``` can be found in ```/results/cpplint.txt```. |
| 59 | + |
| 60 | +### cppcheck |
| 61 | +Change to the root directory of the package, ```/beginner_tutorials```, and run: |
| 62 | +``` |
| 63 | +cppcheck --enable=all --std=c++17 ./src/*.cpp ./include/beginner_tutorials/*.hpp --suppress=missingIncludeSystem --suppress=unmatchedSuppression --suppress=unusedFunction --suppress=missingInclude --suppress=useInitializationList > results/cppcheck.txt |
| 64 | +``` |
| 65 | +The results of running ```cppcheck``` can be found in ```/results/cppcheck.txt```. |
0 commit comments