<?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 Baptiste Busch on Medium]]></title>
        <description><![CDATA[Stories by Baptiste Busch on Medium]]></description>
        <link>https://medium.com/@buschbapti?source=rss-82103366a2f5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*yp0cLGC8b4ZVW1LtiX8-vA.jpeg</url>
            <title>Stories by Baptiste Busch on Medium</title>
            <link>https://medium.com/@buschbapti?source=rss-82103366a2f5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 10:06:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@buschbapti/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[The foundation of a breakthrough in AI]]></title>
            <link>https://buschbapti.medium.com/the-foundation-of-a-breaktrough-in-ai-61d24d9e70a4?source=rss-82103366a2f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/61d24d9e70a4</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[foundation-models]]></category>
            <category><![CDATA[robotics]]></category>
            <dc:creator><![CDATA[Baptiste Busch]]></dc:creator>
            <pubDate>Fri, 28 Nov 2025 08:08:39 GMT</pubDate>
            <atom:updated>2025-11-28T08:41:20.647Z</atom:updated>
            <content:encoded><![CDATA[<p>Would you bring a child to do factory work? Of course not, right? Then why are we training AI models from scratch?</p><p>This provocative question highlights one of the biggest breakthrough of the past few years. We are not training AI models from scratch anymore. We are now using <strong>foundation models</strong>.</p><p>AI models are learning like a child. In fact, some research laboratories, such as the <a href="https://flowers.inria.fr/">Flowers AI &amp; CogSci Lab</a>, are exploring the mechanism behind child learning to replicate them in AI training. Untrained models need training and, like a child, this takes time. And sometimes supervision. Training AI models, in particular, requires a lot of time and a lot of data. And I mean a LOT.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ln-Q6YcySx3nPXp_Y-NJ4A.png" /><figcaption>Training an AI model by ChatGPT</figcaption></figure><p>Until now, deploying AI models in industry required first to train them on the specific task they are used for. For example, showing the model defects on parts such that it is able to distinguish a faulty part from a good one. But this training is tedious, takes time, and results are not guaranteed. This was, of course, inefficient, leading to limited deployment of AI, at least in the industrial context, specifically because public industrial data are limited or rather inexistant.</p><p>In 2021, the Center for Research on Foundation Models (CRFM) coined the term &quot;foundation model&quot; to mean:</p><blockquote>“any model that is trained on broad data (generally using self-supervision at scale) that can be adapted (e.g., fine-tuned) to a wide range of downstream tasks”</blockquote><p>In other words, an AI model that has already been trained on a lot of data and that can be adapted to your specific needs. And the best part, AI companies have already <a href="https://www.visualcapitalist.com/the-surging-cost-of-training-ai-models/">paid the cost</a> for training those models so that you don&#39;t have to. ChatGPT, a Large Language Model (LLM), is one of the most known foundation model.</p><p>This completely shifts the narrative. Instead of bringing a child to the factory, you are now hiring a very skilled worker. But the devil is in the details… As you see, the second part of the quote is quite important:</p><blockquote>“that can be adapted (e.g., fine-tuned) to a wide range of downstream tasks”</blockquote><p>A <em>skilled</em> worker doesn&#39;t necessarily mean a <em>specialised</em> worker… Like any new hires, you might need to train the model on your specific process. A concept known as <strong>fine-tuning</strong>.</p><p>What is so different than before, then, if you still have to train the model in the end? Well, the main principle is that fine-tuning requires far less data and computational power than training a model from scratch. A child needs to learn how to walk, a skilled worker already knows that… And, in fact, some foundation model are perfectly fine as is and work out of the box for certain tasks.</p><p>For industrial applications, and in particular robotics, this changes a lot of things. Some foundation models, like <a href="https://nvlabs.github.io/FoundationPose/">FoundationPose</a> from Nvidia are completely changing the way we do computer vision. Without any fine-tuning, also known as <a href="https://www.ibm.com/think/topics/zero-shot-learning">Zero-Shot Learning (ZSL)</a>, the model is able to give the position and orientation of any objects. And this, from a single RGB image. Some companies have spend thousands of dollars in training and bought very expensive camera systems to solve that exact problem. They can now, take a standard webcam and download an <a href="https://github.com/NVlabs/FoundationPose">open-source package</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*X09Sbr-L3QYjOQ2oUg25Ww.png" /><figcaption>Foundation pose gives the spatial position and orientation of any object from a single RGB camera</figcaption></figure><p>There are many different <a href="https://nairl.kr/robotics-foundation-models/">foundation models for robotics</a>, solving some very niche applications. Most of the hyped humanoid robot companies are training some kind of foundation model as the base layer of their system, like <a href="https://www.figure.ai/news/helix">Helix</a> by Figure or <a href="https://nvidianews.nvidia.com/news/nvidia-isaac-gr00t-n1-open-humanoid-robot-foundation-model-simulation-frameworks">GR00T</a> by Nvidia. Those foundation models are really the new Eldorado of AI as it is believed one of them will bring the &quot;ChatGPT moment&quot; to robotics.</p><p>The main drawback of those foundation models is that they are very hard and computationally heavy to train and even execute. This is the reason why ChatGPT is <a href="https://www.forbes.com/sites/johnkoetsier/2023/02/10/chatgpt-burns-millions-every-day-can-computer-scientists-make-ai-one-million-times-more-efficient/">burning millions every day</a>. For robotics, this will likely be even worse as spatial data or images are in a much richer and complex space than text. So, extracting meaningful representation will lead to even bigger models than LLMs. There is, of course, a case for <a href="https://hbr.org/2025/09/the-case-for-using-small-language-models">smaller models</a>. This trends is mostly <a href="https://www.thewirechina.com/2025/11/09/cheap-and-open-source-chinese-ai-models-are-taking-off/">led by China</a> which even makes those models open-source. Some researchers, like Yann Lecun who recently left Meta to create his own AI company, believes that <a href="https://blogs.nvidia.com/blog/what-is-a-transformer-model/">transformers</a>, the technology behind foundation models, will not be able to perform spatial reasoning and instead focus on <a href="https://eu.36kr.com/en/p/3559837738555779">world models</a> to achieve this milestone. For sure, the next few years or even months will be definitely interesting.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F4__gg83s_Do%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D4__gg83s_Do&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F4__gg83s_Do%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/b331455dd48777b7019593292fdf90d7/href">https://medium.com/media/b331455dd48777b7019593292fdf90d7/href</a></iframe><p>Anyway, what does those foundation models mean for industrial robotics? How do we deploy those models in production? This is where things get nasty and complicated. Because like most AI models, they still requires a GPU to run, also known as making inferences. And there aren&#39;t that many industrial computers that embark a GPU… <a href="https://press.siemens.com/global/en/pressrelease/siemens-drives-ai-adoption-industrial-operations-x-and-nvidia-accelerated-industrial">Siemens</a> &amp; <a href="https://apps.boschrexroth.com/microsites/ctrlx-automation/en/portfolio/ctrlx-ipc/">Bosch Rexroth</a> and a few robot manufacturers like <a href="https://www.universal-robots.com/products/ai-accelerator/">Universal Robot</a> or <a href="https://www.yaskawa.eu.com/header-meta/news-events/article/motoman-next---a-new-platform-from-yaskawa-for-intelligent-adaptive-robotic-automation-and-ai_n22113">Yaskawa</a> are starting to position themselves in this emerging market. But applications are still limited and technically challenging.</p><p>If you want the uncomplicated way, take a look at how we do it at AICA, within AICA Studio!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61d24d9e70a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The battle of loops]]></title>
            <link>https://buschbapti.medium.com/the-battle-of-loops-d426cab82f08?source=rss-82103366a2f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/d426cab82f08</guid>
            <category><![CDATA[robotics]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[sensors]]></category>
            <dc:creator><![CDATA[Baptiste Busch]]></dc:creator>
            <pubDate>Thu, 20 Nov 2025 07:37:48 GMT</pubDate>
            <atom:updated>2025-11-20T07:37:48.113Z</atom:updated>
            <content:encoded><![CDATA[<p>Open or closed-loop? Behind those terms lie very fundamental and different ways of controlling robots.</p><p>The year is 1980, Sam works as a courier in a big city. Sam has his whole delivery route planned on a paper map. No matter what, he will stick to the plan. Stuck on traffic or the road is blocked? Replanning is possible, but it is tedious.</p><p>The year is 2025, Bob is also a courier in a big city. Unlike Sam, Bob is using a GPS and receive continuous updates. The GPS tells him where to turn to avoid trafic and to reach his destination.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9aH2BgGNrv-qvZ7L4gTDEg.jpeg" /><figcaption>You are not lost when you have a map — photo by <a href="https://unsplash.com/@lureofadventure?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Ali Kazal</a></figcaption></figure><p>Are you still using a paper map today? Well, in fact, in industrial robotics we do! This is called open-loop control or offline programming.</p><p>Open-loop control has some serious advantages and there are reasons why we keep using it for most industrial robotics applications. It is reliable, it is fast, and more importantly it is easy to program. It simply consists in instructing the robot to move from a point A to a point B, programming the trajectory in advance such that it always follow the same path. And, more importantly, is very accurate at doing so.</p><p>Yet, like Sam who can get stuck in traffic, robot can also stop working if things are not exactly as planned. And that happen more than you might think.</p><p>According to the <a href="http://www.ijpe-online.com/"><strong><em>International Journal of Performability Engineering</em></strong></a>, the average reliability of a robot cell is 88%. In other words, 12% of the time, the cell is not working. Among the reasons for failure almost half of them are because of “<em>positional</em>” problems, i.e. some equipment in the cell is bumped, or the robot is “crashed” into another piece of equipment that is left in the way, etc… Meaning, along the robot path, something happened which shouldn&#39;t have. And that cost the industry billions of dollars every year. In fact, an average of <a href="https://patentpc.com/blog/robotics-maintenance-costs-operating-efficiency-data">$260,000 per downtime hour</a>.</p><p>Then where is the GPS for robots? Well, there is closed-loop control.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yA2BCFF6wshBoZD1BQ47Tg.png" /><figcaption>Gearbox assembly powered by <a href="https://www.aica.tech/schaeffler-case">AICA System</a></figcaption></figure><p>Closed-loop control consist in fusing sensor informations to alter the path of the robot during execution. This can be from using computer vision to detect parts, force sensors to carefully assemble them, and, of course AI models for understanding the environment. Closed-loop control is absolutely crucial in social environments or when interacting with humans. We are closed-loop systems after all... Yet, because the industry tries to remove uncertainty as much as possible, it never really took off in the industrial robotics context.</p><p>Yet, the advantages are rather obvious: less downtime, more flexibility in the production lines and the possibility of human-robot collaboration. Then why is it not generalised? Because it is complex. Sensors are noisy and their fusion is still a hard topic. But the most fundamental problem, the way we program robots is not made for closed-loop control…</p><p>Industrial robots are programmed with scripts. A script is like a cooking recipe or the itinerary on Sam&#39;s printed map. A set of instructions executed line by line. Obviously, scripting works very well for open-loop control where robots have to move from a point A to a point B, rince and repeat. Developing a closed-loop system from a set of scripts is possible, a lot of developers are doing so, but it is far from being practical. That&#39;s the reason why AICA developed <a href="https://www.aica.tech/product">AICA Studio</a>, a graphical interface to program closed-loop applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T7vGQM4Dup2JKVqp9tb7uA.png" /><figcaption><a href="https://www.aica.tech/product">AICA Studio</a>, a graphical interface and framework to program closed-loops for any industrial robots</figcaption></figure><p>Then, is the battle between open and closed-loop systems settled? Should we all move from using printed maps to GPS enabled robotic systems? Not so fast…</p><p>Industrial robotics is complex. And in some industry, where pieces are produced by thousands, millions or even billions of units per year, industries were each operations should be performed in less than 10 seconds, open-loop is by far the best way to go. For the rest, you should think about it. And consider <a href="https://www.aica.tech/product">AICA Studio</a> to program those closed-loops!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d426cab82f08" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Extending ROS 2 States: An Overview of AICA’s Libraries for State Representation]]></title>
            <link>https://medium.com/better-programming/extending-ros-2-states-an-overview-of-aicas-libraries-for-state-representation-419b2911700a?source=rss-82103366a2f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/419b2911700a</guid>
            <category><![CDATA[robotics]]></category>
            <category><![CDATA[kinematics]]></category>
            <category><![CDATA[dynamics]]></category>
            <category><![CDATA[ros2]]></category>
            <category><![CDATA[cartesian]]></category>
            <dc:creator><![CDATA[Baptiste Busch]]></dc:creator>
            <pubDate>Mon, 05 Jun 2023 16:44:20 GMT</pubDate>
            <atom:updated>2023-06-05T19:23:18.224Z</atom:updated>
            <content:encoded><![CDATA[<h4>Part 2 of a series of articles centered on ROS 2 and the development we made at AICA to develop a Task and Motion Planning (TAMP) framework</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9z5TiMPtyR4yBnsw" /><figcaption>Photo by <a href="https://unsplash.com/@euwars?utm_source=medium&amp;utm_medium=referral">Farzad</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Welcome back to this series of articles centered on the development we made at <a href="https://www.aica.tech/">AICA</a> to develop a Task and Motion Planning (TAMP) framework, extending from ROS 2 features.</p><p><a href="https://medium.com/better-programming/introduction-to-ros-2-and-dynamic-composition-a-gateway-to-advanced-robotics-782b459215ee">In the previous articl</a>e, we introduced dynamic composition and its current implementation in ROS 2. In this article, we will see the design steps we took to develop a TAMP framework. We will focus here on the motion planning part by showcasing the library we use internally to represent robots and object states. We believe in open source code. Hence, all the libraries we list here are publicly available.</p><h3>Representing Cartesian States in ROS 2</h3><p>To plan dynamic robotic actions, the robot needs to have accurate information about its own internal state, as well as the state of its environment. Everything can be represented as a physical moving body observed from a certain point, considered fixed from the observer&#39;s point of view.</p><p>In robotics and physics, the <a href="https://en.wikipedia.org/wiki/Cartesian_coordinate_system">Cartesian state</a> of an object is often described as a reference frame. A reference frame, or coordinate system, is a set of axes used to measure the position and orientation of an object. The choice of reference frame can affect the Cartesian state of the object. For instance, the object’s position and orientation will be different when measured from the perspective of an observer on the ground versus an observer in a moving vehicle.</p><p>The object&#39;s orientation is often expressed using a <a href="http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/">quaternion</a>, a mathematical construct representing a rotation in three-dimensional space. Quaternions are preferred over other representations like Euler angles because they avoid issues like gimbal lock and provide a smooth interpolation between orientations. One important aspect is that most modern libraries provide a <a href="https://eigen.tuxfamily.org/dox/classEigen_1_1Quaternion.html">translation function</a> between the common representations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*dK6MKEYi3Ak7Fan1Q05xmA.gif" /><figcaption>Cartesian representation of two robotic bases expressed in a fixed world reference frame. Image from <a href="https://www.tthk.ee/inlearcs/industrial-robot-functionality-and-coordinate-systems/">https://www.tthk.ee/inlearcs/industrial-robot-functionality-and-coordinate-systems/</a></figcaption></figure><p>The Cartesian state can also include the linear and angular velocities, referred to as twist, and the object&#39;s linear and angular accelerations. Those represent the rates of change of the linear and angular velocities, respectively. These quantities are important for understanding the dynamics of the object.</p><p>In addition to position, orientation, velocities, and accelerations, the Cartesian state can also include force and torque. Force is a vector quantity that represents the total force acting on the object, while torque is a vector quantity that represents the total torque (or moment) acting on the object. The combined representation of those two elements is referred to as a wrench.</p><p>ROS 2 does not provide a unified representation for Cartesian states. Instead, the <a href="http://wiki.ros.org/geometry_msgs">geometry_msgs</a> package contains several messages that can be grouped to represent a full Cartesian state. Here is an example of how to represent a Cartesian state in ROS 2:</p><pre>#include &quot;geometry_msgs/msg/pose_stamped.hpp&quot;<br>#include &quot;geometry_msgs/msg/twist_stamped.hpp&quot;<br>#include &quot;geometry_msgs/msg/accel_stamped.hpp&quot;<br>#include &quot;geometry_msgs/msg/wrench_stamped.hpp&quot;<br><br>// Create a PoseStamped message to represent the position and orientation<br>geometry_msgs::msg::PoseStamped pose;<br>pose.header.frame_id = &quot;world&quot;;<br>pose.pose.position.x = 1.0;<br>pose.pose.position.y = 2.0;<br>pose.pose.position.z = 3.0;<br>pose.pose.orientation = tf2::toMsg(tf2::Quaternion(0.0, 0.0, M_PI/2));<br><br>// Create a TwistStamped message to represent the linear and angular velocity<br>geometry_msgs::msg::TwistStamped twist;<br>twist.header.frame_id = &quot;world&quot;;<br>twist.twist.linear.x = 0.1;<br>twist.twist.linear.y = 0.2;<br>twist.twist.linear.z = 0.3;<br>twist.twist.angular.x = 0.01;<br>twist.twist.angular.y = 0.02;<br>twist.twist.angular.z = 0.03;<br><br>// Do the same for AccelStamped and WrenchStamped messages</pre><p>You would then need to create a custom message that groups those four messages in a single structure. It becomes clear that this is a very tedious and long process. Moreover, more compact representations are available using vectors or quaternions. The <a href="https://eigen.tuxfamily.org/index.php?title=Main_Page">Eigen</a> library, for example, is a great way of representing Cartesian states and expressing transformations between them. Lastly, apart from having a compact representation of Cartesian states, the main advantage is considering mathematical operations such as inverting, scaling, and changing reference frame…</p><p>In particular, changing the reference frame of a Cartesian state involves transforming the state from one coordinate system to another. This is a common operation in robotics, as different system parts may use different reference frames.</p><p>For example, consider a robot arm that is picking up an object. The position and orientation of the object might be described in the reference frame of the robot’s base. However, the control system for the robot’s gripper might use a different reference frame centered on the gripper itself. To control the gripper accurately, we must transform the object’s Cartesian state from the base frame to the gripper frame.</p><p>This transformation involves two steps: a translation to account for the difference in position between the two frames and a rotation to account for the difference in orientation.</p><p>In ROS 2, these transformations can be performed using the <a href="https://docs.ros.org/en/iron/Tutorials/Intermediate/Tf2/Introduction-To-Tf2.html">tf2</a> library, which provides tools for managing multiple coordinate frames and transforming data between them. Here is a simple example:</p><pre>#include &quot;tf2_geometry_msgs/tf2_geometry_msgs.h&quot;<br><br>// Assume we have a PoseStamped msg representing the object&#39;s state in the base frame<br>geometry_msgs::msg::PoseStamped object_state_base;<br><br>// And a TransformStamped msg representing the transformation from the base frame to the gripper frame<br>geometry_msgs::msg::TransformStamped base_to_gripper;<br><br>// We can use tf2 to transform the object&#39;s state to the gripper frame<br>geometry_msgs::msg::PoseStamped object_state_gripper;<br>tf2::doTransform(object_state_base, object_state_gripper, base_to_gripper);</pre><p>Although this works well for pose (position and orientation), no such tools are available for velocities, accelerations, and wrenches. This motivated us to provide a clear structure to handle Cartesian states (and other types of states) and the transformations between them. Introducing the <a href="https://github.com/aica-technology/control-libraries/tree/main/source/state_representation">state_representation</a> library.</p><h3>Compact Representation of Cartesian States</h3><p><a href="https://github.com/aica-technology/control-libraries/tree/main/source/state_representation">state_representation</a> is the first library we developed and made publicly available as part of the <a href="https://github.com/aica-technology/control-libraries">control-libraries</a> meta-package. It includes multiple representations of states to explain environmental changes (Cartesian, joint state representation of robots, objects shapes, …).</p><p>The <a href="https://github.com/aica-technology/control-libraries/blob/main/source/state_representation/include/state_representation/space/cartesian/CartesianState.hpp">CartesianState</a> class represents a spatial frame in 3D space containing the following spatial and dynamic properties:</p><ul><li>Position</li><li>Orientation</li><li>Linear velocity</li><li>Angular velocity</li><li>Linear acceleration</li><li>Angular acceleration</li><li>Force</li><li>Torque</li></ul><p>Each state variable is represented as a 3D vector (Eigen::Vector3D), except for the orientation, which is represented by a unit quaternion (Eigen::Quaterniond). The values are assumed to be in standard SI units (meters, radians, seconds, and Newtons).</p><p>The spatial properties are expressed relative to a named reference frame. For a CartesianState with the name &quot;A&quot; and reference frame &quot;B,&quot; each state variable represents the instantaneous spatial property measured at or around frame &quot;A&quot; from the perspective of frame &quot;B.&quot; Here is how you can initialize a CartesianState:</p><pre>#include &quot;state_representation/space/cartesian/CartesianState.hpp&quot;<br><br>// Create a CartesianState A expressed in reference frame B<br>state_representation::CartesianState state(&quot;A&quot;, &quot;B&quot;);<br><br>// Set the position<br>state.set_position(Eigen::Vector3d(1.0, 2.0, 3.0));<br><br>// Set the orientation using a quaternion<br>Eigen::Quaterniond orientation(1.0, 0.0, 0.0, 0.0); // identity quaternion<br>state.set_orientation(orientation);<br><br>// Set the linear velocity<br>state.set_linear_velocity(Eigen::Vector3d(0.1, 0.2, 0.3));<br><br>// Set the angular velocity<br>state.set_angular_velocity(Eigen::Vector3d(0.01, 0.02, 0.03));<br><br>// Do the same for linear &amp; angular accelerations, force and torque</pre><p>state_representation also provides mathematical operations for changing reference frames. To that extent, we have decided to override the * operator as this is the most common and compact way of representing chained transformations:</p><pre>// Assume we have a CartesianState &#39;state_in_A&#39; expressed in frame &#39;A&#39;<br>state_representation::CartesianState state_in_A(&quot;state&quot;, &quot;A&quot;);<br><br>// And we have a transform from frame &#39;A&#39; to a new frame &#39;B&#39;<br>state_representation::CartesianPose A_in_B(&quot;A&quot;, &quot;B&quot;);<br><br>// We can change the reference frame of &#39;state_in_A&#39; to frame &#39;B&#39;<br>state_representation::CartesianState state_in_B = state_in_A * A_in_B;</pre><p>This operation affects the pose (position and orientation) and all the other state variables (twist, acceleration, and wrench). Other operations, such as addition or difference, are also implemented, as shown below:</p><pre>#include &quot;state_representation/space/cartesian/CartesianState.hpp&quot;<br><br>// Create two CartesianStates<br>state_representation::CartesianState state1(&quot;state1&quot;, &quot;world&quot;);<br>state_representation::CartesianState state2(&quot;state2&quot;, &quot;world&quot;);<br><br>// Set their positions<br>state1.set_position(Eigen::Vector3d(1.0, 2.0, 3.0));<br>state2.set_position(Eigen::Vector3d(4.0, 5.0, 6.0));<br><br>// Add the states<br>state_representation::CartesianState sum = state1 + state2;<br><br>// Subtract the states<br>state_representation::CartesianState difference = state1 - state2;</pre><p>Those operations are checked for validity. For example, adding states not expressed in the same reference frame will throw an error. We refer the reader to the <a href="https://github.com/aica-technology/control-libraries/tree/main/source/state_representation">documentation</a> for additional functionalities, including derived class to express single state variables, time derivation and integration, and norms. Please, note this library is available both in C++ and Python.</p><h3>From Cartesian to Joint States</h3><p>One important aspect of robotics lies in the existence of two distinct spaces. As seen above, the Cartesian space represents the state of moving bodies, such as the robot&#39;s end-effector or base. Conversely, the joint state represents the state of the joints of a robot. It typically includes the joint positions (angles for revolute joints or displacements for prismatic joints), velocities (angular or linear), and accelerations. It may also include joint torques or forces.</p><p>Following the exact same pattern and API of CartesianState, state_representation provide a <a href="https://github.com/aica-technology/control-libraries/blob/main/source/state_representation/include/state_representation/space/joint/JointState.hpp">JointState</a> class for representing joint states:</p><pre>#include &quot;state_representation/robot/JointState.hpp&quot;<br><br>// Create a JointState for a robot with 7 joints<br>state_representation::JointState joint_state(&quot;my_robot&quot;, 7);<br><br>// Set the joint positions<br>joint_state.set_positions(Eigen::VectorXd::Random(7));<br><br>// Set the joint velocities<br>joint_state.set_velocities(Eigen::VectorXd::Random(7));<br><br>// Set the joint torques<br>joint_state.set_torques(Eigen::VectorXd::Random(7));</pre><p>In this code, we create a JointState for a robot with seven joints, and set the joint positions, velocities, and torques to random values. The accelerations are set to zeroes which are the default values.</p><p>One fundamental concept of robotics is the ability to transform Cartesian space into joint space and vice versa. Knowing the robot&#39;s state, one can infer the Cartesian state of each robot&#39;s body part. This can be achieved for all state variables of both states.</p><h3>Implementing Kinematics and Dynamics</h3><p>Kinematics is the study of motion without considering the forces that cause the motion. In robotics, kinematics involves the mathematical description of the motion of robots. There are two primary types of kinematics: direct (or forward) kinematics and inverse kinematics.</p><p>On the other hand, dynamics involves studying forces and torques that cause motion in robots. Similar to kinematics, dynamics can be divided into two types: direct (or forward) dynamics and inverse dynamics.</p><h4>Direct (forward) kinematics</h4><p>Direct kinematics is the process of determining the position and orientation of the end-effector (the robot&#39;s tool or hand) given the robot&#39;s joint angles and lengths. In other words, if you know the angles of all the joints in the robot, forward kinematics allows you to calculate where the end-effector is.</p><p>The mathematical model that describes this relationship is often represented as a function that maps joint variables (angles for revolute joints, displacements for prismatic joints) to a pose in Cartesian space (position and orientation).</p><h4>Inverse kinematics</h4><p>Inverse kinematics is the reverse process of direct kinematics. Given a desired pose of the end-effector, inverse kinematics determines the joint angles and lengths that would achieve that position. In other words, if you want the robot to reach a certain location, inverse kinematics tells you how to position and orient each robot’s joints.</p><p>Inverse kinematics is often more complex than direct kinematics because there may be multiple sets of joint angles that result in the same end-effector position (multiple solutions), or there may need to be a way to position the joints to reach the desired location (no solution).</p><p>Both direct and inverse kinematics are fundamental to robot motion planning and control. Direct kinematics is often used in robot simulation and visualization, while inverse kinematics is used in path planning and control, where the goal is to move the end-effector to a desired location.</p><h4>Direct (forward) dynamics</h4><p>Direct dynamics is the process of determining the robot&#39;s acceleration given the joint torques (or forces for prismatic joints) and the current state of the robot (joint positions and velocities). In other words, if you know the forces applied to the robot and its current state, forward dynamics allow you to calculate how the robot will move.</p><p>The mathematical model that describes this relationship is often represented as a function that maps joint torques and the current state to joint accelerations. This function is typically derived from the robot’s equations of motion, which are based on Newton’s second law of motion (force equals mass times acceleration).</p><h4>Inverse dynamics</h4><p>Inverse dynamics is the reverse process of direct dynamics. Given the desired motion of the robot (joint positions, velocities, and accelerations), inverse dynamics determines the joint torques that would achieve that motion. In other words, if you want the robot to move a certain way, inverse dynamics tells you how much force or torque to apply at each joint.</p><p>Inverse dynamics is often more complex than direct dynamics because it involves calculating the forces and torques required to overcome inertia, gravity, and damping. However, it is a crucial part of robot control, as it allows the control system to command the appropriate forces and torques to achieve the desired motion.</p><p>Both direct and inverse dynamics are fundamental to robot motion planning and control. Direct dynamics is often used in robot simulation, where the goal is to predict how the robot will move given certain forces. Inverse dynamics is used in robot control, where the goal is to command the robot to move in a certain way.</p><h4>Using Pinocchio</h4><p>To compute both kinematics and dynamics, we rely on the open-source library <a href="https://github.com/stack-of-tasks/pinocchio">pinocchio</a>. It is written in C++ and is designed to be fast and flexible. To get information on the robot (segment length, body masses, etc.), the library relies on <a href="http://wiki.ros.org/urdf">URDF</a> models commonly used in ROS / ROS 2.</p><p>We have developed a wrapper around it in the <a href="https://github.com/aica-technology/control-libraries/tree/main/source/robot_model">robot_model</a> library. This library is fully integrated with CartesianState and JointState from state_representation. We use it to convert spaces while we develop controllers.</p><p>For example, it provides simple-to-use functions for forward and inverse kinematics:</p><pre>// initialize the robot model from a URDF<br>robot_model::Model model(&quot;myrobot&quot;, &quot;path/to/urdf/myrobot.urdf&quot;)<br><br>// forward kinematics: pose of end-effector frame from the robot joint positions<br>state_representation::JointPositions jp = state_representation::JointPositions::Random(&quot;myrobot&quot;, 7);<br>state_representation::CartesianPose pose = model.forward_kinematics(jp);<br><br>// inverse kinematics: joint positions from end-effector pose<br>state_representation::CartesianPose cp = state_representation::CartesianPose::Random(&quot;eef&quot;);<br>state_representation::JointPositions jp = model.inverse_kinematics(cp);<br><br>// forward velocity kinematics: twist of end-effector frame from the robot joint velocities and positions<br>state_representation::JointState js = state_representation::JointState::Random(&quot;myrobot&quot;, 7);<br>state_representation::CartesianTwist twist = model.forward_velocity(js);<br><br>// inverse velocity kinematics: joint velocities from end-effector twist and current state of the robot<br>state_representation::CartesianTwist ct = state_representation::CartesianTwist::Random(&quot;eef&quot;);<br>state_representation::JointPositions jp = state_representation::JointPositions::Random(&quot;myrobot&quot;, 7);<br>state_representation::JointVelocities jv = model.inverse_velocity(ct, jp);</pre><p>and also forward and inverse dynamics:</p><pre>// inertia matrix from joint positions<br>state_representation::JointPositions jp = state_representation::JointPositions::Random(&quot;myrobot&quot;, 7);<br>Eigen::MatrixXd inertia = model.compute_inertia_matrix(jp);<br>// inertia torques, equivalent to inertia multiplied by joint accelerations. The joint positions part of the state<br>// is used to compute the inertia matrix<br>state_representation::JointState js = state_representation::JointState::Random(&quot;myrobot&quot;, 7);<br>state_representation::JointTorques inertia_t = model.compute_inertia_torques(js);<br><br>// coriolis matrix from joint positions and velocities<br>state_representation::JointState js = state_representation::JointState::Random(&quot;myrobot&quot;, 7);<br>Eigen::MatrixXd coriolis = model.compute_coriolis_matrix(js);<br>// coriolis torques, equivalent to coriolis multiplied by joint velocities. The joint positions part of the state<br>// is used to compute the coriolis matrix<br>state_representation::JointState js = state_representation::JointState::Random(&quot;myrobot&quot;, 7);<br>state_representation::JointTorques coriolis_t = model.compute_coriolis_torques(js);<br><br>// gravity torques from joint positions<br>state_representation::JointPositions jp = state_representation::JointPositions::Random(&quot;myrobot&quot;, 7);<br>state_representation::JointTorques gravity_t = model.compute_gravity_torques(jp);</pre><p>Although dynamics computations are available, these are not used as much as kinematics in practice. One of the main reasons is that robot manufacturers treat inertia and mass data as trade secrets; even if they provide them, they are sometimes inaccurate. However, there are new techniques to learn those data from direct interaction. We are looking at this to improve those models and achieve a finer level of control for force-based applications.</p><h3>Conclusion</h3><p>In this article, we have seen how the state of the robot and its environment can be represented using Cartesian and joint states. We have hinted at how both spaces can be transformed and their relationships. We also introduced the libraries we developed at <a href="https://www.aica.tech/">AICA</a> to handle those transformations.</p><p>The <a href="https://github.com/aica-technology/control-libraries/tree/main/source/state_representation">state_representation</a> and <a href="https://github.com/aica-technology/control-libraries/tree/main/source/robot_model">robot_model</a> libraries are designed to be highly versatile and easy to use. They extend the representation of states that can be found in ROS / ROS 2 and rely on modern and efficient libraries for computation (such as <a href="https://eigen.tuxfamily.org/index.php?title=Main_Page">Eigen</a> and <a href="https://github.com/stack-of-tasks/pinocchio">pinocchio</a>). Both libraries can be installed from the <a href="https://github.com/aica-technology/control-libraries/tree/main">control-libraries</a> meta-package and provide C++ and Python implementations.</p><p>Looking at <a href="https://github.com/aica-technology/control-libraries/tree/main">control-libraries</a>, you will notice two additional libraries, <a href="https://github.com/aica-technology/control-libraries/tree/main/source/dynamical_systems">dynamical_systems</a> and <a href="https://github.com/aica-technology/control-libraries/tree/main/source/controllers">controllers</a> that were not addressed in this article. This will be the focus of the next article, which will cover the topics of motion planning and control strategies based on the representation of states introduced here. Stay tuned for more insights on robotics!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3-R2sSwj50NBstaPa4bJiw.png" /><figcaption>Image credit: AICA</figcaption></figure><h3>References</h3><ul><li><a href="https://www.aica.tech/">https://www.aica.tech/</a></li><li><a href="https://betterprogramming.pub/introduction-to-ros-2-and-dynamic-composition-a-gateway-to-advanced-robotics-782b459215ee">https://betterprogramming.pub/introduction-to-ros-2-and-dynamic-composition-a-gateway-to-advanced-robotics-782b459215ee</a></li><li><a href="https://en.wikipedia.org/wiki/Cartesian_coordinate_system">https://en.wikipedia.org/wiki/Cartesian_coordinate_system</a></li><li><a href="http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/">http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/</a></li><li><a href="https://www.tthk.ee/inlearcs/industrial-robot-functionality-and-coordinate-systems/">https://www.tthk.ee/inlearcs/industrial-robot-functionality-and-coordinate-systems/</a></li><li><a href="http://wiki.ros.org/geometry_msgs">http://wiki.ros.org/geometry_msgs</a></li><li><a href="https://eigen.tuxfamily.org/index.php?title=Main_Page">https://eigen.tuxfamily.org/index.php?title=Main_Page</a></li><li><a href="https://docs.ros.org/en/iron/Tutorials/Intermediate/Tf2/Introduction-To-Tf2.html">https://docs.ros.org/en/iron/Tutorials/Intermediate/Tf2/Introduction-To-Tf2.html</a></li><li><a href="https://github.com/aica-technology/control-libraries">https://github.com/aica-technology/control-libraries</a></li><li><a href="https://github.com/stack-of-tasks/pinocchio">https://github.com/stack-of-tasks/pinocchio</a></li><li><a href="http://wiki.ros.org/urdf">http://wiki.ros.org/urdf</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=419b2911700a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/extending-ros-2-states-an-overview-of-aicas-libraries-for-state-representation-419b2911700a">Extending ROS 2 States: An Overview of AICA’s Libraries for State Representation</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fear of robots is cultural]]></title>
            <link>https://buschbapti.medium.com/fear-of-robots-is-cultural-178b450db49c?source=rss-82103366a2f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/178b450db49c</guid>
            <category><![CDATA[culture]]></category>
            <category><![CDATA[robotics]]></category>
            <category><![CDATA[society]]></category>
            <dc:creator><![CDATA[Baptiste Busch]]></dc:creator>
            <pubDate>Mon, 29 May 2023 13:20:41 GMT</pubDate>
            <atom:updated>2023-05-29T13:21:37.551Z</atom:updated>
            <content:encoded><![CDATA[<p>Do you see robots as a threat to your work or humanity in general? Then, I guess you must be from Europe or America. It is well known that the Japanese society tends to welcome the evolution of robotics and their intrusion in our daily lives. Conversely Western societies are more cautious on the subject. But, why?</p><figure><img alt="Drawinf of a robot with a seringue with text that say &quot;Destroy all humans" src="https://cdn-images-1.medium.com/max/400/1*IlJ_3wwstUpHcBQSl81riQ.jpeg" /><figcaption>Drawing by <a href="http://joostmarcellis.nl/">Joost Marcellis</a></figcaption></figure><p>In his article “<em>Who is afraid of the humanoid? Investigating cultural differences in the acceptance of robots</em>” Frédéric Kaplan details a very interesting analysis of the impact of both Japanese and Western cultures on the perception of robots. Looking at robots depicted in science fiction we can already see some major differences. On one hand, mangas like <em>Mighty Atom (Astroboy) </em>or <em>Gundam</em> introduce robots that save society from evil threats, while trying to mingle with humankind. On the other hand, Hollywood movies like <em>I, robot</em> or <em>Terminator</em> paint a grimmer vision of robots, seen as killing machines and threats to fight against. The only notable exception is the <em>Star Wars </em>saga but seeing <a href="https://www.inverse.com/entertainment/star-wars-samurai-japan-connection-explained#:~:text=Lucas%20was%20famously%20inspired%20by,in%20medieval%20Japan%2C%20too">how much it is inspired from the Japanese culture </a>already hints some plausible explanations.</p><p>Can those perception differences be explained from an historical point of view? After living ostracized from the rest of the world for centuries, during the Meiji period (1868–1912), Japan started its industrial revolution. And it was rather unconventional. In order to defend themselves they started copying and replicating foreign technologies like machine guns and railways. Kaplan refers to it as technology “taming”. You would think that it would have created a cleavage between technology and culture as in most Western countries. But, in fact, it showed the Japanese society that technology can be tamed, incorporated as your own, when sufficiently mastered. Unmastered technologies can be a threat to society, not the one you understand well enough. And that same tamed technology can then be used to defend yourself against foreign threats. Isn’t it surprising that a country that suffered so much from the nuclear bomb would decide to invest in and produce nuclear energy? Therefore, isn’t robotics another technology for Japanese to master and tame? This definitely starts providing a plausible explanation. But it might only be the tip of the iceberg.</p><p>To understand why robotics is such a topic of passion, we have to dive deeper. Deeper in the culture realm, and the myths that nourish our collective thoughts. First, we have to understand where robots are coming from. Probably, you already know, but the term robot has been invented by the Czech science fiction writer Karel Capek in his play <a href="https://en.wikipedia.org/wiki/R.U.R."><em>Rossumovi Univerzální Roboti</em> (Rossum’s Universal Robots)</a> in 1920. The play was featuring a factory that was creating artificial people, called roboti, whose purpose is to replace human workers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*nkU7IKOIDeYA9gjZZHqACQ.jpeg" /><figcaption>A scene in R.U.R depicting the artificial machines named roboti</figcaption></figure><p><strong>“Artificial beings”</strong> is key here. And the abundant literature on the subject is giving us food for thoughts.</p><p>From the <a href="https://en.wikipedia.org/wiki/Golem">golems</a> in the Jewish folklore, to Dr. Frankenstein’s hideous creature, our western myths depict artificial beings as a threat to humanity that would soon take over their maker. And, more generally, we make a clear distinction between what is artificial, aka created by humankind, and natural. Would you say that a beehive is natural but your own house is not? Maybe you prefer natural medicine than the one prescribed by your doctor? Robots are not simple machines. They are artificial beings made to look and act like humans. How long before they take over the world?</p><p>And Japan in all that? In the Japanese culture, there isn’t such a clear distinction between natural and artificial things. Take a Zen garden for example. It is made of artificially disposed rocks. Yet it is incorporated into a more natural environment without clear separations. Bonsaïs trees are nothing but normal trees kept artificially small. Artificially replicating nature is not only an art, it is a tribute made to natural beauty. It teaches us that artificial and natural things can cohabitate to a point where there is no distinction between them. Thus, it is not surprising that Japan is investing so much into creating androids that mimics us in perfect ways, while western humanoid robots keep looking like very distinguishable machines.</p><figure><img alt="Hiroshi Ishiguro standing next to Geminoid HI, an android robotic copy of himself. Photo by Makoto Ishida." src="https://cdn-images-1.medium.com/max/1024/1*8LXsx-E1BBSmQtaZA956UA.jpeg" /><figcaption>Hiroshi Ishiguro and his android robot copy Geminoid HI. Photo by Makoto Ishida</figcaption></figure><p>This distinction between artificial and natural things or beings goes far beyond impacting our perception about robotics. It also hinders our approach to solving bigger challenges like global warming for example. Here again, western societies would oppose the two views. One might think that we should abandon all technologies and live in a more natural way, while others will say that only technology can save us. Look at how we separate natural environments in wildlife sanctuaries, shrinking them the more we expand, instead of learning how to better live within them. But wouldn’t the correct approach lie somewhere in the middle? For once, maybe, we should adopt the Japanese point of view on the matter.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=178b450db49c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to ROS 2 and Dynamic Composition: A Gateway to Advanced Robotics]]></title>
            <link>https://medium.com/better-programming/introduction-to-ros-2-and-dynamic-composition-a-gateway-to-advanced-robotics-782b459215ee?source=rss-82103366a2f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/782b459215ee</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[robotics]]></category>
            <category><![CDATA[ros2]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[robot-motion-planning]]></category>
            <dc:creator><![CDATA[Baptiste Busch]]></dc:creator>
            <pubDate>Sun, 28 May 2023 12:01:41 GMT</pubDate>
            <atom:updated>2023-06-01T14:27:13.055Z</atom:updated>
            <content:encoded><![CDATA[<p>Welcome to the first part of our series on dynamic composition in ROS 2 and how we, at <a href="https://www.aica.tech/">AICA</a>, have built advanced features on top of it. This article is designed to be a comprehensive guide for those with a basic understanding of robotics and programming, but who may be new to ROS 2 and the concept of dynamic composition. Let’s dive in!</p><h3>What is ROS 2?</h3><p><a href="https://www.ros.org/">ROS</a>, or the Robot Operating System, is a flexible framework for writing robot software. It’s a collection of tools, libraries, and conventions that aim to simplify the task of creating complex and robust robot behavior across a wide variety of robotic platforms.</p><p><a href="https://docs.ros.org/en/iron/index.html#">ROS 2</a> is the second version of this system, designed with an eye towards the future of robotics and industrial applications. It includes features like multi-robot systems, real-time communication, lifecycle nodes and dynamic composition.</p><p>One of the fundamental concepts in ROS and by extension ROS 2 is the idea of a “node”. A node is essentially a process that performs computation. Nodes communicate with each other by passing messages through topics.</p><p>Here is a simple code snippet that shows how a node might be created in ROS 2:</p><pre>#include &quot;rclcpp/rclcpp.hpp&quot;<br><br>class MyNode : public rclcpp::Node<br>{<br>public:<br>  MyNode() : Node(&quot;my_node&quot;) {}<br>};<br><br>int main(int argc, char **argv)<br>{<br>  rclcpp::init(argc, argv);<br>  auto node = std::make_shared&lt;MyNode&gt;();<br>  rclcpp::spin(node);<br>  rclcpp::shutdown();<br>  return 0;<br>}</pre><p>In this code, we define a new node named “my_node”. The <strong>rclcpp::init</strong> function initializes ROS 2, and <strong>rclcpp::spin</strong> causes ROS 2 to enter a loop, processing data and passing messages until the program is terminated.</p><p>Nodes can perform any type of complex behaviors and computation. One of the most common patterns is to define inter-node communication using the concept of publishers and subscribers. This article does not aim at defining all the concepts of ROS / ROS 2 so we invite the reader to follow the <a href="https://docs.ros.org/en/foxy/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.html">official documentation</a>.</p><p>Using ROS 2 and, in particular the concept of nodes, offers several advantages over traditional robotic scripting:</p><ol><li><strong>Modularity</strong>: Nodes in ROS 2 allow for a modular approach to building robotic systems. Each node can be developed, tested, and deployed independently, making the system more manageable and scalable.</li><li><strong>Interoperability</strong>: Nodes communicate with each other using a publish-subscribe pattern, which allows for easy integration of different components. This means you can easily combine nodes developed by different teams or even different organizations.</li><li><strong>Fault Isolation</strong>: If a node crashes, it doesn’t bring down the whole system. This is a significant advantage over traditional monolithic applications where a single error can cause the entire system to fail.</li><li><strong>Real-time Performance</strong>: ROS 2 has been designed with real-time performance in mind. This is crucial for many robotic applications where timing is critical.</li></ol><p>While we showcase here the examples written in C++, one of the most useful features of ROS / ROS 2 is the possibility to write nodes in both C++ and python (additional languages are also available while not necessarily officially supported). Those nodes then coexist and can exchange messages independently of their base language.</p><h3>Lifecycle Nodes in ROS 2</h3><p>In addition to the standard nodes, ROS 2 introduces the concept of a lifecycle node. This is a node with a managed lifecycle, allowing for greater control over the state of the system. It ensures that all elements have been instantiated correctly before it allows a node to begin executing its behavior. It also allows nodes to be restarted or replaced online.</p><p>A lifecycle node presents a known interface and executes according to a known lifecycle state machine. This allows freedom to the node developer on how they provide the managed lifecycle functionality, while also ensuring that any tools created for managing nodes can work with any compliant node.</p><p>There are four primary states in the lifecycle of a node:</p><ol><li>Unconfigured</li><li>Inactive</li><li>Active</li><li>Finalized</li></ol><p>And there are seven transitions exposed to a supervisory process:</p><ol><li>Create</li><li>Configure</li><li>Cleanup</li><li>Activate</li><li>Deactivate</li><li>Shutdown</li><li>Destroy</li></ol><p>The following diagram from the <a href="https://design.ros2.org/articles/node_lifecycle.html">official documentation</a> shows all the possible lifecycle states and transitions between them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TTPHVgOUcX_NtV9pVPOurw.png" /><figcaption>Diagram of lifecycle transitions from official ROS 2 documentation <a href="https://design.ros2.org/articles/node_lifecycle.html">https://design.ros2.org/articles/node_lifecycle.html</a></figcaption></figure><p>Here is a simple code snippet that shows how a lifecycle node might be created in ROS 2:</p><pre>#include &quot;rclcpp_lifecycle/lifecycle_node.hpp&quot;<br><br>class MyLifecycleNode : public rclcpp_lifecycle::LifecycleNode<br>{<br>public:<br>  MyLifecycleNode() : LifecycleNode(&quot;my_lifecycle_node&quot;) {}<br><br>rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn<br>on_configure(const rclcpp_lifecycle::State &amp;)<br>{<br>  RCLCPP_INFO(get_logger(), &quot;Configuring…&quot;);<br>  // Add your configuration code here<br>  return rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn::SUCCESS;<br>}<br><br>rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn<br>on_activate(const rclcpp_lifecycle::State &amp;)<br>{<br>  RCLCPP_INFO(get_logger(), &quot;Activating…&quot;);<br>  // Add your activation code here<br>  return rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn::SUCCESS;<br>}<br><br>// Do the same for on_deactivate, on_cleanup, on_shutdown<br>};<br><br>int main(int argc, char **argv)<br>{<br>  rclcpp::init(argc, argv);<br>  auto node = std::make_shared&lt;MyLifecycleNode&gt;();<br>  rclcpp::spin(node-&gt;get_node_base_interface());<br>  rclcpp::shutdown();<br>  return 0;<br>}</pre><p>In this code, we define a new lifecycle node named my_lifecycle_node. This node has several callback functions that are called when the node transitions to different states. For example, the on_configure function is called when the node is transitioning from Unconfigured to the Inactive state, and the on_activate function is called when the node is transitioning to the Active state. Each of these functions returns a status indicating whether the transition was successful.</p><p>This is a basic example, and in a real-world application, you would add your own code to these functions to perform the necessary configuration, activation, deactivation, cleanup, and shutdown tasks for your node.</p><h3>Comparing Nodes and Lifecycle Nodes</h3><p>A standard node in ROS 2 performs computations and communicates with other nodes by passing messages, while being always in an active state. A lifecycle node, on the other hand, has additional capabilities that allow to manage its lifecycle externally from service calls. This includes the ability to transition between different states, such as inactive &amp; active, and to respond to specific transitions.</p><p>In summary, compared to traditional nodes, lifecycle nodes bring the additional benefits:</p><ol><li><strong>Lifecycle Management</strong>: Lifecycle nodes in ROS 2 provide a managed lifecycle for nodes, allowing for greater control over the state of the system. This can lead to more robust systems that can handle errors more gracefully.</li><li><strong>State Management</strong>: Lifecycle nodes allow for explicit state transitions, such as configuring, activating, deactivating, and shutting down. This can make the system easier to manage and debug compared to traditional scripting where the state of the system can be more difficult to understand.</li><li><strong>Online Replacement and Upgrades</strong>: With lifecycle nodes, it’s possible to replace or upgrade parts of the system online, without needing to bring down the whole system. This can lead to higher uptime and more flexibility in maintaining and improving the system.</li><li><strong>Resource Efficiency</strong>: Allowing nodes to be in different states enables better resource utilization. Resource heavy nodes can be turned on / off only when needed, saving computational power and, eventually, network bandwidth.</li></ol><h3>Understanding Components and Dynamic Composition</h3><p>ROS 2 also introduces the concept of components. A component is essentially a node that is designed to be used with dynamic composition. It is built into a shared library and doesn’t have a main function, as it is not meant to be directly instantiated. Instead, it is a subclass of rclcpp::Node and registers itself using macros from the rclcpp_components package. This makes the component discoverable when its library is being loaded into a running process.</p><p>Here is an example of how you might define a component in ROS 2:</p><pre>#include &quot;rclcpp/rclcpp.hpp&quot;<br>#include &quot;rclcpp_components/register_node_macro.hpp&quot;<br><br>class MyComponent : public rclcpp::Node<br>{<br>public:<br>  MyComponent() : Node(&quot;my_component&quot;) {}<br>};<br><br>RCLCPP_COMPONENTS_REGISTER_NODE(MyComponent)</pre><p>In this code, we define a new component named “my_component”. The RCLCPP_COMPONENTS_REGISTER_NODE macro registers the component, making it discoverable when its library is loaded into a running process.</p><p>Although we showcased nodes in this example, the same concept applies to lifecycle nodes. In that case they simply inherit from rclcpp_lifecycle::LifecycleNode instead of rclcpp::Node.</p><p>A component is not made to be directly instantiated but dynamically loaded from a ComponentManager. This is the concept referred to as dynamic composition.</p><p>The following simple code snippet shows how you might use dynamic composition in ROS 2:</p><pre>#include &quot;rclcpp/rclcpp.hpp&quot;<br>#include &quot;rclcpp_components/component_manager.hpp&quot;<br><br>int main(int argc, char **argv)<br>{<br>  rclcpp::init(argc, argv);<br>  auto executor = std::make_shared&lt;rclcpp::executors::SingleThreadedExecutor&gt;();<br>  auto manager = std::make_shared&lt;rclcpp_components::ComponentManager&gt;(executor);<br>  executor-&gt;add_node(manager);<br>  executor-&gt;spin();<br>  rclcpp::shutdown();<br>  return 0;<br>}</pre><p>Using the ComponentManager you can then use services to dynamically load and unload components. The <a href="https://docs.ros.org/en/iron/Tutorials/Intermediate/Composition.html">official documentation</a> introduces a comprehensive guide on this feature.</p><p>Dynamic composition in ROS 2 offers several benefits:</p><ol><li><strong>Efficiency</strong>: Dynamic composition allows multiple nodes to be composed into a single process at runtime, reducing the overhead of inter-process communication. This can lead to more efficient use of system resources and potentially faster communication between nodes.</li><li><strong>Flexibility</strong>: With dynamic composition, the layout of processes and nodes can be changed at runtime. This allows for a high degree of flexibility in how the system is structured and can adapt to different requirements or conditions at runtime.</li><li><strong>Scalability</strong>: Dynamic composition supports a more modular and scalable approach to building robotic systems. It allows complex systems to be built from simpler parts, which can be developed, tested, and deployed independently.</li><li><strong>Performance Tuning</strong>: Dynamic composition allows for fine-grained control over the execution of nodes, which can be used to optimize the performance of the system. For example, nodes that communicate frequently can be composed into the same process to reduce communication latency.</li><li><strong>Code Reusability</strong>: Components designed for dynamic composition can be reused in different contexts and composed in different ways, promoting code reusability and reducing development effort.</li></ol><p>In summary, the dynamic composition is a powerful feature in ROS 2 that can lead to more efficient, flexible, and robust robotic systems.</p><h3>Limits of the current implementation</h3><p>While dynamic composition brings clear benefits that can lead to more efficient and flexible robotic systems when used appropriately, the current design lacks in legibility making it hard to define proper applications. Most of the community is not aware of the existence of this feature and the documentation is not clear enough to guide newcomers into it.</p><p>One of the most limiting aspects is the lack of Python implementation of the ComponentManager class restricting the support of dynamic composition only to C++ based nodes. The best feature of ROS / ROS 2 lies in the possibility of having the coexistence of nodes written in C++ and Python, thus, limiting one of the best features of ROS 2 to only C++ is nonsense. A generic ComponentManager<strong> </strong>able to handle both C++ and Python components seamlessly is yet to be introduced.</p><p>We also believe that the framework could be extended further, in particular when combined with the functionalities offered by lifecycle nodes (that are also not yet available in Python by the way). An extension of this feature could finally enable <strong>Task And Motion Planning (TAMP)</strong> in ROS 2.</p><p>TAMP is a fundamental aspect of robotics that involves determining the sequence of actions (task planning) and the specific movements (motion planning) a robot must execute to achieve a specific goal. It is akin to a chef following a recipe, where the recipe outlines the steps (tasks) and the chef figures out how to physically perform each step (motions). TAMP is a complex but crucial process that enables robots to perform intricate tasks autonomously, taking into account the robot’s capabilities, the environment, and the specific task requirements. All the base elements are there to develop such a solution. Dedicated components define each specific movements (motion planning) and dynamic composition<strong> </strong>manages<strong> </strong>the transitions between them. A simple way of defining the graph of actions (task planning) is still needed as ROS launch files tend to overcomplicate this process.</p><p>TAMP also relies heavily on the notion of predicates to trigger transitions between actions. A predicate is a statement about the world that can be either true or false, serving as the system’s understanding of facts about its environment. Predicates, such as IsPartReady or IsMotionDone, represent knowledge in a way that a robot or AI can understand and reason about, aiding in decision-making and planning. For instance, a robot could use the logic combination of those predicates (<strong>AND</strong> gate) to decide to close its gripper to grasp an object. Essentially, predicates help robots comprehend their surroundings and determine appropriate actions. There is no dedicated solution for predicate handling in ROS 2, yet basic message passing of boolean values is a possible way of implementing them (discrete events, i.e. predicates that are true then turn false when consumed are slightly harder to replicate though).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jBdcBLBi_fhYBiYUKpJaIw.png" /><figcaption>TAMP architecture mixing continuous signal for passing information and predicates for transitions handling Image credit: AICA</figcaption></figure><p>At AICA, we leverage the capabilities of lifecycle nodes and dynamic composition to develop our own TAMP framework. We have implemented a <strong>Dynamic State Engine</strong> not only allowing dynamic composition of C++ &amp; python nodes and lifecycle nodes, but also enabling transition of lifecycle states from predicate logic. We have also defined a text-based syntax that structures this concept, simplifying the writing of such transitions. This syntax allows us to then build a graphical representation of components and their transition, enabling a proper no-code dynamic composition.</p><p>The next part of this series of articles will dive deeper into the concepts and solutions we have developed. Stay tuned!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3-R2sSwj50NBstaPa4bJiw.png" /><figcaption>Image credit: AICA</figcaption></figure><h4>References</h4><ul><li><a href="https://www.aica.tech/">https://www.aica.tech/</a></li><li><a href="https://www.ros.org/">https://www.ros.org/</a></li><li><a href="https://docs.ros.org/en/iron/index.html#">https://docs.ros.org/en/iron/index.html#</a></li><li><a href="https://design.ros2.org/articles/node_lifecycle.html">https://design.ros2.org/articles/node_lifecycle.html</a></li><li><a href="https://docs.ros.org/en/iron/Concepts/About-Composition.html">https://docs.ros.org/en/iron/Concepts/About-Composition.html</a></li><li><a href="https://docs.ros.org/en/iron/Tutorials/Intermediate/Composition.html">https://docs.ros.org/en/iron/Tutorials/Intermediate/Composition.html</a></li><li><a href="https://arxiv.org/pdf/2305.09933.pdf">https://arxiv.org/pdf/2305.09933.pdf</a></li><li><a href="https://roboticseabass.com/2022/07/30/integrated-task-and-motion-planning-in-robotics/">https://roboticseabass.com/2022/07/30/integrated-task-and-motion-planning-in-robotics/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=782b459215ee" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/introduction-to-ros-2-and-dynamic-composition-a-gateway-to-advanced-robotics-782b459215ee">Introduction to ROS 2 and Dynamic Composition: A Gateway to Advanced Robotics</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a ROS or ROS2 workspace in Docker (Part 1)]]></title>
            <link>https://buschbapti.medium.com/creating-a-ros-or-ros2-workspace-in-docker-part-1-912529c87708?source=rss-82103366a2f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/912529c87708</guid>
            <category><![CDATA[dockerfiles]]></category>
            <category><![CDATA[robotics]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Baptiste Busch]]></dc:creator>
            <pubDate>Mon, 22 Jun 2020 20:11:49 GMT</pubDate>
            <atom:updated>2020-06-22T20:11:49.785Z</atom:updated>
            <content:encoded><![CDATA[<p>At <a href="http://www.aica.tech/">AICA</a>, we focus on simplifying the programming of industrial robotic arms. For some years now, the <a href="http://www.ros.org/">Robot Operating System (ROS)</a> has been widely use by academics and industrial alike to create their robotic tasks and standardize their developed algorithms. With ROS2 LTS versions being released, you might want to include this framework into your arsenal.</p><p>If you are like us, and have tried to setup ROS on a computer, you have probably been puzzled by how not straightforward this is. Now, imagine having to deal with algorithms that run on a specific version of ROS or a robot that have been hooked on a computer that have not been updated for years by fear of it not working anymore. Well, we&#39;ve got you covered. Thanks to containerized solution like Docker you can create and deploy ROS workspaces in minutes. Without further ado let&#39;s dive into it.</p><p>Disclaimer: This tutorial is not an introduction to ROS or Docker. For this we refer to the plethora of articles on both topics. Please not that we are using Docker here as our container solution thanks to the availability of official ROS images that drastically simplify the process. The proposed solution works on a Linux based host machine. It will require modifications to work on Windows or Mac systems.</p><h3>ROS images on DockerHub</h3><p>Assuming that you have already Docker installed on your machine (if not you can follow the guide <a href="https://docs.docker.com/engine/install/">here</a>), the first step is to find an image that will serve as a base. Luckily, official ROS images are released and regularly updated as soon as a new version comes in. However, they are dispersed in multiple repository on DockerHub and it is sometime confusing to understand which image you need.</p><h4>The official ROS repository on DockerHub</h4><p><a href="https://hub.docker.com/_/ros?tab=description"><strong>ros</strong> on DockerHub</a> contains all the images you need to create your application. If you are familiar with ROS nomenclature, you will find again the bare-bones or core version of each release. Be aware that they do not include all the tools like rviz or gazebo you might need (those tools actually need some tricks to work in Docker, we will cover this in Part 2 of this tutorial series). If you are unsure, we recommend you to simply use the full version. It is easy to recognize them, their tags are simply the name of the ROS version you are looking for. For example, if you need <strong>noetic</strong>, the latest version of ROS simply do:</p><pre>docker pull ros:noetic</pre><p>Here you are, you have downloaded a full working version of ROS noetic. Using it in practice it not that easy, we will come back to this. ROS2 images are also available and are just as easy to get.</p><h4>Nightly images</h4><p>If you are a developer and want to use the latest version before it is even officially released you might be interested in the nightly versions. Those are located in different repositories. For ROS1 you will need to go to <a href="https://hub.docker.com/r/osrf/ros">osrf/ros</a> and for ROS2 to <a href="https://hub.docker.com/r/osrf/ros2">osrf/ros2</a>. The rest is similar and the images are used in the same way.</p><p>All good. Now let&#39;s see how we can actually use them and create our ROS workspace.</p><h3>Setting up a ROS workspace in a container</h3><p>If you are here, it is to actually do something with those images. When you install ROS on your computer, you usually create a ROS workspace. So, we will do exactly that, but inside a Docker container.</p><p>Let us start by creating a Dockerfile that will contain all the installation steps. The first thing is to decide which base image to use:</p><pre>FROM ros:kinetic</pre><p>Now if you want to be a bit more generic you can use Docker ARG command:</p><pre>ARG BASE_IMAGE=ros<br>ARG BASE_TAG=noetic</pre><pre>FROM ${BASE_IMAGE}:${BASE_TAG}</pre><p>The first two lines are to set a default version, but we will see later how to pass the arguments when building the image. Then, we want to specify that the shell is not interactive. We had some issues in the past when building our images and this helped a lot. It prevents bash to ask for user input, that would break the building process otherwise.</p><pre>ENV DEBIAN_FRONTEND=noninteractive</pre><p>By default Docker creates the container as root. We do not recommend that for using ROS and it is much better to create a user in the container that share the same rights as the host user. This is especially better if you use this image for development. So we start by installing sudo and creating a new user:</p><pre>RUN apt-get update &amp;&amp; apt-get install -y \<br> wget \<br> git \<br> bash-completion \<br> build-essential \<br> sudo \<br> &amp;&amp; rm -rf /var/lib/apt/lists/*</pre><pre># Now create the same user as the host itself<br>ARG UID=1000<br>ARG GID=1000<br>RUN addgroup --gid ${GID} ros<br>RUN adduser --gecos &quot;ROS User&quot; --disabled-password --uid ${UID} --gid ${GID} ros<br>RUN usermod -a -G dialout rosADD config/99_aptget /etc/sudoers.d/99_aptget<br>RUN chmod 0440 /etc/sudoers.d/99_aptget &amp;&amp; chown root:root /etc/sudoers.d/99_aptget</pre><p>As you have noticed we also install some packages like git or wget. Everytime we install a package we clear the apt cache with</p><pre>rm -rf /var/lib/apt/lists/*</pre><p>It reduces the image size and is good practice to do, especially when combined with grouped installation of all the packages at the beginning of the Dockerfile. The second part takes care creating a user with the same UID and GID as the host user. Those will be specified at build time. As you can see, we also use a set of config files to setup the user. You can create a config folder and copy the following:</p><pre>mkdir config<br>echo &quot;ros ALL=(ALL) NOPASSWD: ALL&quot; &gt; config/99_aptget</pre><p>This will allow the creation of the user without a password. Now let&#39;s create the workspace:</p><pre># Choose to run as user<br>ENV USER ros<br>USER ros </pre><pre># Change HOME environment variable<br>ENV HOME /home/${USER} </pre><pre># workspace setup<br>RUN mkdir -p ${HOME}/ros_ws/src</pre><p>The next lines will initialize the workspace and they will be different whether you are using ROS1 or ROS2. Let us start with ROS1:</p><pre>WORKDIR ${HOME}/ros_ws/src<br>RUN /bin/bash -c &quot;source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_init_workspace&quot;<br>WORKDIR ${HOME}/ros_ws<br>/bin/bash -c &quot;source source /opt/ros/${ROS_DISTRO}/setup.bash; catkin_make&quot;</pre><p>${ROS_DISTRO} is an environment variable already defined by ROS so you don&#39;t need to modify it. Voila, your workspace is now initialized and compiled. If you are using ROS2 images you would do:</p><pre>WORKDIR ${HOME}/ros_ws<br>/bin/bash -c &quot;source source /opt/ros/${ROS_DISTRO}/setup.bash; colcon build --symlink-install&quot;</pre><p>Finally, we need to setup the environment variables and modifying the <strong>bashrc</strong> file as we would do in a normal installation.</p><pre># set up environment<br>COPY config/update_bashrc /sbin/update_bashrc<br>RUN sudo chmod +x /sbin/update_bashrc ; sudo chown ros /sbin/update_bashrc ; sync ; /bin/bash -c /sbin/update_bashrc ; sudo rm /sbin/update_bashrc</pre><pre># Change entrypoint to source ~/.bashrc and start in ~<br>COPY config/entrypoint.sh /ros_entrypoint.sh<br>RUN sudo chmod +x /ros_entrypoint.sh ; sudo chown ros /ros_entrypoint.sh ;</pre><p>We use two scripts here that you can copy paste and put in the <strong>config</strong> folder. First, we start with <strong>entrypoint.sh</strong>:</p><pre>#!/bin/bash<br>set -e </pre><pre># setup environment<br>source $HOME/.bashrc </pre><pre># start in home directory <br>cd  <br>exec bash -i -c $@</pre><p>And last but not least a script to modify the bashrc:</p><pre># Adding all the necessary ros sourcing<br>echo &quot;&quot; &gt;&gt; ~/.bashrc<br>echo &quot;## ROS&quot; &gt;&gt; ~/.bashrc<br>echo &quot;source /opt/ros/$ROS_DISTRO/setup.bash&quot; &gt;&gt; ~/.bashrc<br>echo &quot;source ~/ros_ws/devel/setup.bash&quot; &gt;&gt; ~/.bashrc</pre><p>Note that for ROS2, the last line should be changed to:</p><pre>echo &quot;source /home/ros/ros_ws/install/setup.bash&quot; &gt;&gt; ~/.bashrc</pre><p>We finish by a bit of cleaning and by calling the entrypoint:</p><pre># Clean image<br>RUN sudo apt-get clean &amp;&amp; sudo rm -rf /var/lib/apt/lists/* </pre><pre>ENTRYPOINT [&quot;/ros_entrypoint.sh&quot;]<br>CMD [&quot;bash&quot;]</pre><p>Now, to compile the image you will need to invoke the docker build command. As it will include some arguments we recommend to create a script. We usually put a script build.sh alongside our Dockerfile containing:</p><pre>REBUILD=0<br>while getopts &#39;r&#39; opt; do<br>  case $opt in<br>    r) REBUILD=1 ;;<br>    *) echo &#39;Error in command line parsing&#39; &gt;&amp;2<br>      exit 1<br>    esac<br>done<br>shift &quot;$(( OPTIND - 1 ))&quot; </pre><pre>if [ $# -eq 0 ] ; then<br>  echo &#39;Specifiy the ros distrib to use: e.g. melodic, noetic...<br>fi </pre><pre>BASE_IMAGE=ros<br>BASE_TAG=$1</pre><pre>docker pull ${BASE_IMAGE}:${BASE_TAG}</pre><pre>NAME=ros_ws</pre><pre>UID=&quot;$(id -u $USER)&quot;<br>GID=&quot;$(id -g $USER)&quot; </pre><pre>if [ &quot;$REBUILD&quot; -eq 1 ]; then<br>  docker build \<br>  --no-cache \<br>  --build-arg BASE_IMAGE=${BASE_IMAGE} \<br>  --build-arg BASE_TAG=${BASE_TAG} \<br>  --build-arg UID=${UID} \<br>  --build-arg GID=${GID} \<br>  -t ${NAME}:${BASE_TAG} .<br>else<br>  docker build \<br>  --build-arg BASE_IMAGE=${BASE_IMAGE} \<br>  --build-arg BASE_TAG=${BASE_TAG} \<br>  --build-arg UID=${UID} \<br>  --build-arg GID=${GID} \<br>  -t ${NAME}:${BASE_TAG} .<br>fi</pre><p>The first block handles the possibility to rebuild the image from scratch (along with the <strong>no-cache</strong> option in docker build). This can be useful, especially when you clone repositories in the container and you know that a new version of them is available. Without this, Docker will simply use the cache and you will not pull the latest version of your repositories. Then, the script also let you choose which ROS version to use as base image. Finally, the <strong>docker pull</strong> command is not necessarily needed as Docker will automatically download the latest version if not present on your computer. However, it will not update it if you already have it, preventing you to get the latest updates. Using this docker pull ensures that you always have the latest version of the image.</p><p>And here you are, a fully compiled workspace for both ROS and ROS2. Now, to be useful we need to be able to add packages in there. So let&#39;s do that.</p><h3>Mounting volumes and run script</h3><p>For a workspace to be functional you might want to create a folder, shared between the host and the docker container. We usually create a source folder that will be mounted at runtime. In order to simplify the runtime command you might want to create a run script:</p><pre>#!/bin/bash<br>NAME=ros_ws # replace by the name of your image<br>TAG=noetic # the tag of your built image</pre><pre>mkdir -p source</pre><pre># create a shared volume to store the ros_ws<br>docker volume create --driver local \<br>    --opt type=&quot;none&quot; \<br>    --opt device=&quot;${PWD}/source/&quot; \<br>    --opt o=&quot;bind&quot; \<br>    &quot;${NAME}_src_vol&quot;<br><br>xhost +<br>docker run \<br>    --net=host \<br>    -it \<br>    --rm \<br>    --volume=&quot;${NAME}_src_vol:/home/ros/ros_ws/src/:rw&quot; \<br>    &quot;${NAME}:${TAG}&quot;</pre><p>The workspace will be directly mounted and matched to ros_ws/src folder in the container. In the run command we also use the <strong>net=host</strong> argument to share the same network as the host machine. The <strong>-it</strong> argument will start an interactive shell in the container when running the script. You could also directly call a command like <strong>roslaunch </strong>or <strong>roscore</strong>. In that case, you simply need to put it after the “${NAME}:${TAG}”.</p><p>Go ahead and try to put a package in the source folder. You will see it appearing on both the host and the container and you will be able to invoke catkin (or colcon) in the container to build your workspace. Now, if you want to have it directly built when building the image you need to add the following lines to your Dockerfile just before building the workspace:</p><pre>WORKDIR ${HOME}/ros_ws/<br>COPY --chown=${USER} ./source/ ./src/</pre><p>Note that every time you modify or add something in the source folder, Docker will notice the changes and will reinvoke the <strong>COPY</strong> command at build time, creating a new version of the image. This can quickly take some disk usage. Remember to monitor this and to clean the old version of your images:</p><pre>Docker system prune</pre><p>With all this you have a fully functional ROS workspace, with the ROS version of your choice, that you can deploy in minutes.</p><p>What’s next? Well, if you try to start rviz in the container, it will simply fail. For applications that needs to have access to the X server you need some extra commands. We will cover this in Part 2 of this tutorial.</p><p>We are looking forward to your comments and have fun deploying your workspaces.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=912529c87708" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>