<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: naguballa77</title>
    <description>The latest articles on DEV Community by naguballa77 (@naguballa77).</description>
    <link>https://dev.to/naguballa77</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3529456%2F4e0180dc-a003-4536-a8a6-b22ae256c997.png</url>
      <title>DEV Community: naguballa77</title>
      <link>https://dev.to/naguballa77</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/naguballa77"/>
    <language>en</language>
    <item>
      <title>ROS2 Publisher Node.</title>
      <dc:creator>naguballa77</dc:creator>
      <pubDate>Fri, 31 Oct 2025 18:56:37 +0000</pubDate>
      <link>https://dev.to/naguballa77/ros2-publisher-node-4758</link>
      <guid>https://dev.to/naguballa77/ros2-publisher-node-4758</guid>
      <description>&lt;p&gt;Hey everyone 👋&lt;br&gt;
In my previous blog, I shared how I started exploring ROS2 Humble using Turtlesim.&lt;br&gt;
Now, I’ve moved one step ahead — by creating my own C++ node that  &lt;strong&gt;publishes data inside ROS2.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This post will walk you through everything I did — step by step — so you can do the same on your system.&lt;/p&gt;

&lt;p&gt;⚙️ Step 1: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Creating a New Package&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;
Inside your workspace:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd ~/ros2_ws/src
ros2 pkg create --build-type ament_cmake pkg_2

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;What this does:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creates a folder named pkg_2&lt;/li&gt;
&lt;li&gt;Generates the necessary files: CMakeLists.txt, package.xml, include/, and src/&lt;/li&gt;
&lt;li&gt;Sets up a C++ ROS2 package ready for your node&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Your structure should look like:&lt;br&gt;
&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pkg_2/
├── CMakeLists.txt
├── include/pkg_2/
├── package.xml
└── src/

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🧩 Step 2: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Writing the Node&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;
Create a file:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd pkg_2/src
nano my_node.cpp

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This node doesn’t publish yet — but it’s alive and running, ready to communicate.&lt;br&gt;
📄 Step 3: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Editing &lt;/p&gt;

&lt;p&gt;CMakeLists.txt&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This tells ROS2 how to compile your C++ node and link it with the rclcpp library&lt;br&gt;
📦 Step 4:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Updating package.xml&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Open:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nano ../package.xml

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;And add your dependency to xml file:&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;depend&amp;gt;rclcpp&amp;lt;/depend&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🏗️ Step 5: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Building the Package&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Go back to your workspace:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd ~/ros2_ws
colcon build
source install/setup.bash

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;colcon&lt;/strong&gt; is the build tool front-end. It discovers packages in src/, figures out build order from package manifests, and runs the configured build tool (eg. ament_cmake) for each package. Results go into build/, install/, and log/.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Discovery
&lt;/h4&gt;

&lt;p&gt;: colcon scans src/ for packages (reads package.xml).&lt;br&gt;
▶️ Step 6: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Running the Node&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Run it with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ros2 run pkg_2 my_node

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[INFO] [my_cpp_node]: Hello guys this is nagu !

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🎉 Congratulations — you’ve just created your first C++ ROS2 node!&lt;/p&gt;




&lt;h4&gt;
  
  
  Typical errors you might encounter and what they mean
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Package &lt;code&gt;'pkg_2'&lt;/code&gt; not found: &lt;br&gt;
You didn’t &lt;code&gt;source install/setup.bash&lt;/code&gt;of your workspace (or you built under a different overlay).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Linker errors (undefined references):&lt;br&gt;
  you forgot to &lt;code&gt;ament_target_dependencies(... rclcpp)&lt;/code&gt;or &lt;code&gt;find_package(rclcpp).&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Runtime errors about DDS:&lt;br&gt;
&lt;code&gt;rclcpp::init&lt;/code&gt;can fail if the rmw implementation is missing or environment variables are wrong. Also firewall settings can block DDS discovery.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;It appears that the &lt;code&gt;colcon&lt;/code&gt; command is not currently installed on your system. This tool is required to build ROS2 workspaces. You may install it using the following commands:&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt update
sudo apt install python3-colcon-common-extensions -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;💬 What’s Next?&lt;/p&gt;

&lt;p&gt;In my next blog, I’ll extend this node to publish messages at regular intervals and create a subscriber node to receive them — this is where true ROS2 communication begins.&lt;/p&gt;

&lt;p&gt;Stay tuned 🚀&lt;br&gt;
Until then, keep experimenting and exploring the power of ROS2!&lt;/p&gt;


&lt;h4&gt;
  
  
  🧩 Bonus Tip:
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;To see all running nodes:&lt;br&gt;
&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ros2 node list

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;To check logs:&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ros2 topic echo /rosout

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🪶 &amp;gt;Written by NARASIMHA ALIAS Nagu&lt;br&gt;
💡 "Don't prove, just improve."&lt;br&gt;
&lt;code&gt;follow me for more knowledge&lt;/code&gt;&lt;/p&gt;

</description>
      <category>ros</category>
      <category>ros2</category>
      <category>pubsub</category>
      <category>node</category>
    </item>
    <item>
      <title>humble turtlesim</title>
      <dc:creator>naguballa77</dc:creator>
      <pubDate>Mon, 27 Oct 2025 07:40:35 +0000</pubDate>
      <link>https://dev.to/naguballa77/humble-turtlesim-4916</link>
      <guid>https://dev.to/naguballa77/humble-turtlesim-4916</guid>
      <description>&lt;h2&gt;
  
  
  ros2 &lt;strong&gt;turtlesim&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;the humble turtlesim is a beginer level simulation tool &lt;/p&gt;

