<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Atul Chaudhari on Medium]]></title>
        <description><![CDATA[Stories by Atul Chaudhari on Medium]]></description>
        <link>https://medium.com/@chaudhariatul29?source=rss-8bdeab63e084------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*RzIODvXKe61yFmcMfz_2Iw.jpeg</url>
            <title>Stories by Atul Chaudhari on Medium</title>
            <link>https://medium.com/@chaudhariatul29?source=rss-8bdeab63e084------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 00:08:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@chaudhariatul29/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[ROS2: Cross Compiling ROS2 Nodes]]></title>
            <link>https://medium.com/@chaudhariatul29/ros2-cross-compiling-ros2-nodes-94387599ee68?source=rss-8bdeab63e084------2</link>
            <guid isPermaLink="false">https://medium.com/p/94387599ee68</guid>
            <dc:creator><![CDATA[Atul Chaudhari]]></dc:creator>
            <pubDate>Wed, 01 Mar 2023 04:35:45 GMT</pubDate>
            <atom:updated>2023-03-01T04:35:45.673Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog we are going to talk about how to cross compile ROS2 nodes for the raspberry pi. We are not talking about cross compiling ROS2 source for installation on different platforms(Raspberry-pi). It’s more about developing ROS2 applications for multiple platforms using cross compilation.</p><p><a href="https://roboticsbackend.com/install-ros2-on-raspberry-pi/">To install ROS2 on raspberry pi.</a></p><p>What is cross compilation?</p><p>A cross compiler is a compiler capable of creating executable code for a platform other than the one on which the compiler is running. For example, a cross compiler executes on machine X and produces machine code for machine Y. Please read the<a href="https://www.geeksforgeeks.org/what-is-cross-compiler/"> cross compiler</a> for more info.</p><p>Why is cross compilation needed?</p><p>The host environment(developing env) and Target environment can be different. In this case our host environment is laptop/desktop(Ubuntu) on which we will write ROS2 nodes and will test on the host itself, but to work it on target(Raspberry- pi(Ubuntu)) we have to cross compile it. The architecture is different for host (X86_64 architecture) and Raspberry-pi(Arm based). The instruction set for the both environments is different. Usually most laptops/desktops are Intel X86_64 CISC based and Raspberry-pi is ARM RISC based architecture.</p><p>As we all know we can write ROS2 nodes using C++ or Python, if you’re writing all ROS2 nodes in Python then cross compilation is not needed as Python is scripting language and it does require compilation. But for C++ we need cross compilation as it creates object code after compilation.</p><p>cross compilation steps for Raspberry pi(ARM arch) on host machine(ubuntu 20.04)</p><p>1. Download dependency package providing the default GNU C++ and C cross-compiler for the arm64 architecture</p><p>- sudo apt-get install g++-aarch64-linux-gnu</p><p>- sudo apt-get -y install gcc-aarch64-linux-gnu</p><p>it will install in /usr/aarch64-linux-gnu, you need to copy some libraries into /lib</p><p>- sudo cp /usr/aarch64-linux-gnu/lib/ld-linux-aarch64.so.1 /lib</p><p>- sudo cp /usr/aarch64-linux-gnu/lib/libc.so.6 /lib</p><p>2. open a new terminal and export variable to set the environment(target environment)</p><p>- export TARGET_ARCH=aarch64</p><p>- export TARGET_TRIPLE=aarch64-linux-gnu</p><p>- export CC=/usr/bin/$TARGET_TRIPLE-gcc</p><p>- export CXX=/usr/bin/$TARGET_TRIPLE-g++</p><p>3. Once the environment is set, compile ros2 nodes using colcon build.</p><p>you can check the binaries type using `file command`.</p><p>e.g.</p><p>`file install/ros2_spikes/lib/ros2_spikes/my_node` — → it will print the type(for which architecture it is compiled) of binaries.</p><p>output — -&gt; install/ros2_spikes/lib/ros2_spikes/my_node: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, BuildID[sha1]=584aaa27f6be25a45c08d06b42dec0ac9adeccf5, for GNU/Linux 3.7.0, not stripped</p><p>Note: for the ros2 python nodes cross compilation is not needed, we can directly compile ros2 nodes on host and can directly transfer binaries on target it will work.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94387599ee68" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ROS2: How to handle multiple callbacks In Parallel(Concurrently).]]></title>
            <link>https://medium.com/@chaudhariatul29/ros2-how-to-handle-multiple-callbacks-in-parallel-concurrently-c283d3bdd5e6?source=rss-8bdeab63e084------2</link>
            <guid isPermaLink="false">https://medium.com/p/c283d3bdd5e6</guid>
            <dc:creator><![CDATA[Atul Chaudhari]]></dc:creator>
            <pubDate>Mon, 12 Sep 2022 11:26:59 GMT</pubDate>
            <atom:updated>2022-09-21T10:46:04.653Z</atom:updated>
            <content:encoded><![CDATA[<p>In this tutorial we will see how to execute multiple callbacks on each separate thread. For that</p><p>We are using <a href="https://docs.ros.org/en/foxy/How-To-Guides/Using-callback-groups.html"><strong>ROS2 callback groups</strong></a> and <a href="https://docs.ros.org/en/foxy/Concepts/About-Executors.html"><strong>ROS2 Executors</strong></a> .</p><p>Here we are going to demonstrate for <strong>Rclpy</strong>.</p><h4><strong>Basics of executors and callback groups:</strong></h4><h4><strong>Executors:</strong></h4><p>Rclpy offers two executors:</p><ul><li><strong>Single Threaded Executor:</strong></li></ul><p>Single Threaded Executor is quite straightforward. It executes callbacks in a single thread, one at a time, and thus the previous callback must always finish before a new one can begin execution.</p><ul><li><strong>Multi-Threaded Executor:</strong></li></ul><p>Multi-Threaded Executor, on the other hand, is capable of executing several callbacks simultaneously.</p><h4><strong>Callback Groups:</strong></h4><p>Rclpy offers two types of callback groups:</p><ul><li><strong>Mutually Exclusive Callback Group:</strong></li></ul><p>Mutually Exclusive Callback Group allows the executor to execute only one of its callbacks simultaneously, essentially making it as if the callbacks in the group were executed by a Single Threaded Executor. Thus, it is a good choice to put any callbacks accessing critical and potentially non-thread-safe resources in the same Mutually Exclusive Callback Group.</p><ul><li><strong>Reentrant Callback Group:</strong></li></ul><p>Reentrant Callback Group allows the executor to schedule and execute the group’s callbacks in any way the executor sees fit, without restrictions. This means that, in addition to different callbacks being run simultaneously, the executor can also execute different instances of the same callback simultaneously. An example case of this would be if the execution of a timer callback takes longer than the timer’s firing period(although that particular case should be avoided at all costs in Rclpy, but that’s another story).</p><h4><strong>Example:</strong></h4><p>In this example there are two callbacks and one callback is blocking as it depends on other callback data to complete its execution. So if we do not use Multi-Threaded Executor and Reentrant Callback Group then it would block execution forever.</p><p>Please look into the following pseudo code to understand it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*aQy5MaW94CmqtLXilJSRrQ.png" /><figcaption><strong>Publisher-Subscriber without callback group</strong></figcaption></figure><p>Here we are not using any callback group.Default callback group is <strong>Mutually Exclusive Callback Group </strong>for the both subscribers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/342/1*jY_qQwohBMJk0ArBWa2AeA.png" /><figcaption><strong>main function without Multi-Threaded executor</strong></figcaption></figure><p>Here also we are not spinning our node on <strong>Multi-Threaded Executor. </strong>Default executor is <strong>Single Threaded Executor.</strong></p><p>As you can see in above pseudo code, I am trying to move my bot to a specific position . For that I am continuously taking the current pose from <strong>‘/Current_Pos_Pub’ topic </strong>and on <strong>On_Lidar_Info(Msg)( ) callback </strong>I am moving my bot.</p><p>In above pseudo code in<strong> def Move_Bot(), </strong>in the while loop we are publishing angular and linear velocity depending on the condition. But once the program enters into the while loop, it will block the current thread because of that <strong>current_pose will never be updated </strong>and it will be in a loop forever.</p><p>To avoid this deadlock, we can use <strong>Multi-Threaded Executor and Single Threaded Executor.</strong></p><p>In the below example, the deadlock condition will never occur as both <strong>on_current_pose() </strong>and <strong>on_lidar_info() </strong>will be executed concurrently. To execute Callback concurrently we created a <strong>Multi-Threaded Executor </strong>and spin our node on it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*VqueIYosL9fGogETn-8mmA.png" /><figcaption><strong>Callbacks using callback group and also use Multi-Threaded executor</strong></figcaption></figure><p>So from above blog and example you can get clear idea about how and when to use <strong>Executors</strong> and <strong>Callback Groups.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c283d3bdd5e6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>