      * [ Added Smoother Task Server ](../../migration/Galactic.html#added-smoother-task-server)
      * [ Removed Use Approach Velocity Scaling Param in RPP ](../../migration/Galactic.html#removed-use-approach-velocity-scaling-param-in-rpp)
      * [ Refactored AMCL motion models as plugins ](../../migration/Galactic.html#refactored-amcl-motion-models-as-plugins)
      * [ Dropping Support for Live Groot Monitoring of Nav2 ](../../migration/Galactic.html#dropping-support-for-live-groot-monitoring-of-nav2)
      * [ Replanning Only if Path is Invalid ](../../migration/Galactic.html#replanning-only-if-path-is-invalid)
      * [ Fix CostmapLayer clearArea invert param logic ](../../migration/Galactic.html#fix-costmaplayer-cleararea-invert-param-logic)
      * [ Dynamic Composition ](../../migration/Galactic.html#dynamic-composition)
      * [ BT Cancel Node ](../../migration/Galactic.html#bt-cancel-node)
      * [ BT PathLongerOnApproach Node ](../../migration/Galactic.html#bt-pathlongeronapproach-node)
      * [ BT TruncatePathLocal Node ](../../migration/Galactic.html#bt-truncatepathlocal-node)
      * [ Constrained Smoother ](../../migration/Galactic.html#constrained-smoother)
      * [ Replanning at a Constant Rate and if the Path is Invalid ](../../migration/Galactic.html#replanning-at-a-constant-rate-and-if-the-path-is-invalid)
      * [ Euclidean Distance 2D ](../../migration/Galactic.html#euclidean-distance-2d)
      * [ Recovery To Behavior ](../../migration/Galactic.html#recovery-to-behavior)
      * [ Respawn Support in Launch and Lifecycle Manager ](../../migration/Galactic.html#respawn-support-in-launch-and-lifecycle-manager)
      * [ New Nav2 Velocity Smoother ](../../migration/Galactic.html#new-nav2-velocity-smoother)
      * [ Goal Checker API Changed ](../../migration/Galactic.html#goal-checker-api-changed)
      * [ Added Assisted Teleop ](../../migration/Galactic.html#added-assisted-teleop)
    * [ Humble to Iron ](../../migration/Humble.html)
      * [ New Behavior-Tree Navigator Plugins ](../../migration/Humble.html#new-behavior-tree-navigator-plugins)
      * [ Added Collision Monitor ](../../migration/Humble.html#added-collision-monitor)
      * [ Removed use_sim_time from yaml ](../../migration/Humble.html#removed-use-sim-time-from-yaml)
      * [ Run-time Speed up of Smac Planner ](../../migration/Humble.html#run-time-speed-up-of-smac-planner)
      * [ Recursive Refinement of Smac and Simple Smoothers ](../../migration/Humble.html#recursive-refinement-of-smac-and-simple-smoothers)
      * [ Simple Commander Python API ](../../migration/Humble.html#simple-commander-python-api)
      * [ Smac Planner Start Pose Included in Path ](../../migration/Humble.html#smac-planner-start-pose-included-in-path)
      * [ Parameterizable Collision Checking in RPP ](../../migration/Humble.html#parameterizable-collision-checking-in-rpp)
      * [ Expanded Planner Benchmark Tests ](../../migration/Humble.html#expanded-planner-benchmark-tests)
      * [ Smac Planner Path Tolerances ](../../migration/Humble.html#smac-planner-path-tolerances)
      * [ costmap_2d_node default constructor ](../../migration/Humble.html#costmap-2d-node-default-constructor)
      * [ Feedback for Navigation Failures ](../../migration/Humble.html#feedback-for-navigation-failures)
      * [ Costmap Filters ](../../migration/Humble.html#costmap-filters)
      * [ Savitzky-Golay Smoother ](../../migration/Humble.html#savitzky-golay-smoother)
      * [ Changes to Map yaml file path for map_server node in Launch ](../../migration/Humble.html#changes-to-map-yaml-file-path-for-map-server-node-in-launch)
      * [ SmootherSelector BT Node ](../../migration/Humble.html#smootherselector-bt-node)
      * [ Publish Costmap Layers ](../../migration/Humble.html#publish-costmap-layers)
      * [ Give Behavior Server Access to Both Costmaps ](../../migration/Humble.html#give-behavior-server-access-to-both-costmaps)
      * [ New Model Predictive Path Integral Controller ](../../migration/Humble.html#new-model-predictive-path-integral-controller)
      * [ Behavior Tree Uses Error Codes ](../../migration/Humble.html#behavior-tree-uses-error-codes)
      * [ Load, Save and Loop Waypoints from the Nav2 Panel in RViz ](../../migration/Humble.html#load-save-and-loop-waypoints-from-the-nav2-panel-in-rviz)


##  Requirements  ¶


####  Maintainers


Close Mobile Search


The Nav2 Controller is an [ Execution Module ](https://github.com/ros-
planning/navigation2/tree/eloquent-
devel/nav2_controller/../doc/requirements/requirements.md) that implements the
` nav2_msgs::action::FollowPath ` action server.


` ` controller ` = controllerTEB(  ___  , ` Name=Value ` ) ` specifies
properties using one or more name-value arguments in addition to any
combination of input arguments from the previous syntaxes.


###  Package Dependencies


---

[
API Docs ](http://docs.ros.org/en/iron/p/nav2_controller "View API
documentation on docs.ros.org") [
Browse Code ](https://github.com/ros-
planning/navigation2/tree/iron/nav2_controller "View source code on
repository")


Awesome work! Here is another question you might get inundated with so let’s
make it public: is it coming to Humble?


**Checkout URI** |  [ https://github.com/ros-planning/navigation2.git
](https://github.com/ros-planning/navigation2.git)
---|---
**VCS Type** |  git
**VCS Version** |  galactic
**Last Updated**

2022-09-15  |  **Dev Status** |  DEVELOPED
**CI status** |  No Continuous Integration
**Released** |  RELEASED
**Tags** |  _No category tags._
**Contributing** |  [ Help Wanted (  0  ) ](/r/navigation2/#galactic-
contribute-lists-help-wanted)
[ Good First Issues (  0  ) ](/r/navigation2/#galactic-contribute-lists-good-
first-issue)
[ Pull Requests to Review (  0  ) ](/r/navigation2/#galactic-contribute-lists-
pull-requests)

###  Package Description


#  step


###  ` velcmds ` — Velocity commands
_N_ -by-2 matrix


---

[
API Docs ](http://docs.ros.org/en/galactic/p/nav2_controller "View API
documentation on docs.ros.org") [
Browse Code ](https://github.com/ros-
planning/navigation2/tree/galactic/nav2_controller "View source code on
repository")


_No launch files found_


[ nav2_controller/README.md ](https://github.com/ros-
planning/navigation2/tree/galactic/nav2_controller/README.md "Open in git
repository")


**Note**


  * MathWorks
  * Help Center


        * [ 1- Launch Navigation2 ](../../tutorials/docs/navigation2_with_slam.html#launch-navigation2)
        * [ 2- Launch SLAM ](../../tutorials/docs/navigation2_with_slam.html#launch-slam)
        * [ 3- Working with SLAM ](../../tutorials/docs/navigation2_with_slam.html#working-with-slam)
        * [ 4- Getting Started Simplification ](../../tutorials/docs/navigation2_with_slam.html#getting-started-simplification)
    * [ (STVL) Using an External Costmap Plugin ](../../tutorials/docs/navigation2_with_stvl.html)
      * [ Overview ](../../tutorials/docs/navigation2_with_stvl.html#overview)
      * [ Costmap2D and STVL ](../../tutorials/docs/navigation2_with_stvl.html#costmap2d-and-stvl)
      * [ Tutorial Steps ](../../tutorials/docs/navigation2_with_stvl.html#tutorial-steps)
        * [ 0- Setup ](../../tutorials/docs/navigation2_with_stvl.html#setup)
        * [ 1- Install STVL ](../../tutorials/docs/navigation2_with_stvl.html#install-stvl)
        * [ 1- Modify Navigation2 Parameter ](../../tutorials/docs/navigation2_with_stvl.html#modify-navigation2-parameter)
        * [ 2- Launch Navigation2 ](../../tutorials/docs/navigation2_with_stvl.html#launch-navigation2)
        * [ 3- RVIZ ](../../tutorials/docs/navigation2_with_stvl.html#rviz)
    * [ Navigating Using GPS Localization ](../../tutorials/docs/navigation2_with_gps.html)
      * [ Overview ](../../tutorials/docs/navigation2_with_gps.html#overview)
      * [ Requirements ](../../tutorials/docs/navigation2_with_gps.html#requirements)
      * [ GPS Localization Overview ](../../tutorials/docs/navigation2_with_gps.html#gps-localization-overview)
      * [ Tutorial Steps ](../../tutorials/docs/navigation2_with_gps.html#tutorial-steps)
        * [ 0- Setup Gazebo World ](../../tutorials/docs/navigation2_with_gps.html#setup-gazebo-world)
        * [ 1- Setup GPS Localization system ](../../tutorials/docs/navigation2_with_gps.html#setup-gps-localization-system)
        * [ 2- Setup Navigation system ](../../tutorials/docs/navigation2_with_gps.html#setup-navigation-system)
        * [ 3- Interactive GPS Waypoint Follower ](../../tutorials/docs/navigation2_with_gps.html#interactive-gps-waypoint-follower)
        * [ 4- Logged GPS Waypoint Follower & Waypoint Logging ](../../tutorials/docs/navigation2_with_gps.html#logged-gps-waypoint-follower-waypoint-logging)
      * [ Conclusion ](../../tutorials/docs/navigation2_with_gps.html#conclusion)
    * [ Groot - Interacting with Behavior Trees ](../../tutorials/docs/using_groot.html)
      * [ Overview ](../../tutorials/docs/using_groot.html#overview)
      * [ Visualize Behavior Trees ](../../tutorials/docs/using_groot.html#visualize-behavior-trees)
      * [ Edit Behavior Trees ](../../tutorials/docs/using_groot.html#edit-behavior-trees)
      * [ Adding A Custom Node ](../../tutorials/docs/using_groot.html#adding-a-custom-node)
    * [ Using VIO to Augment Robot Odometry ](../../tutorials/docs/integrating_vio.html)
      * [ Overview ](../../tutorials/docs/integrating_vio.html#overview)
      * [ Setting Up the ZED X Camera ](../../tutorials/docs/integrating_vio.html#setting-up-the-zed-x-camera)
      * [ Setting Up ZED ROS ](../../tutorials/docs/integrating_vio.html#setting-up-zed-ros)
      * [ Fusing VIO Into Local State Estimate ](../../tutorials/docs/integrating_vio.html#fusing-vio-into-local-state-estimate)
        * [ Fusing VSLAM Into Global State Estimate ](../../tutorials/docs/integrating_vio.html#fusing-vslam-into-global-state-estimate)
      * [ Testing it Out! ](../../tutorials/docs/integrating_vio.html#testing-it-out)
    * [ Dynamic Object Following ](../../tutorials/docs/navigation2_dynamic_point_following.html)
      * [ Overview ](../../tutorials/docs/navigation2_dynamic_point_following.html#overview)
      * [ Tutorial Steps ](../../tutorials/docs/navigation2_dynamic_point_following.html#tutorial-steps)
        * [ 0- Create the Behavior Tree ](../../tutorials/docs/navigation2_dynamic_point_following.html#create-the-behavior-tree)


###  Dependant Packages


  * [ Products ](https://www.mathworks.com/products.html?s_tid=gn_ps)
  * [ Solutions ](https://www.mathworks.com/solutions.html?s_tid=gn_sol)
  * [ Academia ](https://www.mathworks.com/academia.html?s_tid=gn_acad)
  * [ Support ](https://www.mathworks.com/help/?s_tid=gn_supp)
  * [ Community ](https://www.mathworks.com/matlabcentral/?s_tid=gn_mlc)
  * [ Events ](https://www.mathworks.com/company/events.html?s_tid=gn_ev)
  * [ Get MATLAB ](https://login.mathworks.com/embedded-login/landing.html?cid=getmatlab&s_tid=gn_getml)


[ API Docs ](http://docs.ros.org/en/humble/p/nav2_controller "View API
documentation on docs.ros.org") [ Browse Code ](https://github.com/ros-
planning/navigation2/tree/humble/nav2_controller "View source code on
repository")


[ collapse all ](javascript:void\(0\);)


####  Authors


    while ~goalReached && simtime < 200
        % Update map to keep robot in the center of the map. Also update the
        % map with new information from the global map or sensor measurements.
        moveMapBy = curpose(1:2) - localmap.XLocalLimits(end)/2;
        localmap.move(moveMapBy,FillValue=0.5)
        syncWith(localmap,map)

        if mod(itr,10) == 0 % every 1 sec
            % Generate new vel commands with teb
            [velcmds,tstamps,curpath,info] = step(teb,curpose,curvel);
            goalReached = info.HasReachedGoal;
            feasibleDriveDuration = tstamps(info.LastFeasibleIdx);
            % If robot is far from goal and only less than third of trajectory
            % is feasible, then an option is to re-plan the path to follow to
            % reach the goal.
            if info.ExitFlag == 1 && ...
                    feasibleDriveDuration < (teb.LookAheadTime/3)
                route = plan(rrtstar,curpose,[27 18 -pi/2]);
                refpath = route.States;
                headingToNextPose = headingFromXY(refpath(:,1:2));
                refpath(2:end-1,3) = headingToNextPose(2:end-1);
                teb.ReferencePath = refpath;
            end
            timestamps = tstamps + simtime;

            % Show the updated information input to or output
            % from controllerTEB
            clf
            show(localmap)
            hold on
            plot(refpath(:,1),refpath(:,2),".-",Color="#EDB120", ...
                 DisplayName="Reference Path")
            quiver(curpath(:,1),curpath(:,2), ...
                   cos(curpath(:,3)),sin(curpath(:,3)), ...
                   0.2,Color="#A2142F",DisplayName="Current Path")
            quiver(curpose(:,1),curpose(:,2), ...
                   cos(curpose(:,3)),sin(curpose(:,3)), ...
                   0.5,"o",MarkerSize=20,ShowArrowHead="off", ...


_Since R2023b_


Main Content


[ nav2_controller/README.md ](https://github.com/ros-
planning/navigation2/tree/eloquent-devel/nav2_controller/README.md "Open in
git repository")


###  2- Exporting the controller plugin  ¶


      return cmd_vel;
    }


Create a ` controllerTEB ` object by using the reference path generated by the
global planner and the local map.


    #include "pluginlib/class_list_macros.hpp"
    PLUGINLIB_EXPORT_CLASS(nav2_pure_pursuit_controller::PurePursuitController, nav2_core::Controller)


###  Package Dependencies


Initialize parameters.


_Join the conversation_


Yes

setPlan()


* [ github-ros-planning-navigation2 ](/p/nav2_controller/github-ros-planning-navigation2)


Align the orientation to the path, except for at the start and goal states.


[ smac  ](https://discourse.ros.org/u/smac) March 1, 2023, 9:06pm  1


_No message files found._


5. Compile, and it should be registered. Next, we’ll use this plugin.


[ Open Live Script
](matlab:openExample\('nav/ComputeVelocityCmdsAndOptimalTrajUsingTEBAlgorithmExample'\))


* Nav2 (Including dependencies)


###  Dependant Packages


  * [ Trust Center ](https://www.mathworks.com/company/aboutus/policies_statements/trust-center.html?s_tid=gf_tc)
  * [ Trademarks ](https://www.mathworks.com/company/aboutus/policies_statements/trademarks.html?s_tid=gf_trd)
  * [ Privacy Policy ](https://www.mathworks.com/company/aboutus/policies_statements.html?s_tid=gf_priv)
  * [ Preventing Piracy ](https://www.mathworks.com/company/aboutus/policies_statements/piracy.html?s_tid=gf_pir)
  * [ Application Status ](https://status.mathworks.com/?s_tid=gf_application)


_See[ ROS Wiki Tutorials ](http://wiki.ros.org/nav2_controller/Tutorials) for
more details. _


  * Documentation
  * [ Examples ](../examples.html?category=motion-planning&s_tid=CRUX_topnav)
  * [ Functions ](../referencelist.html?type=function&category=motion-planning&s_tid=CRUX_topnav)
  * [ Blocks ](../referencelist.html?type=block&category=motion-planning&s_tid=CRUX_topnav)
  * [ Apps ](../referencelist.html?type=app&category=motion-planning&s_tid=CRUX_topnav)
  * [ Videos ](/support/search.html?fq\[\]=asset_type_name:video%20category:nav/motion-planning&s_tid=CRUX_topnav)
  * [ Answers ](/support/search.html?fq\[\]=asset_type_name:answer%20category:nav/motion-planning&s_tid=CRUX_topnav)


` ` controller ` = controllerTEB( ` refpath ` ) ` creates a TEB controller
object, ` controller ` , that computes the linear and angular velocity
commands for a car-like or differential-drive robot to follow the reference
path ` refpath ` and travel for 5 seconds in an obstacle-free environment. The
` refpath ` input sets the value of the [ ReferencePath
](controllerteb.html#mw_042f8cd3-0a6f-4ba8-b370-7eb2afc697db) property.


Weights for cost function optimization, specified as a structure. The fields
of the structure are:


####  Package Summary


      * [ Smoothers ](../../concepts/index.html#smoothers)
      * [ Robot Footprints ](../../concepts/index.html#robot-footprints)
      * [ Waypoint Following ](../../concepts/index.html#waypoint-following)
    * [ State Estimation ](../../concepts/index.html#state-estimation)
      * [ Standards ](../../concepts/index.html#standards)
      * [ Global Positioning: Localization and SLAM ](../../concepts/index.html#global-positioning-localization-and-slam)
      * [ Odometry ](../../concepts/index.html#odometry)
    * [ Environmental Representation ](../../concepts/index.html#environmental-representation)
      * [ Costmaps and Layers ](../../concepts/index.html#costmaps-and-layers)
      * [ Costmap Filters ](../../concepts/index.html#costmap-filters)
      * [ Other Forms ](../../concepts/index.html#other-forms)
    * [ Nav2 Academic Overview ](../../concepts/index.html#nav2-academic-overview)
  * [ First-Time Robot Setup Guide ](../../setup_guides/index.html)
    * [ Setting Up Transformations ](../../setup_guides/transformation/setup_transforms.html)
      * [ Transforms Introduction ](../../setup_guides/transformation/setup_transforms.html#transforms-introduction)
      * [ Static Transform Publisher Demo ](../../setup_guides/transformation/setup_transforms.html#static-transform-publisher-demo)
      * [ Transforms in Navigation2 ](../../setup_guides/transformation/setup_transforms.html#transforms-in-navigation2)
      * [ Conclusion ](../../setup_guides/transformation/setup_transforms.html#conclusion)
    * [ Setting Up The URDF ](../../setup_guides/urdf/setup_urdf.html)
      * [ URDF and the Robot State Publisher ](../../setup_guides/urdf/setup_urdf.html#urdf-and-the-robot-state-publisher)
      * [ Setting Up the Environment ](../../setup_guides/urdf/setup_urdf.html#setting-up-the-environment)
      * [ Writing the URDF ](../../setup_guides/urdf/setup_urdf.html#writing-the-urdf)
      * [ Build and Launch ](../../setup_guides/urdf/setup_urdf.html#build-and-launch)
      * [ Visualization using RVIZ ](../../setup_guides/urdf/setup_urdf.html#visualization-using-rviz)
      * [ Adding Physical Properties ](../../setup_guides/urdf/setup_urdf.html#adding-physical-properties)
      * [ Conclusion ](../../setup_guides/urdf/setup_urdf.html#conclusion)
    * [ Setting Up Odometry ](../../setup_guides/odom/setup_odom.html)
      * [ Odometry Introduction ](../../setup_guides/odom/setup_odom.html#odometry-introduction)
      * [ Setting Up Odometry on your Robot ](../../setup_guides/odom/setup_odom.html#setting-up-odometry-on-your-robot)
      * [ Simulating an Odometry System using Gazebo ](../../setup_guides/odom/setup_odom.html#simulating-an-odometry-system-using-gazebo)
        * [ Setup and Prerequisites ](../../setup_guides/odom/setup_odom.html#setup-and-prerequisites)
        * [ Adding Gazebo Plugins to a URDF ](../../setup_guides/odom/setup_odom.html#adding-gazebo-plugins-to-a-urdf)
        * [ Launch and Build Files ](../../setup_guides/odom/setup_odom.html#launch-and-build-files)
        * [ Build, Run and Verification ](../../setup_guides/odom/setup_odom.html#build-run-and-verification)
      * [ Robot Localization Demo ](../../setup_guides/odom/setup_odom.html#robot-localization-demo)
        * [ Configuring Robot Localization ](../../setup_guides/odom/setup_odom.html#configuring-robot-localization)
        * [ Launch and Build Files ](../../setup_guides/odom/setup_odom.html#id3)
        * [ Build, Run and Verification ](../../setup_guides/odom/setup_odom.html#id4)
      * [ Conclusion ](../../setup_guides/odom/setup_odom.html#conclusion)
    * [ Setting Up Sensors ](../../setup_guides/sensors/setup_sensors.html)


_No direct system dependencies._


##  MATLAB Command


Search Help Center


###  Related Topics


    teb.LookAheadTime = 10;         % sec
    teb.ObstacleSafetyMargin = 0.4; % meters

    % To generate time-optimal trajectories, specify a larger weight value,
    % like 100, for the cost function, Time. To follow the reference path
    % closely, keep the weight to a smaller value like 1e-3.
    teb.CostWeights.Time = 100;


Run Turtlebot3 simulation with enabled Nav2. Detailed instructions on how to
make it run are written at [ Getting Started
](../../getting_started/index.html#getting-started) . Below is a shortcut
command for that:


Indicates whether the robot has successfully reached the last pose in the [
ReferencePath  ](controllerteb.html#mw_042f8cd3-0a6f-4ba8-b370-7eb2afc697db)
within a tolerance, and returns as ` true ` if successful. Otherwise, this
value returns ` false ` .

` TrajectoryCost ` |


Per what I hope you’ve come to expect from Nav2, we have extensive
configuration documentation, a fantastic _**97%** _ unit test coverage (those
darn 20 lines escaped me this time _rattles fist_ ), and extremely well
calibrated out of the box behavior.


` controller = controllerTEB(refpath)  `


    show(map)
    title("Parking Lot Map")
    hold on


  * [ Navigation Toolbox ](../index.html?s_tid=CRUX_lftnav)
  * [ Motion Planning  ](../motion-planning.html?s_tid=CRUX_lftnav)


navigation2)
---|---

github-ros-planning-navigation2


2 Likes


[ ROS News for the Week of February 27, 2023
](https://discourse.ros.org/t/ros-news-for-the-week-of-february-27-2023/30107)


  * [ Switzerland (English) ](https://ch.mathworks.com)
  * [ Switzerland (Deutsch) ](https://ch.mathworks.com)
  * [ Switzerland (Français) ](https://ch.mathworks.com)


No version for distro **bouncy** . Known supported distros are highlighted in
the buttons above.


###  R2023b:  Specify minimum turning radius, maximum reverse velocity, and
goal tolerance


Powered by [ Discourse ](https://www.discourse.org) , best viewed with
JavaScript enabled


* ` description  ` : Description of the plugin.


* 2 — Indicates that the poses corresponding to indices after the ` LastFeasibleIdx ` violates the obstacle safety margin constraint of the TEB controller by more than 10%.


[ collapse all ](javascript:void\(0\);)


See the [ Navigation Plugin list
](https://navigation.ros.org/plugins/index.html) for a list of the currently
known and available controller plugins.


###  Source Tutorials


####  Authors


  * [ Trial Software ](/campaigns/products/trials.html?prodcode=NV&s_tid=doc_trial_NV_tb)
  * [ Trial Software ](/campaigns/products/trials.html?prodcode=NV&s_tid=doc_trial_NV_tb)
  * [ Product Updates ](/support/web_downloads_bounce.html?s_tid=hc_prod_update&s_cid=1008_degr_docdn_270055)
  * [ Product Updates ](/support/web_downloads_bounce.html?s_tid=hc_prod_update&s_cid=1008_degr_docdn_270055)


> I would be inundated with messages regarding TEB


###  ` CostWeights ` —  Weights for cost function optimization
` struct("Time",10,"Smoothness",1000,"Obstacle",50) ` (default) |  structure


Yes

In this tutorial, we will use the methods ` PurePursuitController::configure
` , ` PurePursuitController::setPlan  ` and `
PurePursuitController::computeVelocityCommands  ` .


###  Wiki Tutorials


**Requires override?**

---|---|---

configure()


####  Package Summary


A massive development campaign spanning a plurality of my 2022 working time
has finally met the last few requirements set out and has been released into
the wild into Nav2. I’m super happy to announce the release of the **New** [
**MPPI Controller** ](https://github.com/ros-
planning/navigation2/tree/main/nav2_mppi_controller) , the first predictive
controller in the Navigation Stack in ROS 1 or ROS 2 to continue progressing
the themes of modern capabilities in the framework. This addresses one of the
longest standing issues in ROS Navigation.


###  ` optPath ` — Optimized path
_N_ -by-3 matrix


**Tags** |  _No category tags._
---|---
**Version** |  1.0.12
**License** |  Apache-2.0
**Build type** |  AMENT_CMAKE
**Use** |  RECOMMENDED

###  Repository Summary


[ smac  ](https://discourse.ros.org/u/smac) March 7, 2023, 6:04pm  10


No version for distro **ardent** . Known supported distros are highlighted in
the buttons above.


Select a Web Site


###  Plugins


__ [ Nav2 ](../../index.html)


Note that it requires pluginlib to export out the plugin’s class. Pluginlib
would provide as macro ` PLUGINLIB_EXPORT_CLASS  ` , which does all the work
of exporting.


##  Syntax


  * It will really nicely back away from obstacles if close up to them and then go around smoothly – where ROS 1 and previous ROS 2 methods get stuck in local minima.
  * You don’t have to “choose” if you want to have exact path-following behavior or highly dynamic behavior due to obstacles. I’ve baked in the ability to do both simultaneously, whereas it will follow the path closely when not near dynamic obstacles but can be highly dynamic off the route when necessary
  * Of the 3 companies that I’ve been working with in recent months as beta testers, 2 have decided to move their primary systems over to it immediately and 1 is seriously considering it.
  * Work with differential, omnidirectional, and ackermann vehicles alongside highly configurable and replaceable objective functions


$ ros2 launch nav2_bringup tb3_simulation_launch.py params_file:=/path/to/your_params_file.yaml


MathWorks


###  ` controller ` —  TEB controller
` controllerTEB ` object


      * [ Composition ](../../tutorials/docs/adding_a_nav2_task_server.html#composition)
      * [ Error codes ](../../tutorials/docs/adding_a_nav2_task_server.html#error-codes)
      * [ Conclusion ](../../tutorials/docs/adding_a_nav2_task_server.html#conclusion)
    * [ Filtering of Noise-Induced Obstacles ](../../tutorials/docs/filtering_of_noise-induced_obstacles.html)
      * [ Overview ](../../tutorials/docs/filtering_of_noise-induced_obstacles.html#overview)
      * [ Requirements ](../../tutorials/docs/filtering_of_noise-induced_obstacles.html#requirements)
      * [ Tutorial Steps ](../../tutorials/docs/filtering_of_noise-induced_obstacles.html#tutorial-steps)
        * [ 1\. Enable Denoise Layer ](../../tutorials/docs/filtering_of_noise-induced_obstacles.html#enable-denoise-layer)
        * [ 2\. Run Nav2 stack ](../../tutorials/docs/filtering_of_noise-induced_obstacles.html#run-nav2-stack)
      * [ How it works ](../../tutorials/docs/filtering_of_noise-induced_obstacles.html#how-it-works)
    * [ Camera Calibration ](../../tutorials/docs/camera_calibration.html)
      * [ Overview ](../../tutorials/docs/camera_calibration.html#overview)
      * [ Requirements ](../../tutorials/docs/camera_calibration.html#requirements)
      * [ Tutorial Steps ](../../tutorials/docs/camera_calibration.html#tutorial-steps)
    * [ Get Backtrace in ROS 2 / Nav2 ](../../tutorials/docs/get_backtrace.html)
      * [ Overview ](../../tutorials/docs/get_backtrace.html#overview)
      * [ Preliminaries ](../../tutorials/docs/get_backtrace.html#preliminaries)
      * [ From a Node ](../../tutorials/docs/get_backtrace.html#from-a-node)
      * [ From a Launch File ](../../tutorials/docs/get_backtrace.html#from-a-launch-file)
      * [ From Large Project ](../../tutorials/docs/get_backtrace.html#from-large-project)
      * [ From Nav2 Bringup ](../../tutorials/docs/get_backtrace.html#from-nav2-bringup)
      * [ Automatic backtrace on crash ](../../tutorials/docs/get_backtrace.html#automatic-backtrace-on-crash)
    * [ Profiling in ROS 2 / Nav2 ](../../tutorials/docs/get_profile.html)
      * [ Overview ](../../tutorials/docs/get_profile.html#overview)
      * [ Preliminaries ](../../tutorials/docs/get_profile.html#preliminaries)
      * [ Profile from a Node ](../../tutorials/docs/get_profile.html#profile-from-a-node)
      * [ Profile from a Launch File ](../../tutorials/docs/get_profile.html#profile-from-a-launch-file)
      * [ From Nav2 Bringup ](../../tutorials/docs/get_profile.html#from-nav2-bringup)
      * [ Interpreting Results ](../../tutorials/docs/get_profile.html#interpreting-results)
    * [ Docker for Development: Zero to Hero ](../../tutorials/docs/docker_dev.html)
      * [ Overview ](../../tutorials/docs/docker_dev.html#overview)
      * [ Preliminaries ](../../tutorials/docs/docker_dev.html#preliminaries)
      * [ Important Docker Commands ](../../tutorials/docs/docker_dev.html#important-docker-commands)
      * [ Exploring Your First Container ](../../tutorials/docs/docker_dev.html#exploring-your-first-container)
      * [ Understanding ROS Docker Images ](../../tutorials/docs/docker_dev.html#understanding-ros-docker-images)
      * [ For Docker-Based Development ](../../tutorials/docs/docker_dev.html#for-docker-based-development)
        * [ Building a Development Image ](../../tutorials/docs/docker_dev.html#building-a-development-image)
        * [ Visualizations from Docker ](../../tutorials/docs/docker_dev.html#visualizations-from-docker)
      * [ For Docker-Based Deployment ](../../tutorials/docs/docker_dev.html#for-docker-based-deployment)
      * [ Conclusion ](../../tutorials/docs/docker_dev.html#conclusion)


I’ll say though that MPPI actually handles non-modeled dynamic obstacles
pretty well. But also the pluginized objective functions can allow you add a
new one for modeling dynamic obstacles if you like in the meantime (and I’d be
very open to reviewing a design/PR for one!).


Topic  |  |  Replies  |  Views  |  Activity
---|---|---|---|---
[ [Nav2 WG] Meeting Minutes March 28, 2024
](https://discourse.ros.org/t/nav2-wg-meeting-minutes-march-28-2024/36898)


###  Source Tutorials


Scalar value indicating the exit condition of the ` step ` function.


32 Likes


    validator = validatorOccupancyMap(stateSpaceSE2,Map=map);
    validator.ValidationDistance = 0.1;


4 Likes


The Nav2 Controller is an [ Execution Module ](https://github.com/ros-
planning/navigation2/tree/galactic/nav2_controller/../doc/requirements/requirements.md)
that implements the ` nav2_msgs::action::FollowPath ` action server.


Velocity commands, returned as an _N_ -by-2 matrix. The first column is the
linear velocity in meters per second, and the second column is the angular
velocity in radians per second.


###  Syntax


        * [ CancelCoverage ](../../configuration/packages/bt-plugins/actions/CancelCoverage.html)
        * [ RemovePassedGoals ](../../configuration/packages/bt-plugins/actions/RemovePassedGoals.html)
        * [ CancelControl ](../../configuration/packages/bt-plugins/actions/CancelControl.html)
        * [ CancelBackUp ](../../configuration/packages/bt-plugins/actions/CancelBackUp.html)
        * [ CancelSpin ](../../configuration/packages/bt-plugins/actions/CancelSpin.html)
        * [ CancelWait ](../../configuration/packages/bt-plugins/actions/CancelWait.html)
        * [ CancelDriveOnHeading ](../../configuration/packages/bt-plugins/actions/CancelDriveOnHeading.html)
        * [ CancelAssistedTeleop ](../../configuration/packages/bt-plugins/actions/CancelAssistedTeleop.html)
        * [ SmoothPath ](../../configuration/packages/bt-plugins/actions/Smooth.html)
      * [ Condition Plugins ](../../configuration/packages/configuring-bt-xml.html#condition-plugins)
        * [ GoalReached ](../../configuration/packages/bt-plugins/conditions/GoalReached.html)
        * [ TransformAvailable ](../../configuration/packages/bt-plugins/conditions/TransformAvailable.html)
        * [ DistanceTraveled ](../../configuration/packages/bt-plugins/conditions/DistanceTraveled.html)
        * [ GoalUpdated ](../../configuration/packages/bt-plugins/conditions/GoalUpdated.html)
        * [ GloballyUpdatedGoal ](../../configuration/packages/bt-plugins/conditions/GloballyUpdatedGoal.html)
        * [ InitialPoseReceived ](../../configuration/packages/bt-plugins/conditions/InitialPoseReceived.html)
        * [ IsStuck ](../../configuration/packages/bt-plugins/conditions/IsStuck.html)
        * [ TimeExpired ](../../configuration/packages/bt-plugins/conditions/TimeExpired.html)
        * [ IsBatteryLow ](../../configuration/packages/bt-plugins/conditions/IsBatteryLow.html)
        * [ IsPathValid ](../../configuration/packages/bt-plugins/conditions/IsPathValid.html)
        * [ PathExpiringTimer ](../../configuration/packages/bt-plugins/conditions/PathExpiringTimer.html)
        * [ AreErrorCodesPresent ](../../configuration/packages/bt-plugins/conditions/AreErrorCodesPresent.html)
        * [ WouldAControllerRecoveryHelp ](../../configuration/packages/bt-plugins/conditions/WouldAControllerRecoveryHelp.html)
        * [ WouldAPlannerRecoveryHelp ](../../configuration/packages/bt-plugins/conditions/WouldAPlannerRecoveryHelp.html)
        * [ WouldASmootherRecoveryHelp ](../../configuration/packages/bt-plugins/conditions/WouldASmootherRecoveryHelp.html)
        * [ IsBatteryCharging ](../../configuration/packages/bt-plugins/conditions/IsBatteryCharging.html)
      * [ Control Plugins ](../../configuration/packages/configuring-bt-xml.html#control-plugins)
        * [ PipelineSequence ](../../configuration/packages/bt-plugins/controls/PipelineSequence.html)
        * [ RoundRobin ](../../configuration/packages/bt-plugins/controls/RoundRobin.html)
        * [ RecoveryNode ](../../configuration/packages/bt-plugins/controls/RecoveryNode.html)
      * [ Decorator Plugins ](../../configuration/packages/configuring-bt-xml.html#decorator-plugins)
        * [ RateController ](../../configuration/packages/bt-plugins/decorators/RateController.html)
        * [ DistanceController ](../../configuration/packages/bt-plugins/decorators/DistanceController.html)
        * [ SpeedController ](../../configuration/packages/bt-plugins/decorators/SpeedController.html)
        * [ GoalUpdater ](../../configuration/packages/bt-plugins/decorators/GoalUpdater.html)
        * [ PathLongerOnApproach ](../../configuration/packages/bt-plugins/decorators/PathLongerOnApproach.html)
        * [ SingleTrigger ](../../configuration/packages/bt-plugins/decorators/SingleTrigger.html)
      * [ Example ](../../configuration/packages/configuring-bt-xml.html#example)
    * [ Costmap 2D ](../../configuration/packages/configuring-costmaps.html)
      * [ Costmap2D ROS Parameters ](../../configuration/packages/configuring-costmaps.html#costmap2d-ros-parameters)


If you specify the reference path as an _N_ -by-2 matrix, then the object
computes the orientation using the [ ` headingFromXY ` ](headingfromxy.html)
function and appends it as the third column.


Method is called when the global plan is updated. Ideally this method should
perform operations that transform the global plan and store it.


[ Edit ](https://github.com/ros-planning/navigation.ros.org)


---

[
API Docs ](http://docs.ros.org/en/humble/p/nav2_controller "View API
documentation on docs.ros.org") [
Browse Code ](https://github.com/ros-
planning/navigation2/tree/humble/nav2_controller "View source code on
repository")


[ nav2_amcl ](/p/nav2_amcl/github-ros-planning-navigation2) [
nav2_behavior_tree ](/p/nav2_behavior_tree/github-ros-planning-navigation2) [
nav2_bringup ](/p/nav2_bringup/github-ros-planning-navigation2) [
nav2_gazebo_spawner ](/p/nav2_gazebo_spawner/github-ros-planning-navigation2)
[ nav2_bt_navigator ](/p/nav2_bt_navigator/github-ros-planning-navigation2) [
nav2_common ](/p/nav2_common/github-ros-planning-navigation2) nav2_controller
[ nav2_core ](/p/nav2_core/github-ros-planning-navigation2) [ nav2_costmap_2d
](/p/nav2_costmap_2d/github-ros-planning-navigation2) [ costmap_queue
](/p/costmap_queue/github-ros-planning-navigation2) [ dwb_core
](/p/dwb_core/github-ros-planning-navigation2) [ dwb_critics
](/p/dwb_critics/github-ros-planning-navigation2) [ dwb_msgs
](/p/dwb_msgs/github-ros-planning-navigation2) [ dwb_plugins
](/p/dwb_plugins/github-ros-planning-navigation2) [ nav2_dwb_controller
](/p/nav2_dwb_controller/github-ros-planning-navigation2) [ nav_2d_msgs
](/p/nav_2d_msgs/github-ros-planning-navigation2) [ nav_2d_utils
](/p/nav_2d_utils/github-ros-planning-navigation2) [ nav2_turtlebot3_rl
](/p/nav2_turtlebot3_rl/github-ros-planning-navigation2) [
nav2_lifecycle_manager ](/p/nav2_lifecycle_manager/github-ros-planning-
navigation2) [ nav2_map_server ](/p/nav2_map_server/github-ros-planning-
navigation2) [ nav2_msgs ](/p/nav2_msgs/github-ros-planning-navigation2) [
nav2_navfn_planner ](/p/nav2_navfn_planner/github-ros-planning-navigation2) [
nav2_planner ](/p/nav2_planner/github-ros-planning-navigation2) [
nav2_recoveries ](/p/nav2_recoveries/github-ros-planning-navigation2) [
nav2_rviz_plugins ](/p/nav2_rviz_plugins/github-ros-planning-navigation2) [
nav2_system_tests ](/p/nav2_system_tests/github-ros-planning-navigation2) [
nav2_util ](/p/nav2_util/github-ros-planning-navigation2) [ nav2_voxel_grid
](/p/nav2_voxel_grid/github-ros-planning-navigation2) [ nav2_waypoint_follower
](/p/nav2_waypoint_follower/github-ros-planning-navigation2) [ navigation2
](/p/navigation2/github-ros-planning-navigation2)
---|---

github-ros-planning-navigation2


Create a deep clone of the ` controllerTEB ` object.


**Data Types:** ` double `


Toggle Main Navigation


##  How to Get Best Site Performance


#  Nav2 Controller


##  Object Functions


####  Maintainers


[ expand all ](javascript:void\(0\);)


**Virtual method**


CHANGELOG


###  Asia Pacific


    load parkingMap.mat;
    resolution = 3;
    map = occupancyMap(map,resolution);


The ` controllerTEB ` object creates a controller (local planner) using the
Timed Elastic Band (TEB) algorithm. The controller enables a robot to follow a
reference path typically generated by a global planner, such as RRT or Hybrid
A*. Additionally, the planner avoids obstacles and smooths the path while
optimizing travel time, and maintains a safe distance from obstacles known or
unknown to the global planner. The object also computes velocity commands and
an optimal trajectory using the current pose of the robot and its current
linear and angular velocities.


[ Davis_Ogunsina  ](https://discourse.ros.org/u/Davis_Ogunsina) March 2, 2023,
4:58pm  6


[ Help Center ](../../index.html) [ Help Center ](../../index.html)


_No service files found_


#  Writing a New Controller Plugin  ¶


It is good practice to place these lines at the end of the file, but
technically, you can also write at the top.


Currently available controller plugins are: DWB, and [ TEB (dashing release)
](https://github.com/rst-tu-dortmund/teb_local_planner/tree/dashing-devel) .


Visualize the path.


**Tags** |  _No category tags._
---|---
**Version** |  0.4.7
**License** |  Apache-2.0
**Build type** |  AMENT_CMAKE
**Use** |  RECOMMENDED

###  Repository Summary


[ smac  ](https://discourse.ros.org/u/smac) March 4, 2023, 2:26am  8


Controller action interface


It has been successfully backported to Humble as well!


[ ](https://lunrjs.com/guides/searching.html "Help to Search")


[ Nav2 ![Logo](../../_static/nav2_logo_powered.png) ](../../index.html)


_No additional links._


[ ros-infrastructure/rosindex  ](https://github.com/ros-
infrastructure/rosindex "Find rosindex in Github") | _generated on 2024-04-05_


####  Package Summary


  * [ ![Facebook](/images/responsive/global/ico-facebook.svg) ](https://www.facebook.com/MATLAB)
  * [ ![X](/images/responsive/global/ico-x.svg) ](https://twitter.com/MATLAB)
  * [ ![Instagram](/etc.clientlibs/mathworks/clientlibs/customer-ui/templates/common/resources/images/ico-instagram.svg) ](https://www.instagram.com/matlab/)
  * [ ![YouTube](/images/responsive/global/ico-youtube.svg) ](https://www.youtube.com/user/MATLAB)
  * [ ![LinkedIn](/images/responsive/global/ico-linkedin.svg) ](https://www.linkedin.com/company/the-mathworks_2)
  * [ ![RSS](/images/responsive/global/ico-rss.svg) ](https://www.mathworks.com/company/rss.html)


Visualize the map. The map contains the floor plan of a parking lot with some
parking slots already occupied.


****Set Up Parking Lot Environment** **


ROS Resources: [ Documentation ](http://docs.ros.org/) | [ Support
](http://wiki.ros.org/Support) | [ Discussion Forum
](http://discourse.ros.org/) | [ Service Status ](http://status.ros.org/) | [
ros @ Robotics Stack Exchange
](https://robotics.stackexchange.com/questions/tagged/ros)
---

[ ROS Index ](/)


    <library path="nav2_pure_pursuit_controller">
      <class type="nav2_pure_pursuit_controller::PurePursuitController" base_class_type="nav2_core::Controller">
        <description>
          This is pure pursuit controller
        </description>
      </class>
    </library>


**Are you a user of the new MPPI controller in some product environment?**
Please send me a PM! I’d love to highlight your company in my upcoming ROSCon
2023 talk on the MPPI Controller showing all the cool uses of it in the wild!


No version for distro **hydro** . Known supported distros are highlighted in
the buttons above.


Method is called when it is required to limit the maximum linear speed of the
robot. Speed limit could be expressed in absolute value (m/s) or in percentage
from maximum robot speed. Note that typically, maximum rotational speed is
being limited proportionally to the change of maximum linear speed, in order
to keep current robot behavior untouched.


    plot(refpath(:,1),refpath(:,2),"r-",LineWidth=2)
    hold off


####  Maintainers


In the above snippet, you can observe the mapping of our `
nav2_pure_pursuit_controller::PurePursuitController  ` controller to its id `
FollowPath  ` . To pass plugin-specific parameters we have used `
<plugin_id>.<plugin_specific_parameter> ` .


###  [ nav2_controller ](/p/nav2_controller) package from [ navigation2
](/r/navigation2/github-ros-planning-navigation2) repo


_See[ ROS Wiki Tutorials ](http://wiki.ros.org/nav2_controller/Tutorials) for
more details. _


The computation for the desired velocity happens in the `
computeVelocityCommands()  ` method. It is used to calculate the desired
velocity command given the current velocity and pose. The third argument - is
a pointer to the ` nav2_core::GoalChecker  ` , that checks whether a goal has
been reached. In our example, this won’t be used. In the case of pure pursuit,
the algorithm computes velocity commands such that the robot tries to follow
the global path as closely as possible. This algorithm assumes a constant
linear velocity and computes the angular velocity based on the curvature of
the global path.


[ ![MathWorks](/images/responsive/global/pic-header-mathworks-logo.svg)
](https://www.mathworks.com?s_tid=gn_logo)


* ROS 2 (binary or build-from-source)


                   Color="#0072BD",DisplayName="Start Pose")
        end

        simtime = simtime+timestep;
        % Compute the instantaneous velocity to be sent to the robot from the
        % series of timestamped commands generated by controllerTEB
        velcmd = velocityCommand(velcmds,timestamps,simtime);
        % Very basic robot model, should be replaced by simulator.
        statedot = [velcmd(1)*cos(curpose(3)) ...
                    velcmd(1)*sin(curpose(3)) ...
                    velcmd(2)];
        curpose = curpose + statedot*timestep;

        if exist("hndl","var")
            delete(hndl)
        end
        hndl = quiver(curpose(:,1),curpose(:,2), ...
                      cos(curpose(:,3)),sin(curpose(:,3)), ...
                      0.5,"o",MarkerSize=20,ShowArrowHead="off", ...
                      Color="#D95319",DisplayName="Current Robot Pose");
        itr = itr + 1;
        drawnow
    end
    legend


Occupancy map representing the environment, specified as a [ `
binaryOccupancyMap ` ](binaryoccupancymap.html) object or [ ` occupancyMap `
](occupancymap.html) object containing the obstacles in the vicinity of the
robot. When optimizing the trajectory, the controller considers the space
outside the boundary of the map to be free. Larger maps can lead to slower
performance.


Currently available controller plugins are: DWB, and [ TEB (dashing release)
](https://github.com/rst-tu-dortmund/teb_local_planner/tree/dashing-devel) .


* [ ` controllerTEB ` ](controllerteb.html)


  * [ Products ](https://www.mathworks.com/products.html?s_tid=gn_ps)
  * [ Solutions ](https://www.mathworks.com/solutions.html?s_tid=gn_sol)
  * [ Academia ](https://www.mathworks.com/academia.html?s_tid=gn_acad)
  * [ Support ](https://www.mathworks.com/help/?s_tid=gn_supp)
  * [ Community ](https://www.mathworks.com/matlabcentral/?s_tid=gn_mlc)
  * [ Events ](https://www.mathworks.com/company/events.html?s_tid=gn_ev)


###  4- Run Pure Pursuit Controller plugin  ¶


Controller action interface


Compute velocity commands and optimal trajectory.


The remaining methods are not used, but it’s mandatory to override them. As
per the rules, we did override all but left them empty.


You clicked a link that corresponds to this MATLAB command:


###  Services


Distance of each pose in [ ` optPath `
](controllerteb.step.html#mw_5298d93f-e911-4f55-9df1-0b4a05a04d13) from the
first pose in ` optPath ` . The value of [ ` curState `
](controllerteb.step.html#mw_65b8a7e2-5022-4653-a517-9df792f413e4) is always
the first pose in ` optPath ` .

` HasReachedGoal ` |


TEB controller, specified as a [ ` controllerTEB ` ](controllerteb.html)
object.


[ nav2_amcl ](/p/nav2_amcl/github-ros-planning-navigation2) [
nav2_behavior_tree ](/p/nav2_behavior_tree/github-ros-planning-navigation2) [
nav2_behaviors ](/p/nav2_behaviors/github-ros-planning-navigation2) [
nav2_bringup ](/p/nav2_bringup/github-ros-planning-navigation2) [
nav2_bt_navigator ](/p/nav2_bt_navigator/github-ros-planning-navigation2) [
nav2_collision_monitor ](/p/nav2_collision_monitor/github-ros-planning-
navigation2) [ nav2_common ](/p/nav2_common/github-ros-planning-navigation2) [
nav2_constrained_smoother ](/p/nav2_constrained_smoother/github-ros-planning-
navigation2) nav2_controller  [ nav2_core ](/p/nav2_core/github-ros-planning-
navigation2) [ nav2_costmap_2d ](/p/nav2_costmap_2d/github-ros-planning-
navigation2) [ costmap_queue ](/p/costmap_queue/github-ros-planning-
navigation2) [ dwb_core ](/p/dwb_core/github-ros-planning-navigation2) [
dwb_critics ](/p/dwb_critics/github-ros-planning-navigation2) [ dwb_msgs
](/p/dwb_msgs/github-ros-planning-navigation2) [ dwb_plugins
](/p/dwb_plugins/github-ros-planning-navigation2) [ nav2_dwb_controller
](/p/nav2_dwb_controller/github-ros-planning-navigation2) [ nav_2d_msgs
](/p/nav_2d_msgs/github-ros-planning-navigation2) [ nav_2d_utils
](/p/nav_2d_utils/github-ros-planning-navigation2) [ nav2_graceful_controller
](/p/nav2_graceful_controller/github-ros-planning-navigation2) [
nav2_lifecycle_manager ](/p/nav2_lifecycle_manager/github-ros-planning-
navigation2) [ nav2_map_server ](/p/nav2_map_server/github-ros-planning-
navigation2) [ nav2_mppi_controller ](/p/nav2_mppi_controller/github-ros-
planning-navigation2) [ nav2_msgs ](/p/nav2_msgs/github-ros-planning-
navigation2) [ nav2_navfn_planner ](/p/nav2_navfn_planner/github-ros-planning-
navigation2) [ nav2_planner ](/p/nav2_planner/github-ros-planning-navigation2)
[ nav2_regulated_pure_pursuit_controller
](/p/nav2_regulated_pure_pursuit_controller/github-ros-planning-navigation2) [
nav2_rotation_shim_controller ](/p/nav2_rotation_shim_controller/github-ros-
planning-navigation2) [ nav2_rviz_plugins ](/p/nav2_rviz_plugins/github-ros-
planning-navigation2) [ nav2_simple_commander
](/p/nav2_simple_commander/github-ros-planning-navigation2) [
nav2_smac_planner ](/p/nav2_smac_planner/github-ros-planning-navigation2) [
nav2_smoother ](/p/nav2_smoother/github-ros-planning-navigation2) [
nav2_system_tests ](/p/nav2_system_tests/github-ros-planning-navigation2) [
nav2_theta_star_planner ](/p/nav2_theta_star_planner/github-ros-planning-
navigation2) [ nav2_util ](/p/nav2_util/github-ros-planning-navigation2) [
nav2_velocity_smoother ](/p/nav2_velocity_smoother/github-ros-planning-
navigation2) [ nav2_voxel_grid ](/p/nav2_voxel_grid/github-ros-planning-
navigation2) [ nav2_waypoint_follower ](/p/nav2_waypoint_follower/github-ros-
planning-navigation2) [ navigation2 ](/p/navigation2/github-ros-planning-


No version for distro **melodic** . Known supported distros are highlighted in
the buttons above.


**Data Types:** ` double `


* Carl Delsey


_No additional links._


###  ` curVel ` —  Current velocity of robot
two-element vector of form [ _v_ _w_ ]


###  ` MaxReverseVelocity ` —  Maximum velocity for reverse motion
` NaN ` (default) |  positive scalar


##  See Also


Off-Canvas Navigation Menu Toggle


Steve


Contact your local office


###  Functions


##  Input Arguments


No version for distro **indigo** . Known supported distros are highlighted in
the buttons above.


_Not currently indexed._


This property impacts the number of velocity commands, timestamps, and poses
in the path.


##  Description


_No launch files found_


Field  |  Description
---|---
` Dimension ` |


Size of the robot, specified as a two-element positive vector of the form [
_length_ _width_ ], in meters.

` Shape ` |


No questions yet, you can ask one [ here
](https://robotics.stackexchange.com/questions/tagged/nav2_controller+eloquent)
.


Failed to get question list, you can ticket an issue [ here
](https://github.com/ros-infrastructure/rosindex/issues/new)


  * controllerTEB
  * On this page
  * Description
  * Creation
    * Description
  * Properties
    * ReferencePath
    * Map
    * CostWeights
    * RobotInformation
    * MinTurningRadius
    * ObstacleSafetyMargin
    * NumIteration
    * MaxVelocity
    * MaxReverseVelocity
    * MaxAcceleration
    * ReferenceDeltaTime
    * LookAheadTime
    * GoalTolerance
  * Object Functions
  * Examples
    * Compute Velocity Commands and Optimal Trajectory for Differential-Drive Robot Using Timed Elastic Band Algorithm
  * Extended Capabilities
  * Version History
    * Specify minimum turning radius, maximum reverse velocity, and goal tolerance
  * See Also


####  Additional Links


###  Services


* [ ` clone ` ](controllerteb.clone.html)


An execution module implementing the ` nav2_msgs::action::FollowPath ` action
server is responsible for generating command velocities for the robot, given
the computed path from the planner module in ` nav2_planner ` . The
nav2_controller package is designed to be loaded with plugins for path
execution. The plugins need to implement functions in the virtual base class
defined in the ` controller ` header file in ` nav2_core ` package.


###  ` NumIteration ` —  Number of iterations to optimize trajectory
` 2 ` (default) |  positive integer


No questions yet, you can ask one [ here
](https://robotics.stackexchange.com/questions/tagged/nav2_controller+galactic)
.


        * [ 1- Creating a new Behavior Plugin ](writing_new_behavior_plugin.html#creating-a-new-behavior-plugin)
        * [ 2- Exporting the Behavior Plugin ](writing_new_behavior_plugin.html#exporting-the-behavior-plugin)
        * [ 3- Pass the plugin name through params file ](writing_new_behavior_plugin.html#pass-the-plugin-name-through-params-file)
        * [ 4- Run Behavior Plugin ](writing_new_behavior_plugin.html#run-behavior-plugin)
    * [ Writing a New Navigator Plugin ](writing_new_navigator_plugin.html)
      * [ Overview ](writing_new_navigator_plugin.html#overview)
      * [ Requirements ](writing_new_navigator_plugin.html#requirements)
      * [ Tutorial Steps ](writing_new_navigator_plugin.html#tutorial-steps)
        * [ 1- Create a new Navigator Plugin ](writing_new_navigator_plugin.html#create-a-new-navigator-plugin)
        * [ 2- Exporting the navigator plugin ](writing_new_navigator_plugin.html#exporting-the-navigator-plugin)
        * [ 3- Pass the plugin name through the params file ](writing_new_navigator_plugin.html#pass-the-plugin-name-through-the-params-file)
        * [ 4- Run plugin ](writing_new_navigator_plugin.html#run-plugin)
  * [ Configuration Guide ](../../configuration/index.html)
    * [ Behavior-Tree Navigator ](../../configuration/packages/configuring-bt-navigator.html)
      * [ Parameters ](../../configuration/packages/configuring-bt-navigator.html#parameters)
      * [ Example ](../../configuration/packages/configuring-bt-navigator.html#example)
    * [ Behavior Tree XML Nodes ](../../configuration/packages/configuring-bt-xml.html)
      * [ Action Plugins ](../../configuration/packages/configuring-bt-xml.html#action-plugins)
        * [ Wait ](../../configuration/packages/bt-plugins/actions/Wait.html)
        * [ Spin ](../../configuration/packages/bt-plugins/actions/Spin.html)
        * [ BackUp ](../../configuration/packages/bt-plugins/actions/BackUp.html)
        * [ DriveOnHeading ](../../configuration/packages/bt-plugins/actions/DriveOnHeading.html)
        * [ AssistedTeleop ](../../configuration/packages/bt-plugins/actions/AssistedTeleop.html)
        * [ ComputePathToPose ](../../configuration/packages/bt-plugins/actions/ComputePathToPose.html)
        * [ FollowPath ](../../configuration/packages/bt-plugins/actions/FollowPath.html)
        * [ NavigateToPose ](../../configuration/packages/bt-plugins/actions/NavigateToPose.html)
        * [ ClearEntireCostmap ](../../configuration/packages/bt-plugins/actions/ClearEntireCostmap.html)
        * [ ClearCostmapExceptRegion ](../../configuration/packages/bt-plugins/actions/ClearCostmapExceptRegion.html)
        * [ ClearCostmapAroundRobot ](../../configuration/packages/bt-plugins/actions/ClearCostmapAroundRobot.html)
        * [ ReinitializeGlobalLocalization ](../../configuration/packages/bt-plugins/actions/ReinitializeGlobalLocalization.html)
        * [ TruncatePath ](../../configuration/packages/bt-plugins/actions/TruncatePath.html)
        * [ TruncatePathLocal ](../../configuration/packages/bt-plugins/actions/TruncatePathLocal.html)
        * [ PlannerSelector ](../../configuration/packages/bt-plugins/actions/PlannerSelector.html)
        * [ ControllerSelector ](../../configuration/packages/bt-plugins/actions/ControllerSelector.html)
        * [ SmootherSelector ](../../configuration/packages/bt-plugins/actions/SmootherSelector.html)
        * [ GoalCheckerSelector ](../../configuration/packages/bt-plugins/actions/GoalCheckerSelector.html)
        * [ ProgressCheckerSelector ](../../configuration/packages/bt-plugins/actions/ProgressCheckerSelector.html)
        * [ NavigateThroughPoses ](../../configuration/packages/bt-plugins/actions/NavigateThroughPoses.html)
        * [ ComputePathThroughPoses ](../../configuration/packages/bt-plugins/actions/ComputePathThroughPoses.html)
        * [ ComputeCoveragePath ](../../configuration/packages/bt-plugins/actions/ComputeCoveragePath.html)


Create a [ ` validatorOccupancyMap ` ](validatoroccupancymap.html) state
validator using the [ ` stateSpaceSE2 ` ](statespacese2.html) definition.
Specify the map and the distance for interpolating and validating path
segments.


* 3 — Indicates that the turning radius of the vehicle while moving from a pose at ` LastFeasibleIdx ` to a subsequent pose violates the minimum turning radius constraint by more than 10%.


**Data Types:** ` single ` | ` double ` | ` int8 ` | ` int16 ` | ` int32 ` | `
int64 ` | ` uint8 ` | ` uint16 ` | ` uint32 ` | ` uint64 `


[ ![MathWorks](/images/responsive/global/pic-header-mathworks-logo.svg)
](https://www.mathworks.com?s_tid=gn_logo)


1 Like


  * [ Trial Software ](/campaigns/products/trials.html?prodcode=NV&s_tid=doc_trial_NV_tb)
  * [ Trial Software ](/campaigns/products/trials.html?prodcode=NV&s_tid=doc_trial_NV_tb)
  * [ Product Updates ](/support/web_downloads_bounce.html?s_tid=hc_prod_update&s_cid=1008_degr_docdn_270055)
  * [ Product Updates ](/support/web_downloads_bounce.html?s_tid=hc_prod_update&s_cid=1008_degr_docdn_270055)


      * [ Subtrees Obtain Shared Resources ](../../migration/Iron.html#subtrees-obtain-shared-resources)
      * [ Collision Monitor: added watchdog mechanism based on ` source_timeout  ` parameter with default blocking behavior ](../../migration/Iron.html#collision-monitor-added-watchdog-mechanism-based-on-source-timeout-parameter-with-default-blocking-behavior)
      * [ BtActionServer: use native library haltTree() ](../../migration/Iron.html#btactionserver-use-native-library-halttree)
      * [ Global Frame Removed from 2 BT Nodes ](../../migration/Iron.html#global-frame-removed-from-2-bt-nodes)
      * [ Introduction of ` CostmapUpdate.msg  ` ](../../migration/Iron.html#introduction-of-costmapupdate-msg)
      * [ Full Stack Uses Node Clocks ](../../migration/Iron.html#full-stack-uses-node-clocks)
      * [ New Graceful Motion Controller ](../../migration/Iron.html#new-graceful-motion-controller)
      * [ Plugin Libraries in BT Navigator Only Includes Custom Nodes ](../../migration/Iron.html#plugin-libraries-in-bt-navigator-only-includes-custom-nodes)
      * [ New RViz Plugin for selecting Planners, Controllers, Goal Checkers, Progress Checkers and Smoothers ](../../migration/Iron.html#new-rviz-plugin-for-selecting-planners-controllers-goal-checkers-progress-checkers-and-smoothers)
      * [ RPP new optional ` interpolate_curvature_after_goal  ` behavior and fix conflict between ` use_rotate_to_heading  ` and ` allow_reversing  ` ](../../migration/Iron.html#rpp-new-optional-interpolate-curvature-after-goal-behavior-and-fix-conflict-between-use-rotate-to-heading-and-allow-reversing)
      * [ Cancel Checker Interface For GlobalPlanner ](../../migration/Iron.html#cancel-checker-interface-for-globalplanner)
      * [ New BtActionServer/BtNavigator parameter ](../../migration/Iron.html#new-btactionserver-btnavigator-parameter)
      * [ New collision monitor parameter ](../../migration/Iron.html#new-collision-monitor-parameter)
      * [ New graceful cancellation API for Controllers ](../../migration/Iron.html#new-graceful-cancellation-api-for-controllers)
      * [ Standardization of Plugin Naming with Double Colons (::) ](../../migration/Iron.html#standardization-of-plugin-naming-with-double-colons)
      * [ Collision monitor: dynamic radius for circle type polygons ](../../migration/Iron.html#collision-monitor-dynamic-radius-for-circle-type-polygons)
  * [ Simple Commander API ](../../commander_api/index.html)
    * [ Overview ](../../commander_api/index.html#overview)
    * [ Commander API ](../../commander_api/index.html#id1)
    * [ Costmap API ](../../commander_api/index.html#costmap-api)
    * [ Footprint Collision Checker API ](../../commander_api/index.html#footprint-collision-checker-api)
    * [ Examples and Demos ](../../commander_api/index.html#examples-and-demos)
  * [ Roadmaps ](../../roadmap/roadmap.html)
    * [ Jazzy Roadmap ](../../roadmap/roadmap.html#jazzy-roadmap)
    * [ Iron Roadmap ](../../roadmap/roadmap.html#iron-roadmap)
    * [ Humble Roadmap ](../../roadmap/roadmap.html#humble-roadmap)
  * [ About and Contact ](../../about/index.html)
    * [ Related Projects ](../../about/related_projects.html)
    * [ About ](../../about/index.html#id1)
    * [ Contact ](../../about/index.html#contact)


[ API Docs ](http://docs.ros.org/en/iron/p/nav2_controller "View API
documentation on docs.ros.org") [ Browse Code ](https://github.com/ros-
planning/navigation2/tree/iron/nav2_controller "View source code on
repository")


**Data Types:** ` single ` | ` double `


a community-maintained index of robotics software | [ privacy ](/privacy.txt)


Create an RRT* path planner. Increase the maximum connection distance.


  * [ Trust Center ](https://www.mathworks.com/company/aboutus/policies_statements/trust-center.html?s_tid=gf_tc)
  * [ Trademarks ](https://www.mathworks.com/company/aboutus/policies_statements/trademarks.html?s_tid=gf_trd)
  * [ Privacy Policy ](https://www.mathworks.com/company/aboutus/policies_statements.html?s_tid=gf_priv)
  * [ Preventing Piracy ](https://www.mathworks.com/company/aboutus/policies_statements/piracy.html?s_tid=gf_pir)
  * [ Application Status ](https://status.mathworks.com/?s_tid=gf_application)


Search Help Center


teb = controllerTEB(refpath,localmap);


* [ nav2_core ](https://github.com/ros-planning/navigation2/tree/humble/nav2_controller//plugins.xml)


    validator = validatorOccupancyMap(stateSpaceSE2,Map=map);
    validator.ValidationDistance = 0.1;


Field  |  Description
---|---
` LastFeasibleIdx ` |


Your Friendly Neighborhood Navigator here with a hot-hot-hot and extra special
announcement.


[ smac  ](https://discourse.ros.org/u/smac) August 30, 2023, 6:17pm  12


localmap = occupancyMap(15,15,map.Resolution);


###  ` RobotInformation ` —  Robot geometry information for collision checking
` struct("Dimension",[1 0.67],"Shape","Rectangle") ` (default) |  structure


[ nav2_controller/README.md ](https://github.com/ros-
planning/navigation2/tree/iron/nav2_controller/README.md "Open in git
repository")


_No additional authors._


###  Messages


**Set Up and Run Global Planner**


Name  |  Repo  |  Deps  |  [ nav2_rotation_shim_controller
](/p/nav2_rotation_shim_controller/github-ros-planning-navigation2#galactic) |
[ github-ros-planning-navigation2 ](/r/navigation2/github-ros-planning-
navigation2) |  [ ](/p/nav2_rotation_shim_controller/github-ros-planning-
navigation2#galactic-deps)
---|---|---
[ navigation2 ](/p/navigation2/github-ros-planning-navigation2#galactic) |  [
github-ros-planning-navigation2 ](/r/navigation2/github-ros-planning-
navigation2) |  [ ](/p/navigation2/github-ros-planning-navigation2#galactic-
deps)

###  Launch files


  * step
  * On this page
  * Syntax
  * Description
  * Examples
    * Compute Velocity Commands and Optimal Trajectory for Differential-Drive Robot Using Timed Elastic Band Algorithm
  * Input Arguments
    * controller
    * curState
    * curVel
  * Output Arguments
    * velcmds
    * timestamps
    * optPath
    * extraInfo
  * Version History
    * Output argument ` extraInfo ` returns exit condition
  * See Also


###  Recent questions tagged ` nav2_controller ` at **[ Robotics Stack
Exchange ](https://robotics.stackexchange.com/) **


_No direct system dependencies._


_Join the conversation_


1. To export the controller, we need to provide two lines


* Overview


Avoid unseen obstacles with time-optimal trajectories


Resources


Reference travel time between consecutive poses, specified as a positive
scalar in seconds. This property affects the addition and deletion of poses
for the optimized trajectory. Increase the value of this property to have
fewer poses and reduce it to have more poses in the output path.


Yes

activate()


[ ![MathWorks](/images/responsive/global/pic-header-mathworks-logo.svg)
](https://www.mathworks.com?s_tid=gn_logo)


Here, ` plugin_name_  +  ".desired_linear_vel"  ` is fetching the ROS
parameter ` desired_linear_vel  ` which is specific to our controller. Nav2
allows loading of multiple plugins, and to keep things organized, each plugin
is mapped to some ID/name. Now, if we want to retrieve the parameters for that
specific plugin, we use ` <mapped_name_of_plugin>.<name_of_parameter> ` as
done in the above snippet. For example, our example controller is mapped to
the name ` FollowPath  ` and to retrieve the ` desired_linear_vel  `
parameter, which is specific to “FollowPath”, we used `
FollowPath.desired_linear_vel  ` . In other words, ` FollowPath  ` is used as
a namespace for plugin-specific parameters. We will see more on this when we
discuss the parameters file (or params file).


###  Functions


* Requirements


An execution module implementing the ` nav2_msgs::action::FollowPath ` action
server is responsible for generating command velocities for the robot, given
the computed path from the planner module in ` nav2_planner ` . The
nav2_controller package is designed to be loaded with multiple plugins for
path execution. The plugins need to implement functions in the virtual base
class defined in the ` controller ` header file in ` nav2_core ` package. It
also contains progress checkers and goal checker plugins to abstract out that
logic from specific controller implementations.


> At some point, its in my bank of future projects.


###  ` timestamps ` — Timestamps corresponding to velocity commands
_N_ -element column vector


Failed to get question list, you can ticket an issue [ here
](https://github.com/ros-infrastructure/rosindex/issues/new)


* [ nav2_core ](https://github.com/ros-planning/navigation2/tree/galactic/nav2_controller//plugins.xml)


###  Services


#  Nav2 Controller


teb = controllerTEB(refpath,localmap);


You can now specify


Create an [ ` occupancyMap ` ](occupancymap.html) object from a parking lot
map and set the map resolution to 3 cells per meter.


_No message files found._


###  R2023b:  Output argument ` extraInfo ` returns exit condition


###  ` curState ` —  Current pose of robot
three-element vector of form [ _x_ _y_ _theta_ ]


No questions yet, you can ask one [ here
](https://robotics.stackexchange.com/questions/tagged/nav2_controller+iron) .


Select the China site (in Chinese or English) for best site performance. Other
MathWorks country sites are not optimized for visits from your location.


    geometry_msgs::msg::TwistStamped PurePursuitController::computeVelocityCommands(
      const geometry_msgs::msg::PoseStamped & pose,
      const geometry_msgs::msg::Twist & velocity,
      nav2_core::GoalChecker * /*goal_checker*/)
    {
      // Find the first pose which is at a distance greater than the specified lookahead distance
      auto goal_pose = std::find_if(
        global_plan_.poses.begin(), global_plan_.poses.end(),
        [&](const auto & global_plan_pose) {
          return hypot(
            global_plan_pose.pose.position.x,
            global_plan_pose.pose.position.y) >= lookahead_dist_;
        })->pose;

      double linear_vel, angular_vel;

      // If the goal pose is in front of the robot then compute the velocity using the pure pursuit algorithm
      // else rotate with the max angular velocity until the goal pose is in front of the robot
      if (goal_pose.position.x > 0) {

        auto curvature = 2.0 * goal_pose.position.y /
          (goal_pose.position.x * goal_pose.position.x + goal_pose.position.y * goal_pose.position.y);
        linear_vel = desired_linear_vel_;
        angular_vel = desired_linear_vel_ * curvature;
      } else {
        linear_vel = 0.0;
        angular_vel = max_angular_vel_;
      }

      // Create and publish a TwistStamped message with the desired velocity
      geometry_msgs::msg::TwistStamped cmd_vel;
      cmd_vel.header.frame_id = pose.header.frame_id;
      cmd_vel.header.stamp = clock_->now();
      cmd_vel.twist.linear.x = linear_vel;
      cmd_vel.twist.angular.z = max(
        -1.0 * abs(max_angular_vel_), min(
          angular_vel, abs(
            max_angular_vel_)));


Timestamps corresponding to velocity commands, returned as an _N_ -element
column vector.


You clicked a link that corresponds to this MATLAB command:


The gif is not displayed here, but it shows a lot about its quality. You are
carrying the ROS community on your shoulders with your state of the art
packages, thanks a lot!


**Introduced in R2023a**


###  Europe


[ expand all in page ](javascript:void\(0\);)


###  Americas


    rrtstar = plannerRRTStar(validator.StateSpace,validator);
    rrtstar.MaxConnectionDistance = 0.2;


Look-ahead time, specified as a positive scalar in seconds. The controller
generates velocity commands and optimizes the trajectory until the controller
reaches the look-ahead time. A higher look-ahead time generates velocity
commands further into the future. This enables the robot to react earlier to
unseen obstacles, but increases the controller execution time. Conversely, a
shorter look-ahead time reduces the available time to react to new, unknown
obstacles, but enables the controller to run at a faster rate.


No version for distro **crystal** . Known supported distros are highlighted in
the buttons above.


` [  ___  ,  ` extraInfo ` ] = step(  ___  ) ` returns extra information, `
extraInfo ` , to evaluate the solution, in addition to all arguments from the
previous syntax.


* [ Documentation Home  ](../../index.html?s_tid=CRUX_lftnav)


[ example ](controllerteb.step.html#mw_6ba595a8-e98f-4a3d-8f8b-04092a4603b4)


Cost function weight for time, specified as a positive scalar. To lower the
travel time, increase this weight value.

` Smoothness ` |


* Carl Delsey


EDIT: I opened a [ backport PR ](https://github.com/ros-
planning/navigation2/pull/3439/files) in the meantime


CHANGELOG


Name  |  Repo  |  Deps  |  [ nav2_graceful_controller
](/p/nav2_graceful_controller/github-ros-planning-navigation2#humble) |  [
github-ros-planning-navigation2 ](/r/navigation2/github-ros-planning-
navigation2) |  [ ](/p/nav2_graceful_controller/github-ros-planning-
navigation2#humble-deps)
---|---|---
[ nav2_rotation_shim_controller ](/p/nav2_rotation_shim_controller/github-ros-
planning-navigation2#humble) |  [ github-ros-planning-navigation2
](/r/navigation2/github-ros-planning-navigation2) |  [
](/p/nav2_rotation_shim_controller/github-ros-planning-navigation2#humble-
deps)
[ navigation2 ](/p/navigation2/github-ros-planning-navigation2#humble) |  [
github-ros-planning-navigation2 ](/r/navigation2/github-ros-planning-
navigation2) |  [ ](/p/navigation2/github-ros-planning-navigation2#humble-
deps)

###  Launch files


##  Overview  ¶


` [  ` velcmds ` ,  ` timestamps ` ,  ` optPath ` ] = step(  ` controller ` ,
` curState ` ,  ` curVel ` ) ` computes the linear and angular velocity
commands ` velcmds ` , with their corresponding ` timestamps ` and
corresponding optimized path ` optPath ` , for the specified current pose `
curState ` and current velocity ` curVel ` of a robot.


###  3- Pass the plugin name through the params file  ¶


**Data Types:** ` single ` | ` double `


Yes

computeVelocityCommands()


[ General  ](/c/general/8)


You can also select a web site from the following list:


×  ![MathWorks](/images/responsive/global/pic-header-mathworks-logo2.svg)


  * [ Trial Software ](/campaigns/products/trials.html?prodcode=NV&s_tid=doc_trial_NV_tb)
  * [ Trial Software ](/campaigns/products/trials.html?prodcode=NV&s_tid=doc_trial_NV_tb)
  * [ Product Updates ](/support/web_downloads_bounce.html?s_tid=hc_prod_update&s_cid=1008_degr_docdn_270055)
  * [ Product Updates ](/support/web_downloads_bounce.html?s_tid=hc_prod_update&s_cid=1008_degr_docdn_270055)


###  [ nav2_controller ](/p/nav2_controller) package from [ navigation2
](/r/navigation2/github-ros-planning-navigation2) repo


![](https://sea2.discourse-
cdn.com/business7/user_avatar/discourse.ros.org/smac/48/6763_2.png) smac:


###  ` LookAheadTime ` —  Look-ahead time
` 5 ` (default) |  positive scalar


    void PurePursuitController::configure(
      const rclcpp_lifecycle::LifecycleNode::WeakPtr & parent,
      std::string name, std::shared_ptr<tf2_ros::Buffer> tf,
      std::shared_ptr<nav2_costmap_2d::Costmap2DROS> costmap_ros)
    {
      node_ = parent;
      auto node = node_.lock();

      costmap_ros_ = costmap_ros;
      tf_ = tf;
      plugin_name_ = name;
      logger_ = node->get_logger();
      clock_ = node->get_clock();

      declare_parameter_if_not_declared(
        node, plugin_name_ + ".desired_linear_vel", rclcpp::ParameterValue(
          0.2));
      declare_parameter_if_not_declared(
        node, plugin_name_ + ".lookahead_dist",
        rclcpp::ParameterValue(0.4));
      declare_parameter_if_not_declared(
        node, plugin_name_ + ".max_angular_vel", rclcpp::ParameterValue(
          1.0));
      declare_parameter_if_not_declared(
        node, plugin_name_ + ".transform_tolerance", rclcpp::ParameterValue(
          0.1));

      node->get_parameter(plugin_name_ + ".desired_linear_vel", desired_linear_vel_);
      node->get_parameter(plugin_name_ + ".lookahead_dist", lookahead_dist_);
      node->get_parameter(plugin_name_ + ".max_angular_vel", max_angular_vel_);
      double transform_tolerance;
      node->get_parameter(plugin_name_ + ".transform_tolerance", transform_tolerance);
      transform_tolerance_ = rclcpp::Duration::from_seconds(transform_tolerance);
    }


Run the command by entering it in the MATLAB Command Window. Web browsers do
not support MATLAB commands.


In ` setPlan()  ` method, we receive the updated global path for the robot to
follow. In our example, we transform the received global path into the frame
of the robot and then store this transformed global path for later use.


####  Additional Links


###  Package Dependencies


#  Nav2 Controller


  * [ Belgium ](https://nl.mathworks.com) (English)
  * [ Denmark ](https://se.mathworks.com) (English)
  * [ Deutschland ](https://de.mathworks.com) (Deutsch)
  * [ España ](https://es.mathworks.com) (Español)
  * [ Finland ](https://se.mathworks.com) (English)
  * [ France ](https://fr.mathworks.com) (Français)
  * [ Ireland ](https://uk.mathworks.com) (English)
  * [ Italia ](https://it.mathworks.com) (Italiano)
  * [ Luxembourg ](https://nl.mathworks.com) (English)


* Minimum turning radius for a vehicle on the optimized path by using the ` MinTurningRadius ` property.


    curpose = refpath(1,:);
    curvel = [0 0];
    simtime = 0;
    % Reducing timestep can lead to more accurate path tracking.
    timestep = 0.1;
    itr = 0;
    goalReached = false;


At some point, its in my bank of future projects. There are more pressing
needs in planning / control that need to be addressed first but after all
those algorithms are around, I can take a higher level view of what’s been
created to see what the best way to integrate those capabilities across the
board with.


**Data Types:** ` struct `


` controller = controllerTEB(  ___  ,Name=Value)  `


Set the start and goal states.


Extra information, returned as a structure. The fields of the structure are:


latest


[ Navigation Stack  ](/c/navigation/44)


_No CHANGELOG found._


_No service files found_


BTW;
Although the dynamic obstacles are handled ‘more dynamically’ here, do you
have a plan to integrate dynamic obstacles with known poses and velocities
like TEB? [ teb_local_planner/Tutorials/Incorporate dynamic obstacles - ROS
Wiki
](http://wiki.ros.org/teb_local_planner/Tutorials/Incorporate%20dynamic%20obstacles)
Could be very useful for fast robot fleets.


Choose a web site to get translated content where available and see local
events and offers. Based on your location, we recommend that you select: ****
.


This definitely would need a deep dive into the details. Maybe in some words,
If you ever came across Model Predictive Path Following ( [ MPFC
](https://ieeexplore.ieee.org/document/5717042) ) or Model Predictive
Contouring Control ( [ MPCC ](https://ieeexplore.ieee.org/document/5717042) ),
what do MPPI introduce that the other two methods lack?


Specify the properties of the ` controllerTEB ` object.


_Not currently indexed._


Resources


      * [ Navigation Subtree ](../../behavior_trees/overview/detailed_behavior_tree_walkthrough.html#navigation-subtree)
      * [ Recovery Subtree ](../../behavior_trees/overview/detailed_behavior_tree_walkthrough.html#recovery-subtree)
    * [ Navigate To Pose ](../../behavior_trees/trees/nav_to_pose_recovery.html)
    * [ Navigate Through Poses ](../../behavior_trees/trees/nav_through_poses_recovery.html)
    * [ Navigate To Pose and Pause Near Goal-Obstacle ](../../behavior_trees/trees/nav_to_pose_and_pause_near_goal_obstacle.html)
    * [ Navigate To Pose With Consistent Replanning And If Path Becomes Invalid ](../../behavior_trees/trees/nav_to_pose_with_consistent_replanning_and_if_path_becomes_invalid.html)
    * [ Follow Dynamic Point ](../../behavior_trees/trees/follow_point.html)
    * [ Odometry Calibration ](../../behavior_trees/trees/odometry_calibration.html)
  * [ Navigation Plugins ](../../plugins/index.html)
    * [ Behavior-Tree Navigators ](../../plugins/index.html#behavior-tree-navigators)
    * [ Costmap Layers ](../../plugins/index.html#costmap-layers)
    * [ Costmap Filters ](../../plugins/index.html#costmap-filters)
    * [ Controllers ](../../plugins/index.html#controllers)
    * [ Planners ](../../plugins/index.html#planners)
    * [ Smoothers ](../../plugins/index.html#smoothers)
    * [ Behaviors ](../../plugins/index.html#behaviors)
    * [ Waypoint Task Executors ](../../plugins/index.html#waypoint-task-executors)
    * [ Goal Checkers ](../../plugins/index.html#goal-checkers)
    * [ Progress Checkers ](../../plugins/index.html#progress-checkers)
    * [ Behavior Tree Nodes ](../../plugins/index.html#behavior-tree-nodes)
  * [ Migration Guides ](../../migration/index.html)
    * [ Dashing to Eloquent ](../../migration/Dashing.html)
      * [ New Packages ](../../migration/Dashing.html#new-packages)
      * [ New Plugins ](../../migration/Dashing.html#new-plugins)
      * [ Navigation2 Architectural Changes ](../../migration/Dashing.html#navigation2-architectural-changes)
    * [ Eloquent to Foxy ](../../migration/Eloquent.html)
      * [ General ](../../migration/Eloquent.html#general)
      * [ Server Updates ](../../migration/Eloquent.html#server-updates)
      * [ New Plugins ](../../migration/Eloquent.html#new-plugins)
      * [ Map Server Re-Work ](../../migration/Eloquent.html#map-server-re-work)
      * [ New Particle Filter Messages ](../../migration/Eloquent.html#new-particle-filter-messages)
      * [ Selection of Behavior Tree in each navigation action ](../../migration/Eloquent.html#selection-of-behavior-tree-in-each-navigation-action)
      * [ FollowPoint Capability ](../../migration/Eloquent.html#followpoint-capability)
      * [ New Costmap Layer ](../../migration/Eloquent.html#new-costmap-layer)
    * [ Foxy to Galactic ](../../migration/Foxy.html)
      * [ NavigateToPose Action Feedback updates ](../../migration/Foxy.html#navigatetopose-action-feedback-updates)
      * [ NavigateToPose BT-node Interface Changes ](../../migration/Foxy.html#navigatetopose-bt-node-interface-changes)
      * [ NavigateThroughPoses and ComputePathThroughPoses Actions Added ](../../migration/Foxy.html#navigatethroughposes-and-computepaththroughposes-actions-added)
      * [ ComputePathToPose BT-node Interface Changes ](../../migration/Foxy.html#computepathtopose-bt-node-interface-changes)
      * [ ComputePathToPose Action Interface Changes ](../../migration/Foxy.html#computepathtopose-action-interface-changes)


If you have familiarity with the code bases of ROS 1 controllers, you could
probably knock out the bulk of it in a day or so. Differently from other new
algorithms I’ve worked on in recent years, the MPPI Controller has a unique
wrapper for dynamic parameters that I think would be quite the challenge to
backport to ROS 1 - and the parameters are really baked into that.


No version for distro **noetic** . Known supported distros are highlighted in
the buttons above.


Plan a path with default settings.


_N_ is affected by the [ ReferenceDeltaTime
](controllerteb.html#mw_6da4b9f0-6f57-4c11-93a2-6b58b1867fd4) and [
LookAheadTime  ](controllerteb.html#mw_cd2437c1-decb-4378-9581-58cb25711d8b)
properties of  ` controller ` . The algorithm tries to keep the difference
between any two consecutive [ ` timestamps `
](controllerteb.step.html#mw_5f66646a-9922-4c14-a3bc-e86df0dd9ee4) close to `
ReferenceDeltaTime ` . If the gap between a pair of consecutive timestamps is
greater than ` ReferenceDeltaTime ` , the function adds poses and timestamps
to the path. If the gap is less than ` ReferenceDeltaTime ` , the function
removes poses and timestamps from the path. In addition, the algorithm tries
to keep the final value of ` timestamps ` close to ` LookAheadTime ` , so
increasing ` LookAheadTime ` increases _N_ as well.


**Set Up and Run Global Planner**


###  Dependant Packages


An execution module implementing the ` nav2_msgs::action::FollowPath ` action
server is responsible for generating command velocities for the robot, given
the computed path from the planner module in ` nav2_planner ` . The
nav2_controller package is designed to be loaded with plugins for path
execution. The plugins need to implement functions in the virtual base class
defined in the ` controller ` header file in ` nav2_core ` package.


The passed-in arguments are stored in member variables so that they can be
used at a later stage if needed.


_No message files found._


refpath(2:end-1,3) = headingToNextPose(2:end-1);


In controllers, ` configure()  ` method must set member variables from ROS
parameters and perform any initialization required.


Overall, there is no intent or roadmap to regress this work to ROS 1. This is
all uniquely available and supported in Nav2, which is a ROS 2 based project.
I hope you’ll consider moving to ROS 2, the water’s fine
![:sunglasses:](https://emoji.discourse-cdn.com/twitter/sunglasses.png?v=12)


No version for distro **jade** . Known supported distros are highlighted in
the buttons above.


**Set Up and Run Local Planner**


  1. [ Home ](/)
  2. [ Packages ](/packages)
  3. nav2_controller


[ API Docs ](http://docs.ros.org/en/foxy/p/nav2_controller "View API
documentation on docs.ros.org") [ Browse Code ](https://github.com/ros-
planning/navigation2/tree/foxy-devel/nav2_controller "View source code on
repository")


###  Compute Velocity Commands and Optimal Trajectory for Differential-Drive
Robot Using Timed Elastic Band Algorithm


Create an [ ` occupancyMap ` ](occupancymap.html) object from a parking lot
map and set the map resolution to 3 cells per meter.


[ nav2_controller/README.md ](https://github.com/ros-
planning/navigation2/tree/foxy-devel/nav2_controller/README.md "Open in git
repository")


Select the China site (in Chinese or English) for best site performance. Other
MathWorks country sites are not optimized for visits from your location.


2 Likes


Minimum turning radius for the vehicle on the optimized path, specified as a
nonnegative scalar. This value corresponds to the radius of the turning circle
at the maximum steering angle of the vehicle. Units are in meters.


Compute velocity commands and optimal trajectory for subsequent time steps


* Tutorial Steps


1 Like


---

[
API Docs ](http://docs.ros.org/en/foxy/p/nav2_controller "View API
documentation on docs.ros.org") [
Browse Code ](https://github.com/ros-planning/navigation2/tree/foxy-
devel/nav2_controller "View source code on repository")


###  Plugins


Name  |  Repo  |  Deps  |  [ navigation2 ](/p/navigation2/github-ros-planning-
navigation2#eloquent) |  [ github-ros-planning-navigation2
](/r/navigation2/github-ros-planning-navigation2) |  [
](/p/navigation2/github-ros-planning-navigation2#eloquent-deps)
---|---|---

###  Launch files


  * [ Navigation Toolbox ](../index.html?s_tid=CRUX_lftnav)
  * [ Motion Planning  ](../motion-planning.html?s_tid=CRUX_lftnav)


  * [ ![Facebook](/images/responsive/global/ico-facebook.svg) ](https://www.facebook.com/MATLAB)
  * [ ![X](/images/responsive/global/ico-x.svg) ](https://twitter.com/MATLAB)
  * [ ![Instagram](/etc.clientlibs/mathworks/clientlibs/customer-ui/templates/common/resources/images/ico-instagram.svg) ](https://www.instagram.com/matlab/)
  * [ ![YouTube](/images/responsive/global/ico-youtube.svg) ](https://www.youtube.com/user/MATLAB)
  * [ ![LinkedIn](/images/responsive/global/ico-linkedin.svg) ](https://www.linkedin.com/company/the-mathworks_2)
  * [ ![RSS](/images/responsive/global/ico-rss.svg) ](https://www.mathworks.com/company/rss.html)


![](/assets/package.png) |


[ Navigation Stack  ](/c/navigation/44)


  * Help Center
  * MathWorks


The Nav2 Controller is a Task Server in Nav2 that implements the `
nav2_msgs::action::FollowPath ` action server.


#  [ [Nav2] Model Predictive Path Integral (MPPI) Controller Now Available!
](/t/nav2-model-predictive-path-integral-mppi-controller-now-available/30054)


    start = [2 9 0];
    goal = [27 18 -pi/2];


We will be implementing the pure pursuit controller. The annotated code in
this tutorial can be found in [ navigation_tutorials ](https://github.com/ros-
planning/navigation2_tutorials) repository as the `
nav2_pure_pursuit_controller  ` . This package can be considered as a
reference for writing your own controller plugin.


[ nav2_controller/README.md ](https://github.com/ros-
planning/navigation2/tree/humble/nav2_controller/README.md "Open in git
repository")


Initialize parameters.


_No additional authors._


[ ` step ` ](controllerteb.step.html) |  Compute velocity commands and optimal
trajectory for subsequent time steps
---|---
[ ` clone ` ](controllerteb.clone.html) |  Create deep clone of `
controllerTEB ` object

##  Examples


  * Documentation
  * [ Examples ](../examples.html?category=motion-planning&s_tid=CRUX_topnav)
  * [ Functions ](../referencelist.html?type=function&category=motion-planning&s_tid=CRUX_topnav)
  * [ Blocks ](../referencelist.html?type=block&category=motion-planning&s_tid=CRUX_topnav)
  * [ Apps ](../referencelist.html?type=app&category=motion-planning&s_tid=CRUX_topnav)
  * [ Videos ](/support/search.html?fq\[\]=asset_type_name:video%20category:nav/motion-planning&s_tid=CRUX_topnav)
  * [ Answers ](/support/search.html?fq\[\]=asset_type_name:answer%20category:nav/motion-planning&s_tid=CRUX_topnav)


Current velocity of the robot, specified as a two-element vector of the form [
_v_ _w_ ]. _v_ specifies the linear velocity of the robot in meters per
second. _w_ specifies the angular velocity of the robot in radians per second.


3. Next step would be to export plugin using ` CMakeLists.txt  ` by using CMake function ` pluginlib_export_plugin_description_file()  ` . This function installs the plugin description file to ` share  ` directory and sets ament indexes to make it discoverable.


###  1- Create a new Controller Plugin  ¶


_No service files found_


No questions yet, you can ask one [ here
](https://robotics.stackexchange.com/questions/tagged/nav2_controller+humble)
.


Controller action interface


pluginlib_export_plugin_description_file(nav2_core pure_pursuit_controller_plugin.xml)


_Since R2023a_


* 5 — Indicates that the robot will not reach the reference path within a specified look-ahead time even if it travels at a maximum linear velocity from its current position.


Search MathWorks.com


###  [ nav2_controller ](/p/nav2_controller) package from [ navigation2
](/r/navigation2/github-ros-planning-navigation2) repo


    void PurePursuitController::setPlan(const nav_msgs::msg::Path & path)
    {
      // Transform global path into the robot's frame
      global_plan_ = transformGlobalPlan(path);
    }


  * Overview
  * 1  Assets
  * 16  Dependencies
  * 0  Tutorials
  * 0  Q & A


* [ ` controllerPurePursuit ` ](controllerpurepursuit-system-object.html) |  [ ` plannerAStarGrid ` ](plannerastargrid.html)


© Copyright 2023.


Cost function weight for maintaining a safe distance from obstacles, specified
as a positive scalar. To prioritize maintaining a safe distance from
obstacles, increase this weight value.

**Data Types:** ` struct `


      * [ Appendix ](../../tutorials/docs/docker_dev.html#appendix)
        * [ Nav2 Development Image ](../../tutorials/docs/docker_dev.html#nav2-development-image)
        * [ Nav2 Deployment Image ](../../tutorials/docs/docker_dev.html#nav2-deployment-image)
  * [ Plugin Tutorials ](../index.html)
    * [ Writing a New Costmap2D Plugin ](writing_new_costmap2d_plugin.html)
      * [ Overview ](writing_new_costmap2d_plugin.html#overview)
      * [ Requirements ](writing_new_costmap2d_plugin.html#requirements)
      * [ Tutorial Steps ](writing_new_costmap2d_plugin.html#tutorial-steps)
        * [ 1- Write a new Costmap2D plugin ](writing_new_costmap2d_plugin.html#write-a-new-costmap2d-plugin)
        * [ 2- Export and make GradientLayer plugin ](writing_new_costmap2d_plugin.html#export-and-make-gradientlayer-plugin)
        * [ 3- Enable the plugin in Costmap2D ](writing_new_costmap2d_plugin.html#enable-the-plugin-in-costmap2d)
        * [ 4- Run GradientLayer plugin ](writing_new_costmap2d_plugin.html#run-gradientlayer-plugin)
    * [ Writing a New Planner Plugin ](writing_new_nav2planner_plugin.html)
      * [ Overview ](writing_new_nav2planner_plugin.html#overview)
      * [ Requirements ](writing_new_nav2planner_plugin.html#requirements)
      * [ Tutorial Steps ](writing_new_nav2planner_plugin.html#tutorial-steps)
        * [ 1- Creating a new Planner Plugin ](writing_new_nav2planner_plugin.html#creating-a-new-planner-plugin)
        * [ 2- Exporting the planner plugin ](writing_new_nav2planner_plugin.html#exporting-the-planner-plugin)
        * [ 3- Pass the plugin name through params file ](writing_new_nav2planner_plugin.html#pass-the-plugin-name-through-params-file)
        * [ 4- Run StraightLine plugin ](writing_new_nav2planner_plugin.html#run-straightline-plugin)
    * Writing a New Controller Plugin
      * Overview
      * Requirements
      * Tutorial Steps
        * 1- Create a new Controller Plugin
        * 2- Exporting the controller plugin
        * 3- Pass the plugin name through the params file
        * 4- Run Pure Pursuit Controller plugin
    * [ Writing a New Behavior Tree Plugin ](writing_new_bt_plugin.html)
      * [ Overview ](writing_new_bt_plugin.html#overview)
      * [ Requirements ](writing_new_bt_plugin.html#requirements)
      * [ Tutorial Steps ](writing_new_bt_plugin.html#tutorial-steps)
        * [ 1- Creating a new BT Plugin ](writing_new_bt_plugin.html#creating-a-new-bt-plugin)
        * [ 2- Exporting the planner plugin ](writing_new_bt_plugin.html#exporting-the-planner-plugin)
        * [ 3- Add plugin library name to config ](writing_new_bt_plugin.html#add-plugin-library-name-to-config)
        * [ 4- Run Your Custom plugin ](writing_new_bt_plugin.html#run-your-custom-plugin)
    * [ Writing a New Behavior Plugin ](writing_new_behavior_plugin.html)
      * [ Overview ](writing_new_behavior_plugin.html#overview)
      * [ Requirements ](writing_new_behavior_plugin.html#requirements)
      * [ Tutorial Steps ](writing_new_behavior_plugin.html#tutorial-steps)


Create a deep clone of the ` controllerTEB ` object.


**Note**


Close


* [ Robotics and Autonomous Systems  ](../../overview/robotics-and-autonomous-systems.html?s_tid=hc_product_group_bc)


* 1 — Indicates that the trajectory output returned by the ` step ` function is collision free only until the index value specified using ` LastFeasibleIdx ` .


[ Help Center ](../../index.html) [ Help Center ](../../index.html)


###  Objects


###  C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.


* Maximum velocity for reverse motion by using the ` MaxReverseVelocity ` property.


_No direct system dependencies._


  * Documentation
  * [ Examples ](../examples.html?category=motion-planning&s_tid=CRUX_topnav)
  * [ Functions ](../referencelist.html?type=function&category=motion-planning&s_tid=CRUX_topnav)
  * [ Blocks ](../referencelist.html?type=block&category=motion-planning&s_tid=CRUX_topnav)
  * [ Apps ](../referencelist.html?type=app&category=motion-planning&s_tid=CRUX_topnav)
  * [ Videos ](/support/search.html?fq\[\]=asset_type_name:video%20category:nav/motion-planning&s_tid=CRUX_topnav)
  * [ Answers ](/support/search.html?fq\[\]=asset_type_name:answer%20category:nav/motion-planning&s_tid=CRUX_topnav)


MathWorks


###  Europe


_No additional links._


####  Additional Links


###  ` extraInfo ` — Extra information
structure


|  0  |  481  |  March 28, 2024
[ [Nav2] "Regulated Pure Pursuit for Robot Path Tracking" Published in
Autonomous Robots ](https://discourse.ros.org/t/nav2-regulated-pure-pursuit-
for-robot-path-tracking-published-in-autonomous-robots/31879)


See its [ Configuration Guide Page
](https://navigation.ros.org/configuration/packages/configuring-controller-
server.html) for additional parameter descriptions and a [ tutorial about
writing controller plugins
](https://navigation.ros.org/plugin_tutorials/docs/writing_new_nav2controller_plugin.html)
.


Create a local ` occupancyMap ` object with a width and height of 15 meters
and the same resolution as the global map.


No

setSpeedLimit()


Safe distance between the robot and the obstacles, specified as a positive
scalar, in meters. Note that this is a soft constraint that the planner may
ignore.


No questions yet, you can ask one [ here
](https://robotics.stackexchange.com/questions/tagged/nav2_controller+foxy) .


_No message files found._


[ https://github.com/ros-
planning/navigation2/raw/main/nav2_mppi_controller/media/demo.gif  (image
larger than 4.95 MB)  ](https://github.com/ros-
planning/navigation2/raw/main/nav2_mppi_controller/media/demo.gif)


Robot geometry information for collision checking, specified as a structure.
The fields of the structure are:


###  Source Tutorials


  * Overview
  * 0  Assets
  * 13  Dependencies
  * 0  Tutorials
  * 0  Q & A


[ collapse all ](javascript:void\(0\);)


×  ![MathWorks](/images/responsive/global/pic-header-mathworks-logo2.svg)


This tutorial shows how to create your own controller [ plugin
](https://index.ros.org/p/pluginlib/) .


##  Version History


No version for distro **rolling** . Known supported distros are highlighted in
the buttons above.


Method is called when controller server enters on_deactivate state. Ideally
this method should implement operations which are neccessary before controller
goes to an inactive state.


* [ Get MATLAB ](https://login.mathworks.com/embedded-login/landing.html?cid=getmatlab&s_tid=gn_getml)


####  Authors


**Checkout URI** |  [ https://github.com/ros-planning/navigation2.git
](https://github.com/ros-planning/navigation2.git)
---|---
**VCS Type** |  git
**VCS Version** |  iron
**Last Updated**

2024-04-04  |  **Dev Status** |  DEVELOPED
**CI status** |  No Continuous Integration
**Released** |  RELEASED
**Tags** |  _No category tags._
**Contributing** |  [ Help Wanted (  0  ) ](/r/navigation2/#iron-contribute-
lists-help-wanted)
[ Good First Issues (  0  ) ](/r/navigation2/#iron-contribute-lists-good-
first-issue)
[ Pull Requests to Review (  0  ) ](/r/navigation2/#iron-contribute-lists-
pull-requests)

###  Package Description


##  Description


  * [ Trial Software ](/campaigns/products/trials.html?prodcode=NV&s_tid=doc_trial_NV_tb)
  * [ Trial Software ](/campaigns/products/trials.html?prodcode=NV&s_tid=doc_trial_NV_tb)
  * [ Product Updates ](/support/web_downloads_bounce.html?s_tid=hc_prod_update&s_cid=1008_degr_docdn_270055)
  * [ Product Updates ](/support/web_downloads_bounce.html?s_tid=hc_prod_update&s_cid=1008_degr_docdn_270055)


© 1994-2024 The MathWorks, Inc.


Method is called when controller server goes to on_cleanup state. Ideally this
method should clean up resources which are created for the controller.


Then goto RViz and click on the “2D Pose Estimate” button at the top and point
the location on the map as it was described in [ Getting Started
](../../getting_started/index.html#getting-started) . The robot will localize
on the map and then click on the “Nav2 goal” and click on the pose where you
want your robot to navigate to. After that controller will make the robot
follow the global path.


###  Plugins


* ` base  class  ` : Name of the base class.


_No service files found_


Great work! Looking forward to testing it on an ackerman steering. Since it
interfaces with nav2::core, I’m assuming it’s only available on ROS2? What
would be the best way to port to ROS1?


Yes

cancel()


_No launch files found_


* Carl Delsey


* [ callback ](/questions/scope:all/sort:activity-desc/tags:callback/page:1/)


    import rclpy
    from rclpy.node import Node

    class TestParamsCallback(Node):
        def __init__(self):
            super().__init__('test_params_callback_rclpy')
            self.declare_parameter('camera_device_port', '/dev/ttyACM0')
            self.declare_parameter('simulation_mode', False)
            self.declare_parameter('battery_percentage_warning', 15.0)

            self.camera_device_port_ = self.get_parameter('camera_device_port').value
            self.simulation_mode_ = self.get_parameter('simulation_mode').value
            self.battery_percentage_warning_ = self.get_parameter('battery_percentage_warning').value

    def main(args=None):
        rclpy.init(args=args)
        node = TestParamsCallback()
        rclpy.spin(node)
        node.destroy_node()
        rclpy.shutdown()

    if __name__ == "__main__":
        main()


##  Question Tools


Cancel  Submit feedback


Additional navigation options


##  Footer


[
![@ivanpauno](https://avatars.githubusercontent.com/u/26796393?s=80&u=8f754ac57482921ea34e7bc6fa3491a127814a74&v=4)
](/ivanpauno)


edited


> Hey, this is an odd thing with lambdas. Here's the fix:
>
> Change
>
>
>                                             lambda msg:
> self.dock_state_clb(msg, robot_name),
>
> To:
>
>
>                                             lambda msg=msg:
> self.dock_state_clb(msg, robot_name),
>
> (FYI, if you use mypy it'll catch these errors!)
>
> [ More on this topic ](https://stackoverflow.com/questions/19837486/lambda-
> in-a-loop)


[
![@TheConstructAi](https://avatars.githubusercontent.com/u/80715513?s=80&u=0086e3dca53758236a47b310ef33222ebaa05ad0&v=4)
](/TheConstructAi)


ROS2 Python: Add arguments to callback


So, if you open 2 terminals, run the node in terminal 1, and try to change the
parameter’s value in terminal 2:


##  Conclusion – rclpy parameter callback


**[ ramezanifar ](/ramezanifar) ** commented  Nov 30, 2020


#  Search code, repositories, users, issues, pull requests...


[ edit ](/questions/346810/edit/) [ retag ](/s/questions/346810/retag/) flag
offensive  [ close ](/questions/346810/close/) merge  delete


**[ KiloNovemberDelta ](/KiloNovemberDelta) ** commented  Feb 20, 2023  •


[ Powered by Askbot version 0.10.2 ](http://askbot.com)


Tried this and it stays with the last value of the multiple subscribers done:


[ ![cc-by-sa](/m/default/media/images/cc-by-sa.png?v=28)
](http://creativecommons.org/licenses/by-sa/3.0/legalcode) ROS Answers is
licensed under Creative Commons Attribution 3.0 Content on this site is
licensed under a [ Creative Commons Attribution Share Alike 3.0
](http://creativecommons.org/licenses/by-sa/3.0/legalcode) license.


Asked: ** 2020-03-16 08:05:40 -0500  **


{{ message }}


    def parameters_callback(self, params):
        for param in params:
            if param.name == "battery_percentage_warning":
                self.battery_percentage_warning_ = param.value
        return SetParametersResult(successful=True)


All reactions


No branches or pull requests


So, as a best practice, always check the type of parameters in your parameters
callbacks.


Functional


This seemed to work and not get stuck in the last name


**Learn ROS2 in a week**


Copy link


    * [ CI/CD & Automation ](/solutions/ci-cd/)
    * [ DevOps ](/solutions/devops/)
    * [ DevSecOps  ](https://resources.github.com/devops/fundamentals/devsecops/)


**Don't miss this opportunity:**


So how to make sure the parameters you get in the callback have the correct
type?


You can simply check for each param you’ve declared (using the param’s name).
Once you’ve found a match you can update the corresponding class attribute in
your program.


###  The code


add a comment


####  Feature description


Another solution that may be worth mentioning here is to use [ `
functools.partial ` ](https://docs.python.org/3/library/functools.html#) :


[ Generating a C++ Code Coverage Report with Colcon
](/question/355388/generating-a-c-code-coverage-report-with-colcon/)


The site is read-only. Please transition to use Robotics Stack Exchange


[
![@ivanpauno](https://avatars.githubusercontent.com/u/26796393?s=40&u=8f754ac57482921ea34e7bc6fa3491a127814a74&v=4)
](/ivanpauno) [ ivanpauno ](/ivanpauno) added the [ question
](/ros2/rclpy/labels/question) Further information is requested  label  Oct
23, 2020