{"id":3494,"date":"2025-07-29T14:09:03","date_gmt":"2025-07-29T14:09:03","guid":{"rendered":"https:\/\/learnbydoing.dev\/?p=3494"},"modified":"2026-01-10T22:05:03","modified_gmt":"2026-01-10T22:05:03","slug":"building-smarter-robots-with-behavior-trees-in-ros-2","status":"publish","type":"post","link":"https:\/\/learnbydoing.dev\/building-smarter-robots-with-behavior-trees-in-ros-2\/","title":{"rendered":"Building Smarter Robots with Behavior Trees in ROS 2"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"3494\" class=\"elementor elementor-3494\" data-elementor-post-type=\"post\">\n\t\t\t\t<div class=\"elementor-element elementor-element-e28ab35 e-flex e-con-boxed e-con e-parent\" data-id=\"e28ab35\" data-element_type=\"container\" data-e-type=\"container\" id=\"content\" data-settings=\"{&quot;background_background&quot;:&quot;classic&quot;}\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t<div class=\"elementor-element elementor-element-62ab6e3 e-con-full e-flex e-con e-child\" data-id=\"62ab6e3\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t<div class=\"elementor-element elementor-element-62ab203 elementor-align-center elementor-widget elementor-widget-post-info\" data-id=\"62ab203\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"post-info.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<ul class=\"elementor-inline-items elementor-icon-list-items elementor-post-info\">\n\t\t\t\t\t\t\t\t<li class=\"elementor-icon-list-item elementor-repeater-item-2c98363 elementor-inline-item\" itemprop=\"about\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"elementor-icon-list-text elementor-post-info__item elementor-post-info__item--type-terms\">\n\t\t\t\t\t\t\t\t\t\t<span class=\"elementor-post-info__terms-list\">\n\t\t\t\t<span class=\"elementor-post-info__terms-list-item\">Nav2<\/span>, <span class=\"elementor-post-info__terms-list-item\">ROS 2<\/span>, <span class=\"elementor-post-info__terms-list-item\">Tutorials<\/span>\t\t\t\t<\/span>\n\t\t\t\t\t<\/span>\n\t\t\t\t\t\t\t\t<\/li>\n\t\t\t\t<\/ul>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-0650e10 e-con-full e-flex e-con e-child\" data-id=\"0650e10\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t<div class=\"elementor-element elementor-element-ac19582 elementor-view-default elementor-widget elementor-widget-icon\" data-id=\"ac19582\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"icon.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-icon-wrapper\">\n\t\t\t<div class=\"elementor-icon\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"75\" height=\"75\" viewBox=\"0 0 75 75\" fill=\"none\"><path d=\"M74.9999 75H13.1889V73.0002H71.5859L0.460938 1.87521L1.87515 0.460999L73.0001 71.586V13.1889H74.9999V75Z\" fill=\"white\"><\/path><\/svg>\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-47aa245d e-flex e-con-boxed e-con e-parent\" data-id=\"47aa245d\" data-element_type=\"container\" data-e-type=\"container\" data-settings=\"{&quot;background_background&quot;:&quot;classic&quot;}\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-206a001 elementor-widget elementor-widget-image\" data-id=\"206a001\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img fetchpriority=\"high\" decoding=\"async\" width=\"1920\" height=\"1080\" src=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/Titolo-_7_.webp\" class=\"attachment-full size-full wp-image-3501\" alt=\"\" srcset=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/Titolo-_7_.webp 1920w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/Titolo-_7_-300x169.webp 300w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/Titolo-_7_-1024x576.webp 1024w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/Titolo-_7_-768x432.webp 768w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/Titolo-_7_-1536x864.webp 1536w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/Titolo-_7_-18x10.webp 18w\" sizes=\"(max-width: 1920px) 100vw, 1920px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-4bc31ca3 elementor-widget elementor-widget-text-editor\" data-id=\"4bc31ca3\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Discover how Behavior Trees can help you structure intelligent robot behaviors in ROS 2 using modular logic, clear control flow, and intuitive tools like Groot.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-12a4ca0 elementor-widget elementor-widget-text-editor\" data-id=\"12a4ca0\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h3 data-section-id=\"197j9kl\" data-start=\"628\" data-end=\"666\"><strong>\ud83e\udd16 Why Behavior Matters in Robotics<\/strong><\/h3><p data-start=\"732\" data-end=\"1018\">Robots that operate in the real world face much more than just navigation tasks. They need to handle dynamic environments, unpredictable humans, and ambiguous situations.<br data-start=\"902\" data-end=\"905\" \/>Think about it: people step in front of delivery bots, block them for fun, or push them just to see what happens.<br \/><br \/><\/p><p data-start=\"1099\" data-end=\"1280\">How can we design robots that are both reliable and flexible in the face of such chaos?<br data-start=\"1186\" data-end=\"1189\" \/>The answer is <strong data-start=\"1203\" data-end=\"1244\">modular, visual, fault-tolerant logic <\/strong>&#8211;\u00a0in other words, <strong data-start=\"1261\" data-end=\"1279\">Behavior Trees<\/strong>.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-ed2c3b3 elementor-widget elementor-widget-image\" data-id=\"ed2c3b3\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" width=\"800\" height=\"450\" src=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/1-1-1024x576.webp\" class=\"attachment-large size-large wp-image-3496\" alt=\"\" srcset=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/1-1-1024x576.webp 1024w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/1-1-300x169.webp 300w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/1-1-768x432.webp 768w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/1-1-1536x864.webp 1536w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/1-1-18x10.webp 18w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/1-1.webp 1920w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-e83840a elementor-widget elementor-widget-text-editor\" data-id=\"e83840a\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h3 data-section-id=\"1xaker4\" data-start=\"1287\" data-end=\"1317\"><strong><img decoding=\"async\" draggable=\"false\" role=\"img\" class=\"emoji\" alt=\"\ud83c\udf33\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/16.0.1\/svg\/1f333.svg\"> What Are Behavior Trees?<\/strong><\/h3>\n<p data-start=\"1319\" data-end=\"1574\">Behavior Trees (BTs) originated in game development, but quickly became a favorite in robotics because of their flexibility and readability. They allow us to <strong data-start=\"1477\" data-end=\"1494\">compose logic<\/strong> in a structured way using nodes that are easy to understand, reuse, and extend.<\/p>\n<p data-start=\"1576\" data-end=\"1607\">A Behavior Tree is composed of:<\/p>\n<ul data-start=\"1608\" data-end=\"1888\">\n<li data-start=\"1608\" data-end=\"1648\">\n<p data-start=\"1610\" data-end=\"1648\"><strong data-start=\"1610\" data-end=\"1626\">Action Nodes<\/strong>: they perform tasks<\/p>\n<\/li>\n<li data-start=\"1649\" data-end=\"1707\">\n<p data-start=\"1651\" data-end=\"1707\"><strong data-start=\"1651\" data-end=\"1670\">Condition Nodes<\/strong>: they check the state of the world<\/p>\n<\/li>\n<li data-start=\"1708\" data-end=\"1794\">\n<p data-start=\"1710\" data-end=\"1794\"><strong data-start=\"1710\" data-end=\"1727\">Control Nodes<\/strong>: they decide how to organize children (e.g., Sequence, Fallback)<\/p>\n<\/li>\n<li data-start=\"1795\" data-end=\"1888\">\n<p data-start=\"1797\" data-end=\"1888\"><strong data-start=\"1797\" data-end=\"1816\">Decorator Nodes<\/strong>: they modify the behavior of a single child (e.g., Retry, ForceFailure)<br><br><\/p>\n<\/li>\n<\/ul>\n<p data-start=\"1890\" data-end=\"1988\">Like LEGO bricks, you can combine these nodes to build behavior that is both powerful and modular.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-2341325 elementor-widget elementor-widget-image\" data-id=\"2341325\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" width=\"800\" height=\"450\" src=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/2-1-1024x576.webp\" class=\"attachment-large size-large wp-image-3497\" alt=\"\" srcset=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/2-1-1024x576.webp 1024w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/2-1-300x169.webp 300w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/2-1-768x432.webp 768w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/2-1-1536x864.webp 1536w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/2-1-18x10.webp 18w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/2-1.webp 1920w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-3ea2dda elementor-widget elementor-widget-text-editor\" data-id=\"3ea2dda\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h3 data-section-id=\"1gol52i\" data-start=\"1995\" data-end=\"2049\"><strong>\ud83e\uddea Let\u2019s Build Our First Behavior Tree (with Groot)<\/strong><\/h3><p data-start=\"2051\" data-end=\"2213\">Once you understand the theory, the next step is <strong data-start=\"2100\" data-end=\"2121\">hands-on practice<\/strong>.<br data-start=\"2122\" data-end=\"2125\" \/>To create and manage Behavior Trees easily, we\u2019ll use a graphical tool called <strong data-start=\"2203\" data-end=\"2212\">Groot<\/strong>.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-9db121f elementor-widget elementor-widget-text-editor\" data-id=\"9db121f\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h5 data-section-id=\"19xi414\" data-start=\"2220\" data-end=\"2243\"><strong>\ud83e\uddf0 Installing Groot<\/strong><\/h5><p data-start=\"2245\" data-end=\"2320\">Open a terminal and run the following commands to install and launch Groot:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-66d9afa elementor-widget elementor-widget-code-highlight\" data-id=\"66d9afa\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-tomorrow copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-bash \">\n\t\t\t\t<code readonly=\"true\" class=\"language-bash\">\n\t\t\t\t\t<xmp>cd ~\/Downloads\r\nchmod +x Groot2*.AppImage\r\n.\/Groot2*.AppImage\r\n<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-2fdbdeb elementor-widget elementor-widget-text-editor\" data-id=\"2fdbdeb\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h5 data-section-id=\"19xi414\" data-start=\"2220\" data-end=\"2243\"><strong>\ud83d\udce5 Import Nav2 Node Models<\/strong><\/h5><p data-start=\"2245\" data-end=\"2320\">Before you start building your navigation logic, you need to import the Nav2 node models into Groot.<br data-start=\"2986\" data-end=\"2989\" \/>You can do this via the GUI by selecting <code data-start=\"3030\" data-end=\"3045\">Import Models<\/code> and choosing:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-ada3d44 elementor-widget elementor-widget-code-highlight\" data-id=\"ada3d44\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-tomorrow copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-swift \">\n\t\t\t\t<code readonly=\"true\" class=\"language-swift\">\n\t\t\t\t\t<xmp>\/opt\/ros\/jazzy\/share\/nav2_behavior_tree\/behavior_tree_nodes.xml\r\n<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-3913ca5 elementor-widget elementor-widget-text-editor\" data-id=\"3913ca5\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p data-start=\"3134\" data-end=\"3173\">After this step, you\u2019ll see nodes like:<\/p><ul data-start=\"3174\" data-end=\"3243\"><li data-start=\"3174\" data-end=\"3195\"><p data-start=\"3176\" data-end=\"3195\"><code data-start=\"3176\" data-end=\"3195\">ComputePathToPose<\/code><\/p><\/li><li data-start=\"3196\" data-end=\"3210\"><p data-start=\"3198\" data-end=\"3210\"><code data-start=\"3198\" data-end=\"3210\">FollowPath<\/code><\/p><\/li><li data-start=\"3211\" data-end=\"3227\"><p data-start=\"3213\" data-end=\"3227\"><code data-start=\"3213\" data-end=\"3227\">IsBatteryLow<\/code><\/p><\/li><li data-start=\"3228\" data-end=\"3243\"><p data-start=\"3230\" data-end=\"3243\">and many more<\/p><\/li><\/ul><p data-start=\"3245\" data-end=\"3298\">Now you\u2019re ready to build your first navigation tree.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-fef741f elementor-widget elementor-widget-text-editor\" data-id=\"fef741f\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h3 data-section-id=\"vsralv\" data-start=\"3305\" data-end=\"3343\"><strong>\ud83d\udee3\ufe0f Create a Simple Navigation Tree<\/strong><\/h3><p data-start=\"3345\" data-end=\"3396\">Let\u2019s build a tree where the robot does two things:<\/p><ol data-start=\"3397\" data-end=\"3446\"><li data-start=\"3397\" data-end=\"3426\"><p data-start=\"3400\" data-end=\"3426\">Compute a path to a goal<\/p><\/li><li data-start=\"3427\" data-end=\"3446\"><p data-start=\"3430\" data-end=\"3446\">Follow that path<\/p><\/li><\/ol>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-afaf0fb elementor-widget elementor-widget-text-editor\" data-id=\"afaf0fb\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h4 data-section-id=\"s44bmi\" data-start=\"3453\" data-end=\"3477\"><strong>\ud83c\udf33 Behavior Tree XML<\/strong><\/h4><p data-start=\"3479\" data-end=\"3510\">Here\u2019s the full XML definition:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-2438008 elementor-widget elementor-widget-code-highlight\" data-id=\"2438008\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-tomorrow copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-xml \">\n\t\t\t\t<code readonly=\"true\" class=\"language-xml\">\n\t\t\t\t\t<xmp><root main_tree_to_execute=\"MainTree\">\r\n  <BehaviorTree ID=\"MainTree\">\r\n    <Sequence name=\"navigate_to_goal\">\r\n      <ComputePathToPose goal=\"{goal}\" planner_id=\"GridBased\" path=\"{path}\"\/>\r\n      <FollowPath path=\"{path}\" controller_id=\"FollowPath\"\/>\r\n    <\/Sequence>\r\n  <\/BehaviorTree>\r\n<\/root>\r\n<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-3774990 elementor-widget elementor-widget-text-editor\" data-id=\"3774990\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p data-start=\"76\" data-end=\"316\">This Behavior Tree defines a simple sequence to navigate the robot to a goal. The main tree is <code data-start=\"171\" data-end=\"183\">\"MainTree\"<\/code>, and it runs a <strong data-start=\"199\" data-end=\"211\">Sequence<\/strong> node called <code data-start=\"224\" data-end=\"244\">\"navigate_to_goal\"<\/code>, which executes its children one by one until one fails or all succeed.<\/p><p data-start=\"318\" data-end=\"347\">The sequence has two actions:<\/p><ol data-start=\"349\" data-end=\"612\"><li data-start=\"349\" data-end=\"491\"><p data-start=\"352\" data-end=\"491\"><strong data-start=\"352\" data-end=\"373\">ComputePathToPose<\/strong>: calculates a path from the robot to the target (<code data-start=\"423\" data-end=\"431\">{goal}<\/code>) using the <code data-start=\"443\" data-end=\"456\">\"GridBased\"<\/code> planner and stores it in <code data-start=\"482\" data-end=\"490\">{path}<\/code>.<\/p><\/li><li data-start=\"492\" data-end=\"612\"><p data-start=\"495\" data-end=\"612\"><strong data-start=\"495\" data-end=\"509\">FollowPath<\/strong>: takes the generated <code data-start=\"531\" data-end=\"539\">{path}<\/code> and commands the robot to follow it using the <code data-start=\"586\" data-end=\"600\">\"FollowPath\"<\/code> controller.<br \/><br \/><\/p><\/li><\/ol><p data-start=\"614\" data-end=\"710\" data-is-last-node=\"\" data-is-only-node=\"\">If both actions succeed, the sequence returns success; otherwise, it stops at the first failure.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-ca2a4ca elementor-widget elementor-widget-text-editor\" data-id=\"ca2a4ca\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h3 data-section-id=\"g8wq45\" data-start=\"5036\" data-end=\"5067\"><strong>\u2699\ufe0f Connect the Tree to ROS 2<\/strong><\/h3><p data-start=\"5069\" data-end=\"5116\">Let\u2019s now tell ROS 2 to actually use this tree.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-4cd295b elementor-widget elementor-widget-text-editor\" data-id=\"4cd295b\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h4 data-section-id=\"lwtd1e\" data-start=\"5123\" data-end=\"5147\"><strong>\ud83d\udcbe Save the XML file<\/strong><\/h4><p data-start=\"5149\" data-end=\"5181\">Save the previous XML code into:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-cc3cc9c elementor-widget elementor-widget-code-highlight\" data-id=\"cc3cc9c\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-tomorrow copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-bash \">\n\t\t\t\t<code readonly=\"true\" class=\"language-bash\">\n\t\t\t\t\t<xmp>bumperbot_navigation\/behavior_tree\/simple_navigation.xml\r\n<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-034382e elementor-widget elementor-widget-text-editor\" data-id=\"034382e\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h4 data-section-id=\"351e6j\" data-start=\"5254\" data-end=\"5282\"><strong>\ud83d\udce6 Modify CMakeLists.txt<\/strong><\/h4><p data-start=\"5284\" data-end=\"5360\">Add this line to your <code data-start=\"5306\" data-end=\"5322\">CMakeLists.txt<\/code> file to ensure the tree is installed:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-dd8836f elementor-widget elementor-widget-code-highlight\" data-id=\"dd8836f\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-tomorrow copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-bash \">\n\t\t\t\t<code readonly=\"true\" class=\"language-bash\">\n\t\t\t\t\t<xmp>install(DIRECTORY behavior_tree\/\r\n  DESTINATION share\/${PROJECT_NAME}\/behavior_tree)\r\n<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-d3ef885 elementor-widget elementor-widget-text-editor\" data-id=\"d3ef885\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>This tells ROS 2 to install the entire <code data-start=\"5637\" data-end=\"5652\">behavior_tree<\/code> folder into the share directory of your package so it\u2019s available at runtime.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-85025c1 elementor-widget elementor-widget-text-editor\" data-id=\"85025c1\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h4 data-section-id=\"cthzwq\" data-start=\"5737\" data-end=\"5776\"><strong>\ud83d\udd27 Configure the Behavior Tree path<\/strong><\/h4><p data-start=\"5778\" data-end=\"5824\">Edit your <code data-start=\"5788\" data-end=\"5807\">bt_navigator.yaml<\/code> file to include:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-e86d19f elementor-widget elementor-widget-code-highlight\" data-id=\"e86d19f\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-tomorrow copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-bash \">\n\t\t\t\t<code readonly=\"true\" class=\"language-bash\">\n\t\t\t\t\t<xmp>default_nav_to_pose_bt_xml: \"\/home\/alien\/bumperbot_ws\/src\/bumperbot_navigation\/behavior_tree\/simple_navigation.xml\"\r\n<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-44931c5 elementor-widget elementor-widget-text-editor\" data-id=\"44931c5\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>This sets the Behavior Tree file that Nav2 will load when the <code data-start=\"6102\" data-end=\"6116\">bt_navigator<\/code> node starts.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-22ada43 elementor-widget elementor-widget-text-editor\" data-id=\"22ada43\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h3 data-section-id=\"1aepgh9\" data-start=\"6136\" data-end=\"6175\"><strong>\ud83d\ude80 Launch the Behavior Tree in ROS 2<\/strong><\/h3><p data-start=\"6177\" data-end=\"6256\">We need to include the <code data-start=\"6200\" data-end=\"6214\">bt_navigator<\/code> node in your <code data-start=\"6228\" data-end=\"6250\">navigation.launch.py<\/code> file.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-073c7ea elementor-widget elementor-widget-text-editor\" data-id=\"073c7ea\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h4><strong>\ud83d\udc0d Add this node<\/strong><\/h4>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-3f4edde elementor-widget elementor-widget-code-highlight\" data-id=\"3f4edde\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-tomorrow copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-python line-numbers\">\n\t\t\t\t<code readonly=\"true\" class=\"language-python\">\n\t\t\t\t\t<xmp>nav2_bt_navigator = Node(\r\n    package=\"nav2_bt_navigator\",\r\n    executable=\"bt_navigator\",\r\n    name=\"bt_navigator\",\r\n    output=\"screen\",\r\n    parameters=[\r\n        os.path.join(\r\n            bumperbot_navigation_pkg,\r\n            \"config\",\r\n            \"bt_navigator.yaml\"),\r\n        {\"use_sim_time\": use_sim_time}\r\n    ],\r\n)\r\n\r\nlifecycle_nodes = [\"controller_server\", \"planner_server\", \"smoother_server\", \"bt_navigator\"]\r\n<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-5faa2cd elementor-widget elementor-widget-text-editor\" data-id=\"5faa2cd\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p data-start=\"64\" data-end=\"314\">This snippet launches the <code data-start=\"90\" data-end=\"104\">bt_navigator<\/code> node from the <code data-start=\"119\" data-end=\"138\">nav2_bt_navigator<\/code> package. The <strong data-start=\"152\" data-end=\"166\">executable<\/strong> is specified as <code data-start=\"183\" data-end=\"199\">\"bt_navigator\"<\/code>, and the <strong data-start=\"209\" data-end=\"222\">node name<\/strong> is also set to <code data-start=\"238\" data-end=\"254\">\"bt_navigator\"<\/code>. Output is directed to the terminal with <code data-start=\"296\" data-end=\"313\">output=\"screen\"<\/code>.<\/p><p data-start=\"316\" data-end=\"584\" data-is-last-node=\"\" data-is-only-node=\"\">It includes a list of <strong data-start=\"338\" data-end=\"352\">parameters<\/strong>, such as the YAML config file and a flag to use simulation time. Finally, the node is added to <code data-start=\"448\" data-end=\"465\">lifecycle_nodes<\/code> so it\u2019s managed automatically by the lifecycle manager\u2014ensuring it\u2019s properly configured and activated during startup.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-8859d24 elementor-widget elementor-widget-text-editor\" data-id=\"8859d24\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h3 data-section-id=\"1ufkb8l\" data-start=\"7413\" data-end=\"7432\"><strong>\ud83e\uddea Build and Run<\/strong><\/h3><p data-start=\"7434\" data-end=\"7477\">Now build the workspace and run everything:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-ef11d63 elementor-widget elementor-widget-code-highlight\" data-id=\"ef11d63\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-tomorrow copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-bash \">\n\t\t\t\t<code readonly=\"true\" class=\"language-bash\">\n\t\t\t\t\t<xmp>cd bumperbot_ws\r\ncolcon build\r\n\r\n. install\/setup.bash\r\nros2 launch bumperbot_bringup simulated_robot.launch.py world_name:=small_house\r\n\r\n. install\/setup.bash\r\nros2 launch bumperbot_navigation navigation.launch.py\r\n<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-bd66ae3 elementor-widget elementor-widget-text-editor\" data-id=\"bd66ae3\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h3 data-section-id=\"2ridkf\" data-start=\"8244\" data-end=\"8280\"><strong>\ud83e\udded Visualize the Robot\u2019s Behavior<\/strong><\/h3><p data-start=\"8282\" data-end=\"8332\">Open RViz and load the default Nav2 configuration:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-073770e elementor-widget elementor-widget-code-highlight\" data-id=\"073770e\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-tomorrow copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-swift \">\n\t\t\t\t<code readonly=\"true\" class=\"language-swift\">\n\t\t\t\t\t<xmp>\/opt\/ros\/jazzy\/share\/nav2_bringup\/rviz\/nav2_default_view.rviz\r\n<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-1e5bb77 elementor-widget elementor-widget-text-editor\" data-id=\"1e5bb77\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p data-start=\"8405\" data-end=\"8470\">Use the <strong data-start=\"8413\" data-end=\"8426\">Nav2 Goal<\/strong> tool to send a target pose. The robot will:<\/p><ul data-start=\"8471\" data-end=\"8572\"><li data-start=\"8471\" data-end=\"8484\"><p data-start=\"8473\" data-end=\"8484\">Plan a path<\/p><\/li><li data-start=\"8485\" data-end=\"8502\"><p data-start=\"8487\" data-end=\"8502\">Follow the path<\/p><\/li><li data-start=\"8503\" data-end=\"8572\"><p data-start=\"8505\" data-end=\"8572\">And if the path is invalid, the tree will return <code data-start=\"8554\" data-end=\"8563\">FAILURE<\/code> and stop<\/p><\/li><\/ul>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-2a1a9f5 elementor-widget elementor-widget-text-editor\" data-id=\"2a1a9f5\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h3 data-section-id=\"p320wl\" data-start=\"8579\" data-end=\"8595\"><strong>\ud83c\udfaf Conclusion<\/strong><\/h3><p data-start=\"8597\" data-end=\"8764\">Behavior Trees give us a powerful way to write robust and reusable logic for autonomous robots.<br data-start=\"8692\" data-end=\"8695\" \/>By using Groot, ROS 2, and Nav2\u2019s BT system, we can build logic that:<\/p><ul data-start=\"8765\" data-end=\"8889\"><li data-start=\"8765\" data-end=\"8785\"><p data-start=\"8767\" data-end=\"8785\">Fails gracefully<\/p><\/li><li data-start=\"8786\" data-end=\"8820\"><p data-start=\"8788\" data-end=\"8820\">Can be visualized and debugged<\/p><\/li><li data-start=\"8821\" data-end=\"8889\"><p data-start=\"8823\" data-end=\"8889\">Is easy to extend with recovery behaviors, safety checks, and more<\/p><\/li><\/ul>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-c5d20e7 e-con-full e-flex e-con e-parent\" data-id=\"c5d20e7\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t<div class=\"elementor-element elementor-element-0741169 elementor-bg-transform elementor-bg-transform-move-left elementor-cta--layout-image-left elementor-cta--mobile-layout-image-above elementor-cta--skin-classic elementor-animated-content elementor-widget elementor-widget-call-to-action\" data-id=\"0741169\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"call-to-action.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-cta\">\n\t\t\t\t\t<div class=\"elementor-cta__bg-wrapper\">\n\t\t\t\t<div class=\"elementor-cta__bg elementor-bg\" style=\"background-image: url(https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/plan_navigation.webp);\" role=\"img\" aria-label=\"plan_navigation\"><\/div>\n\t\t\t\t<div class=\"elementor-cta__bg-overlay\"><\/div>\n\t\t\t<\/div>\n\t\t\t\t\t\t\t<div class=\"elementor-cta__content\">\n\t\t\t\t\n\t\t\t\t\t\t\t\t\t<h2 class=\"elementor-cta__title elementor-cta__content-item elementor-content-item\">\n\t\t\t\t\t\tWant to learn more?\t\t\t\t\t<\/h2>\n\t\t\t\t\n\t\t\t\t\t\t\t\t\t<div class=\"elementor-cta__description elementor-cta__content-item elementor-content-item\">\n\t\t\t\t\t\tExplore Behavior Trees in ROS 2 and learn how to use them to express autonomous navigation logics in the \"Self Driving and ROS 2 - Learn by Doing! Plan &amp; Navigation\" course\t\t\t\t\t<\/div>\n\t\t\t\t\n\t\t\t\t\t\t\t\t\t<div class=\"elementor-cta__button-wrapper elementor-cta__content-item elementor-content-item \">\n\t\t\t\t\t<a class=\"elementor-cta__button elementor-button elementor-size-\" href=\"\" target=\"_blank\">\n\t\t\t\t\t\tEnroll Now\t\t\t\t\t<\/a>\n\t\t\t\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t\t\t<div class=\"elementor-ribbon elementor-ribbon-right\">\n\t\t\t\t<div class=\"elementor-ribbon-inner\">\n\t\t\t\t\tDISCOUNT\t\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-180426a elementor-widget elementor-widget-spacer\" data-id=\"180426a\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"spacer.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-spacer\">\n\t\t\t<div class=\"elementor-spacer-inner\"><\/div>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Discover how Behavior Trees can help you structure intelligent robot behaviors in ROS 2 using modular logic, clear control flow, and intuitive tools like Groot. \ud83e\udd16 Why Behavior Matters in Robotics Robots that operate in the real world face much more than just navigation tasks. They need to handle dynamic environments, unpredictable humans, and ambiguous [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":3501,"comment_status":"closed","ping_status":"open","sticky":false,"template":"elementor_theme","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[49,45,43],"tags":[272,112,129,87,275,276,125,179,66,181,96,131,141,98,100,75,274,71,107,72,273,76,271,64,73],"class_list":["post-3494","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-nav2","category-ros-2","category-tutorials","tag-behavior","tag-behavior-tree","tag-build","tag-guide","tag-implement","tag-iron","tag-jazzy","tag-lbd","tag-learn-by-doing","tag-nav","tag-nav2","tag-node","tag-py","tag-python","tag-robot","tag-robotics","tag-robots","tag-ros","tag-ros-2","tag-ros2","tag-smart","tag-step-by-step","tag-tree","tag-tutorial","tag-ubuntu"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Building Smarter Robots with Behavior Trees in ROS 2 - Learn by Doing!<\/title>\n<meta name=\"description\" content=\"Build smarter ROS 2 robots with Behavior Trees: explore modular logic, control flow, and Groot in a detailed, step-by-step tutorial\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/learnbydoing.dev\/es\/building-smarter-robots-with-behavior-trees-in-ros-2\/\" \/>\n<meta property=\"og:locale\" content=\"es_ES\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Building Smarter Robots with Behavior Trees in ROS 2 (Step-by-Step)\" \/>\n<meta property=\"og:description\" content=\"Build smarter ROS 2 robots with Behavior Trees: explore modular logic, control flow, and Groot in a detailed, step-by-step tutorial\" \/>\n<meta property=\"og:url\" content=\"https:\/\/learnbydoing.dev\/es\/building-smarter-robots-with-behavior-trees-in-ros-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Learn by Doing!\" \/>\n<meta property=\"article:published_time\" content=\"2025-07-29T14:09:03+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-01-10T22:05:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/Titolo-_7_.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Escrito por\" \/>\n\t<meta name=\"twitter:data1\" content=\"\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tiempo de lectura\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/building-smarter-robots-with-behavior-trees-in-ros-2\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/building-smarter-robots-with-behavior-trees-in-ros-2\\\/\"},\"author\":{\"name\":\"\",\"@id\":\"\"},\"headline\":\"Building Smarter Robots with Behavior Trees in ROS 2\",\"datePublished\":\"2025-07-29T14:09:03+00:00\",\"dateModified\":\"2026-01-10T22:05:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/building-smarter-robots-with-behavior-trees-in-ros-2\\\/\"},\"wordCount\":761,\"publisher\":{\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/es\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/building-smarter-robots-with-behavior-trees-in-ros-2\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/learnbydoing.dev\\\/wp-content\\\/uploads\\\/2025\\\/07\\\/Titolo-_7_.webp\",\"keywords\":[\"behavior\",\"behavior tree\",\"build\",\"Guide\",\"implement\",\"iron\",\"Jazzy\",\"lbd\",\"learn by doing\",\"nav\",\"nav2\",\"node\",\"py\",\"python\",\"robot\",\"Robotics\",\"robots\",\"ROS\",\"ROS 2\",\"ROS2\",\"smart\",\"step by step\",\"tree\",\"tutorial\",\"Ubuntu\"],\"articleSection\":[\"Nav2\",\"ROS 2\",\"Tutorials\"],\"inLanguage\":\"es\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/building-smarter-robots-with-behavior-trees-in-ros-2\\\/\",\"url\":\"https:\\\/\\\/learnbydoing.dev\\\/building-smarter-robots-with-behavior-trees-in-ros-2\\\/\",\"name\":\"Building Smarter Robots with Behavior Trees in ROS 2 - Learn by Doing!\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/es\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/building-smarter-robots-with-behavior-trees-in-ros-2\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/building-smarter-robots-with-behavior-trees-in-ros-2\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/learnbydoing.dev\\\/wp-content\\\/uploads\\\/2025\\\/07\\\/Titolo-_7_.webp\",\"datePublished\":\"2025-07-29T14:09:03+00:00\",\"dateModified\":\"2026-01-10T22:05:03+00:00\",\"description\":\"Build smarter ROS 2 robots with Behavior Trees: explore modular logic, control flow, and Groot in a detailed, step-by-step tutorial\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/building-smarter-robots-with-behavior-trees-in-ros-2\\\/#breadcrumb\"},\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/learnbydoing.dev\\\/building-smarter-robots-with-behavior-trees-in-ros-2\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/building-smarter-robots-with-behavior-trees-in-ros-2\\\/#primaryimage\",\"url\":\"https:\\\/\\\/learnbydoing.dev\\\/wp-content\\\/uploads\\\/2025\\\/07\\\/Titolo-_7_.webp\",\"contentUrl\":\"https:\\\/\\\/learnbydoing.dev\\\/wp-content\\\/uploads\\\/2025\\\/07\\\/Titolo-_7_.webp\",\"width\":1920,\"height\":1080},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/building-smarter-robots-with-behavior-trees-in-ros-2\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/learnbydoing.dev\\\/es\\\/learn-by-doing-es\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Building Smarter Robots with Behavior Trees in ROS 2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/es\\\/#website\",\"url\":\"https:\\\/\\\/learnbydoing.dev\\\/es\\\/\",\"name\":\"Learn by Doing!\",\"description\":\"Learn Robotics the fun way\",\"publisher\":{\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/es\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/learnbydoing.dev\\\/es\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"es\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/es\\\/#organization\",\"name\":\"Learn by Doing!\",\"url\":\"https:\\\/\\\/learnbydoing.dev\\\/es\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/es\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/learnbydoing.dev\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/cropped-Progetto-senza-titolo-6-1.png\",\"contentUrl\":\"https:\\\/\\\/learnbydoing.dev\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/cropped-Progetto-senza-titolo-6-1.png\",\"width\":512,\"height\":512,\"caption\":\"Learn by Doing!\"},\"image\":{\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/es\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/antonio-brandi-512166bb\\\/\"]},{\"@type\":\"Person\",\"@id\":\"\",\"url\":\"https:\\\/\\\/learnbydoing.dev\\\/es\\\/author\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Building Smarter Robots with Behavior Trees in ROS 2 - Learn by Doing!","description":"Build smarter ROS 2 robots with Behavior Trees: explore modular logic, control flow, and Groot in a detailed, step-by-step tutorial","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/learnbydoing.dev\/es\/building-smarter-robots-with-behavior-trees-in-ros-2\/","og_locale":"es_ES","og_type":"article","og_title":"Building Smarter Robots with Behavior Trees in ROS 2 (Step-by-Step)","og_description":"Build smarter ROS 2 robots with Behavior Trees: explore modular logic, control flow, and Groot in a detailed, step-by-step tutorial","og_url":"https:\/\/learnbydoing.dev\/es\/building-smarter-robots-with-behavior-trees-in-ros-2\/","og_site_name":"Learn by Doing!","article_published_time":"2025-07-29T14:09:03+00:00","article_modified_time":"2026-01-10T22:05:03+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/Titolo-_7_.webp","type":"image\/webp"}],"twitter_card":"summary_large_image","twitter_misc":{"Escrito por":"","Tiempo de lectura":"8 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/learnbydoing.dev\/building-smarter-robots-with-behavior-trees-in-ros-2\/#article","isPartOf":{"@id":"https:\/\/learnbydoing.dev\/building-smarter-robots-with-behavior-trees-in-ros-2\/"},"author":{"name":"","@id":""},"headline":"Building Smarter Robots with Behavior Trees in ROS 2","datePublished":"2025-07-29T14:09:03+00:00","dateModified":"2026-01-10T22:05:03+00:00","mainEntityOfPage":{"@id":"https:\/\/learnbydoing.dev\/building-smarter-robots-with-behavior-trees-in-ros-2\/"},"wordCount":761,"publisher":{"@id":"https:\/\/learnbydoing.dev\/es\/#organization"},"image":{"@id":"https:\/\/learnbydoing.dev\/building-smarter-robots-with-behavior-trees-in-ros-2\/#primaryimage"},"thumbnailUrl":"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/Titolo-_7_.webp","keywords":["behavior","behavior tree","build","Guide","implement","iron","Jazzy","lbd","learn by doing","nav","nav2","node","py","python","robot","Robotics","robots","ROS","ROS 2","ROS2","smart","step by step","tree","tutorial","Ubuntu"],"articleSection":["Nav2","ROS 2","Tutorials"],"inLanguage":"es"},{"@type":"WebPage","@id":"https:\/\/learnbydoing.dev\/building-smarter-robots-with-behavior-trees-in-ros-2\/","url":"https:\/\/learnbydoing.dev\/building-smarter-robots-with-behavior-trees-in-ros-2\/","name":"Building Smarter Robots with Behavior Trees in ROS 2 - Learn by Doing!","isPartOf":{"@id":"https:\/\/learnbydoing.dev\/es\/#website"},"primaryImageOfPage":{"@id":"https:\/\/learnbydoing.dev\/building-smarter-robots-with-behavior-trees-in-ros-2\/#primaryimage"},"image":{"@id":"https:\/\/learnbydoing.dev\/building-smarter-robots-with-behavior-trees-in-ros-2\/#primaryimage"},"thumbnailUrl":"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/Titolo-_7_.webp","datePublished":"2025-07-29T14:09:03+00:00","dateModified":"2026-01-10T22:05:03+00:00","description":"Build smarter ROS 2 robots with Behavior Trees: explore modular logic, control flow, and Groot in a detailed, step-by-step tutorial","breadcrumb":{"@id":"https:\/\/learnbydoing.dev\/building-smarter-robots-with-behavior-trees-in-ros-2\/#breadcrumb"},"inLanguage":"es","potentialAction":[{"@type":"ReadAction","target":["https:\/\/learnbydoing.dev\/building-smarter-robots-with-behavior-trees-in-ros-2\/"]}]},{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/learnbydoing.dev\/building-smarter-robots-with-behavior-trees-in-ros-2\/#primaryimage","url":"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/Titolo-_7_.webp","contentUrl":"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/Titolo-_7_.webp","width":1920,"height":1080},{"@type":"BreadcrumbList","@id":"https:\/\/learnbydoing.dev\/building-smarter-robots-with-behavior-trees-in-ros-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/learnbydoing.dev\/es\/learn-by-doing-es\/"},{"@type":"ListItem","position":2,"name":"Building Smarter Robots with Behavior Trees in ROS 2"}]},{"@type":"WebSite","@id":"https:\/\/learnbydoing.dev\/es\/#website","url":"https:\/\/learnbydoing.dev\/es\/","name":"Learn by Doing!","description":"Learn Robotics the fun way","publisher":{"@id":"https:\/\/learnbydoing.dev\/es\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/learnbydoing.dev\/es\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"es"},{"@type":"Organization","@id":"https:\/\/learnbydoing.dev\/es\/#organization","name":"Learn by Doing!","url":"https:\/\/learnbydoing.dev\/es\/","logo":{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/learnbydoing.dev\/es\/#\/schema\/logo\/image\/","url":"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/cropped-Progetto-senza-titolo-6-1.png","contentUrl":"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/cropped-Progetto-senza-titolo-6-1.png","width":512,"height":512,"caption":"Learn by Doing!"},"image":{"@id":"https:\/\/learnbydoing.dev\/es\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.linkedin.com\/in\/antonio-brandi-512166bb\/"]},{"@type":"Person","@id":"","url":"https:\/\/learnbydoing.dev\/es\/author\/"}]}},"_links":{"self":[{"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/posts\/3494","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/comments?post=3494"}],"version-history":[{"count":26,"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/posts\/3494\/revisions"}],"predecessor-version":[{"id":5516,"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/posts\/3494\/revisions\/5516"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/media\/3501"}],"wp:attachment":[{"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/media?parent=3494"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/categories?post=3494"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/tags?post=3494"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}