&lt;p&gt;Hey everyone 👋 I’m Nagu, and this is my first blog post on the DEV Community!&lt;br&gt;
In this post, we’ll explore Turtlesim, a fun and simple simulator in ROS 2 (Robot Operating System 2) — perfect for beginners who want to start learning robotics and ROS commands.&lt;/p&gt;

&lt;p&gt;🚀 What is ROS 2 Humble?&lt;/p&gt;

&lt;p&gt;ROS 2 Humble Hawksbill is a popular Long-Term Support (LTS) version of ROS 2.&lt;br&gt;
It’s widely used for building and simulating robots — from simple mobile bots to advanced AI-driven systems.&lt;/p&gt;

&lt;p&gt;🐢 What is Turtlesim?&lt;/p&gt;

&lt;p&gt;Turtlesim is a lightweight simulator that shows a small turtle in a 2D world.&lt;br&gt;
It’s often the first step to understanding ROS concepts such as:&lt;/p&gt;

&lt;p&gt;Nodes 🧩 (independent programs)&lt;/p&gt;

&lt;p&gt;Topics 🗣️ (communication channels)&lt;/p&gt;

&lt;p&gt;Services ⚙️ (request/response system)&lt;/p&gt;

&lt;p&gt;Parameters ⚡ (settings and configurations)&lt;/p&gt;

&lt;p&gt;⚙️ Step 1: Install ROS 2 Humble&lt;/p&gt;

&lt;p&gt;If you haven’t installed ROS 2 yet, open your terminal and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt update &amp;amp;&amp;amp; sudo apt upgrade -y
sudo apt install ros-humble-desktop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then source it:&lt;/p&gt;

&lt;p&gt;source&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/opt/ros/humble/setup.bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(Tip: Add this line to your .bashrc so it auto-loads every time you open a terminal)&lt;/p&gt;

&lt;p&gt;🧩 Step 2: Install Turtlesim&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install ros-humble-turtlesim
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check if it’s installed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ros2 pkg list | grep turtlesim
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;note :sometimes ros2 command not found in terminal &lt;br&gt;
in that case it better to switch to root terminal by the below command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo su
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🖥️ Step 3: Run Turtlesim&lt;/p&gt;

&lt;p&gt;Launch the turtlesim window:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ros2 run turtlesim turtlesim_node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A blue window will appear with a turtle in the center 🐢💙&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft7byxf7tgwdlpmmczzee.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft7byxf7tgwdlpmmczzee.png" alt=" " width="502" height="539"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🎮 Step 4: Control the Turtle&lt;/p&gt;

&lt;p&gt;Open another terminal and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ros2 run turtlesim turtle_teleop_key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;after clicks of some keys&lt;/strong&gt;&lt;br&gt;
⬆️➡️⬇️⬅️&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6hs82quk2c34fnxwiwyi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6hs82quk2c34fnxwiwyi.png" alt=" " width="502" height="539"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now use your arrow keys to move the turtle around.&lt;br&gt;
Congrats — you just published your first commands in ROS 2!&lt;/p&gt;

&lt;p&gt;🧠 Step 5: Explore Basic Commands&lt;/p&gt;

&lt;p&gt;List all active topics:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ros2 topic list&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;See messages being published: while you are controling the turtle by arrow keys&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ros2 topic echo /turtle1/cmd_vel&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;---
linear:
  x: 0.0
  y: 0.0
  z: 0.0
angular:
  x: 0.0
  y: 0.0
  z: -2.0
---
linear:
  x: 0.0
  y: 0.0
  z: 0.0
angular:
  x: 0.0
  y: 0.0
  z: 2.0
---

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;WHEN YOU TOUCH THE EDGE OF THE WINDOW it publish to the &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;turtlesim_node &lt;br&gt;
terminal&lt;br&gt;
&lt;code&gt;[WARN] [1761550426.649414936] [turtlesim]: Oh no! I hit the wall! (Clamping from [x=11.120421, y=4.634281])&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Clear the screen:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ros2 service call /clear std_srvs/srv/Empty
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Change the background color:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ros2 param set /turtlesim background_r 200
ros2 param set /turtlesim background_g 100
ros2 param set /turtlesim background_b 150
ros2 service call /clear std_srvs/srv/Empty
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💡 What You Learned&lt;/p&gt;

&lt;p&gt;✅ How to install and run ROS 2 Humble&lt;br&gt;
✅ How to launch and control Turtlesim&lt;br&gt;
✅ How to explore topics, services, and parameters&lt;br&gt;
&lt;a href="https://docs.ros.org/en/humble/Tutorials/Beginner-CLI-Tools/Introducing-Turtlesim/Introducing-Turtlesim.html" rel="noopener noreferrer"&gt;the official website for ros &lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is just the beginning of your ROS 2 journey — next, we’ll write a Python node to move the turtle automatically!&lt;/p&gt;

&lt;p&gt;✍️ Final Words&lt;/p&gt;

&lt;p&gt;Thanks for reading!&lt;br&gt;
If you enjoyed this post or found it helpful, leave a ❤️ and follow me for more tutorials on ROS 2, Ubuntu, and Ethical Hacking.&lt;br&gt;
and since it is my first ever blog please support me for more info &lt;/p&gt;

&lt;p&gt;“Don’t prove, just improve.” — Nagu&lt;/p&gt;

&lt;p&gt;Would you like me to write your next post script — the one about controlling Turtlesim using Python code &lt;br&gt;
&lt;strong&gt;see you soon guys&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>ros2</category>
      <category>turtlesim</category>
      <category>humble</category>
    </item>
  </channel>
</rss>
