--- aliases: - NAV2 - Navigation - ROS2 --- - How is the NAV2 library structured? - What are the core concepts? - How can we utilize it to improve our own code? # ROS2 and NAV2 Because navigation is usually a long running task, [[ROS2 - NAV2 Library|NAV2]] uses [[ROS2]] actions (servers and clients) to implement and execute navigation tasks. Actions servers implement the actual execution in a separate thread and thus can be running in a blocking manner (a [shared Future object](https://en.wikipedia.org/wiki/Futures_and_promises) is used to communicate Feedback and results). The feedback can be shared both synchronously through callbacks and asynchronously through requesting information from the shared future object. In any case we spinning the client node is required. ## Lifecycle Nodes (aka. Mangaged Nodes) NAV2 relies heavily on [[ROS2 - Lifecycle Nodes]], because it helps to structure the program in reasonable ways for commercial uses and debugging. All servers in NAV2 use the lifecycle nodes and it is the best convention for all ROS systems to use lifecycle nodes if possible. # Behavior Trees [[Behaviour Trees]] are used as the main concept to implement complex tasks and the application logic. In order to do that behaviors are broken down into primitives (very basic behavior). From [NAV2 documentation:](https://navigation.ros.org/concepts/index.html) >For this project, we use [BehaviorTree CPP V3](https://www.behaviortree.dev/) as the behavior tree library. We create node plugins which can be constructed into a tree, inside the `BT Navigator`. The node plugins are loaded into the BT and when the XML file of the tree is parsed, the registered names are associated. At this point, we can march through the behavior tree to navigate. # Source Code Walk Through The version of nav2 I used to write our own nav3 library was: 7009ffba on october 16th 2023. ## NAV2 Common This package contains only launchfiles that implement classes to facilitate writing other launch files. Functions like rewriting part of a file, replacing strings, check if node parameters are available, etc. # Navigation Servers ## Planners ## Controllers There is a single GoalChecker Plugin that implements the GoalChecker interface. It is called SimpleGoalChecker # Navigation illumination Video [Vimeo Video](https://vimeo.com/106994708)
Controller (Local Planner) ![[Pasted image 20231019145329.png]]