鱼香ROS社区
    • 版块
    • 最新
    • 未解决
    • 已解决
    • 群组
    • 注册
    • 登录
    紧急通知:禁止一切关于政治&VPN翻墙等话题,发现相关帖子会立马删除封号
    提问前必看的发帖注意事项: 社区问答规则(小鱼个人)更新 | 高质量帖子发布指南

    8.2.4配置导航参数并测试失败

    已定时 已固定 已锁定 已移动
    动手学ROS2
    插件替换 rviz不反应
    2
    5
    633
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • 4
      开心
      最后由 编辑

      问题:修改为"nav捻仓tom_planner/CustomPlanner,按清单配置后,rviz初始化位置后不反应
      planner_server代码:

      planner_server:
        ros__parameters:
          #expected_planner_frequency: 20.0
          use_sim_time: True
          planner_plugins: ["GridBased"]
          GridBased:
            #plugin: "nav2_navfn_planner/NavfnPlanner"
            plugin: "nav2_custom_planner/CustomPlanner"
            #tolerance: 0.5
            #use_astar: false
            #allow_unknown: true
            interpolation_resolution: 0.1
      

      nav2_custom_planner.cpp代码:

      #include "nav2_util/node_utils.hpp"
      #include <cmath>
      #include <memory>
      #include <string>
      #include "nav2_core/exceptions.hpp"
      #include "nav2_custom_planner/nav2_custom_planner.hpp"
      
      namespace nav2_custom_planner {
          void CustomPlanner::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) {
                  tf_ = tf;
                  node_ = parent.lock();
                  name_ = name;
                  costmap_ = costmap_ros->getCostmap();
                  global_frame_ = costmap_ros->getGlobalFrameID();
                  //参数初始化
                  nav2_util::declare_parameter_if_not_declared(node_, name_ + ".interpolation_resolution", rclcpp::ParameterValue(0.1));
                  node_->get_parameter(name_ + ".interpolation_resolution",
                                      interpolation_resolution_);
              
              
              }
          void CustomPlanner::cleanup() {
              RCLCPP_INFO(node_->get_logger(), "正在清理类型为CustomPlanner的插件 %s", name_.c_str());
          }
          
          void CustomPlanner::activate() {
              RCLCPP_INFO(node_->get_logger(), "正在激活类型为CustomPlanner的插件 %s", name_.c_str());
          }
      
          void CustomPlanner::deactivate() {
              RCLCPP_INFO(node_->get_logger(), "正在停用类型为CustomPlanner的插件 %s", name_.c_str());
          }
      
          nav_msgs::msg::Path
          CustomPlanner::createPlan(const geometry_msgs::msg::PoseStamped &start,
              const geometry_msgs::msg::PoseStamped &goal) {
              // 1、声明并初始化global_path
              nav_msgs::msg::Path global_path;
              global_path.poses.clear();
              global_path.header.stamp = node_->now();
              global_path.header.frame_id = global_frame_;
              // 2、检察目标和起始状态是否在全局坐标中
              if (start.header.frame_id != global_frame_) {
                  RCLCPP_ERROR(node_->get_logger(), "规划器仅接受来自 %s 坐标系的起始位置", global_frame_.c_str());
                  return global_path;
              }
              if (goal.header.frame_id != global_frame_) {
                  RCLCPP_INFO(node_->get_logger(), "规划器仅接受来自 %s 坐标系的起始位置", global_frame_.c_str());
                  return global_path;
              }
              // 3、计算当前插值分辨率 interpolation_resolution_下的循环次数和步进值
              int total_number_of_loop =
                  std::hypot(goal.pose.position.x - start.pose.position.x,
                              goal.pose.position.y - start.pose.position.y) /
                              interpolation_resolution_;
                  double x_increment = 
                      (goal.pose.position.x - start.pose.position.x) / total_number_of_loop;
                  double y_increment = 
                      (goal.pose.position.y - start.pose.position.y) / total_number_of_loop;
              // 4、生成路径
              for (int i = 0; i < total_number_of_loop; ++i) {
                  geometry_msgs::msg::PoseStamped pose; // 生成一个点
                  pose.pose.position.x = start.pose.position.x + x_increment * i;
                  pose.pose.position.y = start.pose.position.y + y_increment * i;
                  pose.pose.position.z = 0.0;
                  pose.header.stamp = node_->now();
                  pose.header.frame_id = global_frame_;
                  // 将该点放在路径中
                  global_path.poses.push_back(pose);
              }
              // 5、使用 costmap 检察该条路径是否经过障碍物
              for (geometry_msgs::msg::PoseStamped pose : global_path.poses) {
                  unsigned int mx, my; // 将坐标转换为栅格坐标
                  if (costmap_->worldToMap(pose.pose.position.x, pose.pose.position.y, mx, my)) {
                      unsigned char cost = costmap_->getCost(mx, my); // 获取带有栅格的代价值
                      // 如果存在致命障碍物则抛出异常
                      if (cost == nav2_costmap_2d::LETHAL_OBSTACLE) {
                          RCLCPP_WARN(node_->get_logger(), "在(%f,%f)检测到存在致命障碍物,规划失败。", 
                          pose.pose.position.x, pose.pose.position.y);
                          throw nav2_core::PlannerException(
                              "无法创建规划目标:" + std::to_string(goal.pose.position.x) + "," + 
                              std::to_string(goal.pose.position.y));
                      }
                  }   
              }
              // 6、收尾,将目标点作为路径的最后一个点并返回路径
              geometry_msgs::msg::PoseStamped goal_pose = goal;
              goal_pose.header.stamp = node_->now();
              goal_pose.header.frame_id = global_frame_;
              global_path.poses.push_back(goal_pose);
              
              return global_path;
              }
      
      } // namespace nav2_custom_planner
      
      #include "pluginlib/class_list_macros.hpp"
      PLUGINLIB_EXPORT_CLASS(nav2_custom_planner::CustomPlanner,
                              nav2_core::GlobalPlanner);
      
      4 2 条回复 最后回复 回复 引用 0
      • 4
        开心 @43996173
        最后由 编辑

        @43996173
        rviz日志文件:

        tingbo@DESKTOP-NHH5E05:~/chapt8/chapt8_ws$ ros2 launch fishbot_navigation2 navigation2.launch.py
        [INFO] [launch]: All log files can be found below /home/tingbo/.ros/log/2024-04-30-09-41-28-252807-DESKTOP-NHH5E05-48185
        [INFO] [launch]: Default logging verbosity is set to INFO
        [INFO] [component_container_isolated-1]: process started with pid [48210]
        [INFO] [rviz2-2]: process started with pid [48212]
        [rviz2-2] QStandardPaths: wrong permissions on runtime directory /run/user/1000/, 0755 instead of 0700
        [component_container_isolated-1] [INFO] [1714441290.519077768] [nav2_container]: Load Library: /opt/ros/humble/lib/libcontroller_server_core.so
        [component_container_isolated-1] [INFO] [1714441290.543254369] [nav2_container]: Found class: rclcpp_components::NodeFactoryTemplate<nav2_controller::ControllerServer>
        [component_container_isolated-1] [INFO] [1714441290.543359969] [nav2_container]: Instantiate class: rclcpp_components::NodeFactoryTemplate<nav2_controller::ControllerServer>
        [component_container_isolated-1] [INFO] [1714441290.581321471] [controller_server]:
        [component_container_isolated-1]        controller_server lifecycle node launched.
        [component_container_isolated-1]        Waiting on external lifecycle transitions to activate
        [component_container_isolated-1]        See https://design.ros2.org/articles/node_lifecycle.html for more information.
        [component_container_isolated-1] [INFO] [1714441290.589289171] [controller_server]: Creating controller server
        [component_container_isolated-1] [INFO] [1714441290.611475272] [local_costmap.local_costmap]:
        [component_container_isolated-1]        local_costmap lifecycle node launched.
        [component_container_isolated-1]        Waiting on external lifecycle transitions to activate
        [component_container_isolated-1]        See https://design.ros2.org/articles/node_lifecycle.html for more information.
        [component_container_isolated-1] [INFO] [1714441290.758609779] [amcl]:
        [component_container_isolated-1]        amcl lifecycle node launched.
        [component_container_isolated-1]        Waiting on external lifecycle transitions to activate
        [component_container_isolated-1]        See https://design.ros2.org/articles/node_lifecycle.html for more information.
        [component_container_isolated-1] [INFO] [1714441290.759910779] [amcl]: Creating
        [INFO] [launch_ros.actions.load_composable_nodes]: Loaded node '/amcl' in container '/nav2_container'
        [component_container_isolated-1] [INFO] [1714441290.769389280] [nav2_container]: Load Library: /opt/ros/humble/lib/libplanner_server_core.so
        [component_container_isolated-1] [INFO] [1714441290.772756980] [nav2_container]: Found class: rclcpp_components::NodeFactoryTemplate<nav2_planner::PlannerServer>
        [component_container_isolated-1] [INFO] [1714441290.772884380] [nav2_container]: Instantiate class: rclcpp_components::NodeFactoryTemplate<nav2_planner::PlannerServer>
        [component_container_isolated-1] [INFO] [1714441290.810831282] [planner_server]:
        [component_container_isolated-1]        planner_server lifecycle node launched.
        [component_container_isolated-1]        Waiting on external lifecycle transitions to activate
        [component_container_isolated-1]        See https://design.ros2.org/articles/node_lifecycle.html for more information.
        [component_container_isolated-1] [INFO] 
        [component_container_isolated-1] [INFO] [1714441290.922881987] [lifecycle_manager_localization]: Starting managed nodes bringup...
        [component_container_isolated-1] [INFO] [1714441290.923287687] [lifecycle_manager_localization]: Configuring map_server
        [component_container_isolated-1] [INFO] [1714441290.923776887] [map_server]: Configuring
        [component_container_isolated-1] [INFO] [map_io]: Loading yaml file: /home/tingbo/chapt8/chapt8_ws/install/fishbot_navigation2/share/fishbot_navigation2/maps/room.yaml
        [component_container_isolated-1] [DEBUG] [map_io]: resolution: 0.05
        [component_container_isolated-1] [DEBUG] [map_io]: origin[0]: -7.64
        [component_container_isolated-1] [DEBUG] [map_io]: origin[1]: -7.15
        [component_container_isolated-1] [DEBUG] [map_io]: origin[2]: 0
        [component_container_isolated-1] [DEBUG] [map_io]: free_thresh: 0.25
        [component_container_isolated-1] [DEBUG] [map_io]: occupied_thresh: 0.65
        [component_container_isolated-1] [DEBUG] [map_io]: mode: trinary
        [component_container_isolated-1] [DEBUG] [map_io]: negate: 0
        [component_container_isolated-1] [INFO] [map_io]: Loading image_file: /home/tingbo/chapt8/chapt8_ws/install/fishbot_navigation2/share/fishbot_navigation2/maps/room.pgm
        [component_container_isolated-1] [DEBUG] [map_io]: Read map /home/tingbo/chapt8/chapt8_ws/install/fishbot_navigation2/share/fishbot_navigation2/maps/room.pgm: 262 X 296 map @ 0.05 m/cell
        [component_container_isolated-1] [INFO] [1714441290.963183489] [lifecycle_manager_localization]: Configuring amcl
        [component_container_isolated-1] [INFO] [1714441290.963454689] [amcl]: Configuring
        [component_container_isolated-1] [INFO] [1714441290.963983489] [amcl]: initTransforms
        [component_container_isolated-1] [INFO] [1714441290.966080289] [behavior_server]:
        [component_container_isolated-1]        behavior_server lifecycle node launched.
        [component_container_isolated-1]        Waiting on external lifecycle transitions to activate
        [component_container_isolated-1]        See https://design.ros2.org/articles/node_lifecycle.html for more information.
        [INFO] [launch_ros.actions.load_composable_nodes]: Loaded node '/behavior_server' in container '/nav2_container'
        [component_container_isolated-1] [INFO] [1714441290.985823690] [nav2_container]: Load Library: /opt/ros/humble/lib/libbt_navigator_core.so
        [component_container_isolated-1] [INFO] [1714441291.004051591] [nav2_container]: Found class: rclcpp_components::NodeFactoryTemplate<nav2_bt_navigator::BtNavigator>
        [component_container_isolated-1] [INFO] [1714441291.004100891] [nav2_container]: Instantiate class: rclcpp_components::NodeFactoryTemplate<nav2_bt_navigator::BtNavigator>
        [component_container_isolated-1] [INFO] [1714441291.026670892] [amcl]: initPubSub
        [component_container_isolated-1] [INFO] [1714441291.056052294] [amcl]: Subscribed to map topic.
        [component_container_isolated-1] [INFO] [1714441291.081119195] [lifecycle_manager_localization]: Activating map_server
        [component_container_isolated-1] [INFO] [1714441291.081495595] [map_server]: Activating
        [component_container_isolated-1] [INFO] [1714441291.082991795] [map_server]: Creating bond (map_server) to lifecycle manager.
        [component_container_isolated-1] [INFO] [1714441291.083556695] [amcl]: Received a 262 X 296 map @ 0.050 m/pix
        [component_container_isolated-1] [INFO] [1714441291.090327595] [bt_navigator]:
        [component_container_isolated-1]        bt_navigator lifecycle node launched.
        [component_container_isolated-1]        Waiting on external lifecycle transitions to activate
        [component_container_isolated-1]        See https://design.ros2.org/articles/node_lifecycle.html for more information.
        [component_container_isolated-1] [INFO] [1714441291.097086896] [bt_navigator]: Creating
        [INFO] [launch_ros.actions.load_composable_nodes]: Loaded node '/bt_navigator' in container '/nav2_container'
        [component_container_isolated-1] [INFO] [1714441291.103330096] [nav2_container]: Load Library: /opt/ros/humble/lib/libwaypoint_follower_core.so
        [component_container_isolated-1] [INFO] [1714441291.106782896] [nav2_container]: Found class: rclcpp_components::NodeFactoryTemplate<nav2_waypoint_follower::WaypointFollower>
        [component_container_isolated-1] [INFO] [1714441291.108129896] [nav2_container]: Instantiate class: rclcpp_components::NodeFactoryTemplate<nav2_waypoint_follower::WaypointFollower>
        [component_container_isolated-1] [INFO] [1714441291.163609199] [waypoint_follower]:
        [component_container_isolated-1]        waypoint_follower lifecycle node launched.
        [component_container_isolated-1]        Waiting on external lifecycle transitions to activate
        [component_container_isolated-1]        See https://design.ros2.org/articles/node_lifecycle.html for more information.
        [component_container_isolated-1] [INFO] [1714441291.165948499] [waypoint_follower]: Creating
        [INFO] [launch_ros.actions.load_composable_nodes]: Loaded node '/waypoint_follower' in container '/nav2_container'
        [component_container_isolated-1] [INFO] [1714441291.172636599] [nav2_container]: Load Library: /opt/ros/humble/lib/libvelocity_smoother_core.so
        [component_container_isolated-1] [INFO] [1714441291.176886899] [nav2_container]: Found class: rclcpp_components::NodeFactoryTemplate<nav2_velocity_smoother::VelocitySmoother>
        [component_container_isolated-1] [INFO] [1714441291.177470200] [nav2_container]: Instantiate class: rclcpp_components::NodeFactoryTemplate<nav2_velocity_smoother::VelocitySmoother>
        [component_container_isolated-1] [INFO] [1714441291.211718801] [velocity_smoother]:
        [component_container_isolated-1]        velocity_smoother lifecycle node launched.
        [component_container_isolated-1]        Waiting on external lifecycle transitions to activate
        [component_container_isolated-1]        See https://design.ros2.org/articles/node_lifecycle.html for more information.
        [INFO] [launch_ros.actions.load_composable_nodes]: Loaded node '/velocity_smoother' in container '/nav2_container'
        [component_container_isolated-1] [INFO] [1714441291.218161601] [nav2_container]: Found class: rclcpp_components::NodeFactoryTemplate<nav2_lifecycle_manager::LifecycleManager>
        [component_container_isolated-1] [INFO] [1714441291.218238802] [nav2_container]: Instantiate class: rclcpp_components::NodeFactoryTemplate<nav2_lifecycle_manager::LifecycleManager>
        [component_container_isolated-1] [INFO] [1714441291.253727303] [lifecycle_manager_navigation]: Creating
        [INFO] [launch_ros.actions.load_composable_nodes]: Loaded node '/lifecycle_manager_navigation' in container '/nav2_container'
        [component_container_isolated-1] [INFO] [1714441291.261462704] [lifecycle_manager_navigation]: Creating and initializing lifecycle service clients
        [component_container_isolated-1] [INFO] [1714441291.286281705] [amcl]: createLaserObject
        [component_container_isolated-1] [WARN] [1714441291.298604105] [amcl]: AMCL cannot publish a pose or update the transform. Please set the initial pose...
        [component_container_isolated-1] [INFO] [1714441291.312159206] [lifecycle_manager_navigation]: Starting managed nodes bringup...
        [component_container_isolated-1] [INFO] 
        [component_container_isolated-1] [INFO] [1714441291.547476717] [smoother_server]: Created smoother : simple_smoother of type nav2_smoother::SimpleSmoother
        [component_container_isolated-1] [INFO] [1714441291.553400218] [smoother_server]: Smoother Server has simple_smoother  smoothers available.
        [component_container_isolated-1] [INFO] [1714441291.570279919] [lifecycle_manager_navigation]: Configuring planner_server
        [component_container_isolated-1] [INFO] [1714441291.570477919] [planner_server]: Configuring
        [component_container_isolated-1] [INFO] [1714441291.570618619] [global_costmap.global_costmap]: Configuring
        [component_container_isolated-1] [INFO] [1714441291.592593820] [global_costmap.global_costmap]: Using plugin "static_layer"
        [component_container_isolated-1] [INFO] [1714441291.597003320] [global_costmap.global_costmap]: Subscribing to the map topic (/map) with transient local durability
        [component_container_isolated-1] [INFO] [1714441291.598914120] [global_costmap.global_costmap]: Initialized plugin "static_layer"
        [1714441291.628119821] [global_costmap.global_costmap]: Initialized plugin "inflation_layer"
        [component_container_isolated-1] [FATAL] [1714441291.653694823] [planner_server]: Failed to create global planner. Exception: Could not find library corresponding to plugin nav2_custom_planner/CustomPlanner. Make sure that the library 'nav2_custom_planner_plugin' actually exists.
        [component_container_isolated-1] [ERROR] [1714441291.654599323] [lifecycle_manager_navigation]: Failed to change state for node: planner_server
        [component_container_isolated-1] [ERROR] [1714441291.654630423] [lifecycle_manager_navigation]: Failed to bring up all requested nodes. Aborting bringup.
        [component_container_isolated-1] [INFO] [1714441291.668797823] [global_costmap.global_costmap]: StaticLayer: Resizing costmap to 262 X 296 at 0.050000 m/pix
        [rviz2-2] [INFO] [1714441291.777295029] [rviz2]: Stereo is NOT SUPPORTED
        [rviz2-2] [INFO] [1714441291.777755429] [rviz2]: OpenGl version: 4.2 (GLSL 4.2)
        [rviz2-2] [INFO] [1714441291.880743234] [rviz2]: Stereo is NOT SUPPORTED
        [component_container_isolated-1] [WARN] [1714441292.044388642] [amcl]: New subscription discovered on topic '/particle_cloud', requesting incompatible QoS. No messages will be sent to it. Last incompatible policy: RELIABILITY_QOS_POLICY
        [rviz2-2] [INFO] [1714441292.263889052] [rviz2]: Trying to create a map of size 262 x 296 using 1 swatches
        [rviz2-2] [ERROR] [1714441292.321494655] [rviz2]: Vertex Program:rviz/glsl120/indexed_8bit_image.vert Fragment Program:rviz/glsl120/indexed_8bit_image.frag GLSL link result :
        [rviz2-2] active samplers with a different type refer to the same texture image unit
        [component_container_isolated-1] [WARN] [1714441293.290612502] [amcl]: AMCL cannot publish a pose or update the transform. Please set the initial pose...
        [rviz2-2] [INFO] [1714441295.116431690] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7556.178 for reason 'discarding message because the queue is full'
        [component_container_isolated-1] [WARN] [1714441295.294489499] [amcl]: AMCL cannot publish a pose or update the transform. Please set the initial pose...
        [rviz2-2] [INFO] [1714441295.308184900] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7556.378 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441295.500418309] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7556.578 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441295.724786420] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7556.778 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441295.916522729] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7556.978 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441296.140943540] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7557.178 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441296.332987349] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7557.378 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441296.524172558] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7557.578 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441296.716890368] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7557.778 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441296.940116279] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7557.978 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441297.132164788] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7558.178 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441297.324480397] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7558.378 for reason 'discarding message because the queue is full'
        [component_container_isolated-1] [WARN] [1714441297.519346307] [amcl]: AMCL cannot publish a pose or update the transform. Please set the initial pose...
        [rviz2-2] [INFO] [1714441297.549014208] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7558.578 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441297.742961314] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7558.778 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441297.932609316] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7558.978 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441298.157083519] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7559.178 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441298.348363821] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7559.378 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441298.540796323] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7559.578 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441298.765424426] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7559.778 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441298.956352528] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7559.978 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441299.148800330] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7560.178 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441299.340691432] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7560.378 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441299.564489735] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7560.578 for reason 'discarding message because the queue is full'
        [component_container_isolated-1] [WARN] [1714441299.736345737] [amcl]: AMCL cannot publish a pose or update the transform. Please set the initial pose...
        [rviz2-2] [INFO] [1714441299.756277237] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7560.779 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441299.948922739] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7560.978 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441300.140377241] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7561.178 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441300.364789944] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7561.378 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441300.556585846] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7561.578 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441300.748703548] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7561.778 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441300.940379150] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7561.978 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441301.164773852] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7562.178 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441301.356904355] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7562.378 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441301.548841157] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7562.578 for reason 'discarding message because the queue is full'
        [component_container_isolated-1] [WARN] [1714441301.742724159] [amcl]: AMCL cannot publish a pose or update the transform. Please set the initial pose...
        [rviz2-2] [INFO] [1714441301.772535759] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7562.778 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441301.968095961] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7562.978 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441302.157295064] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7563.178 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441302.381168966] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7563.378 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441302.572797168] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7563.578 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441302.764103470] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7563.778 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441302.988702573] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7563.978 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441303.180418775] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7564.178 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441303.373016077] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7564.378 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441303.564124979] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7564.578 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441303.789413482] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7564.778 for reason 'discarding message because the queue is full'
        [component_container_isolated-1] [WARN] [1714441303.962216584] [amcl]: AMCL cannot publish a pose or update the transform. Please set the initial pose...
        [rviz2-2] [INFO] [1714441303.980394984] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7564.978 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441304.172235886] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7565.178 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441304.364489088] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7565.379 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441305.772877903] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7566.778 for reason 'discarding message because the queue is full'
        [component_container_isolated-1] [WARN] [1714441305.968206304] [amcl]: AMCL cannot publish a pose or update the transform. Please set the initial pose...
        [rviz2-2] [INFO] [1714441305.996126204] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7566.978 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441306.188657505] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7567.178 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441306.380885706] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7567.378 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441306.572938407] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7567.578 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441306.796428708] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7567.778 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441306.988795509] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7567.978 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441307.134442610] [rviz2]: Setting estimate pose: Frame:map, Position(3.46453e-08, 0.00937503, 0), Orientation(0, 0, 0.00314274, 0.999995) = Angle: 0.00628548
        [component_container_isolated-1] [INFO] [1714441307.135065910] [amcl]: initialPoseReceived
        [component_container_isolated-1] [INFO] [1714441307.135162110] [amcl]: Setting pose (7570.047000): 0.000 0.009 0.006
        [rviz2-2] [INFO] [1714441307.180886710] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7568.178 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441307.372332211] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7568.378 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441307.596409712] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7568.578 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441307.789098513] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7568.778 for reason 'discarding message because the queue is full'
        [rviz2-2] [INFO] [1714441316.424794648] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7569.378 for reason 'the timestamp on the message is earlier than all the data in the transform cache'
        [rviz2-2] [INFO] [1714441316.625205649] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7569.578 for reason 'the timestamp on the message is earlier than all the data in the transform cache'
        [rviz2-2] [INFO] [1714441316.825335949] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7569.778 for reason 'the timestamp on the message is earlier than all the data in the transform cache'
        [rviz2-2] [INFO] [1714441317.026644250] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7569.978 for reason 'the timestamp on the message is earlier than all the data in the transform cache'
        [rviz2-2] [INFO] [1714441317.227855750] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7570.178 for reason 'the timestamp on the message is earlier than all the data in the transform cache'
        [rviz2-2] [INFO] [1714441317.427462251] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7570.378 for reason 'the timestamp on the message is earlier than all the data in the transform cache'
        [rviz2-2] [INFO] [1714441317.628638551] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7570.578 for reason 'the timestamp on the message is earlier than all the data in the transform cache'
        [rviz2-2] [INFO] [1714441317.827929452] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7570.778 for reason 'the timestamp on the message is earlier than all the data in the transform cache'
        [rviz2-2] [INFO] [1714441318.028947452] [rviz2]: Message Filter dropping message: frame 'laser_link' at time 7570.978 for reason 'the timestamp on the message is earlier than all the data in the transform cache'
        [rviz2-2] Start navigation
        ^C[WARNING] [launch]: user interrupted with ctrl-c (SIGINT)
        [component_container_isolated-1] [INFO] [1714441322.595722163] [rclcpp]: signal_handler(signum=2)
        [component_container_isolated-1] [INFO] [1714441322.596122963] [global_costmap.global_costmap]: Running Nav2 LifecycleNode rcl preshutdown (global_costmap)
        [component_container_isolated-1] [INFO] [1714441322.596467263] [global_costmap.global_costmap]: Cleaning up
        [ERROR] [rviz2-2]: process has died [pid 48212, exit code -11, cmd '/opt/ros/humble/lib/rviz2/rviz2 -d /opt/ros/humble/share/nav2_bringup/rviz/nav2_default_view.rviz --ros-args -r __node:=rviz2 --params-file /tmp/launch_params__2_xt3ip'].
        [rviz2-2] [INFO] [1714441322.595845663] [rclcpp]: signal_handler(signum=2)
        [rviz2-2] [ERROR] [1714441322.596476663] [rviz_navigation_dialog_action_client]: navigate_to_pose action server is not available. Is the initial pose set?
        [rviz2-2]
        [rviz2-2] >>> [rcutils|error_handling.c:108] rcutils_set_error_state()
        [rviz2-2] This error state is being overwritten:
        [rviz2-2]
        [rviz2-2]   'rcl node's context is invalid, at ./src/rcl/node.c:428'
        [rviz2-2]
        [rviz2-2] with this new error message:
        [rviz2-2]
        [rviz2-2]   'publisher's context is invalid, at ./src/rcl/publisher.c:389'
        [rviz2-2]
        [rviz2-2] rcutils_reset_error() should be called after error handling to avoid this.
        [rviz2-2] <<<
        [component_container_isolated-1] [INFO] [1714441322.606711263] [global_costmap.global_costmap]: Destroying bond (global_costmap) to lifecycle manager.
        [component_container_isolated-1] [INFO] [1714441322.606747963] [smoother_server]: Running Nav2 LifecycleNode rcl preshutdown (smoother_server)
        [component_container_isolated-1] [INFO] [1714441322.606817163] [smoother_server]: Cleaning up
        [component_container_isolated-1] [INFO] LifecycleNode rcl preshutdown (amcl)
        [component_container_isolated-1] [INFO] [1714441322.659397963] [amcl]: Deactivating
        [1714441322.677908863] [amcl]: Destroying bond (amcl) to lifecycle manager.
        [component_container_isolated-1] [INFO] [1714441322.677947963] [map_server]: Running Nav2 LifecycleNode rcl preshutdown (map_server)
        [component_container_isolated-1] [INFO] [1714441322.677968363] [map_server]: Deactivating
        [component_container_isolated-1] [INFO] [1714441322.677980363] [map_server]: Destroying bond (map_server) to lifecycle manager.
        [component_container_isolated-1] [INFO] [1714441322.693491563] [map_server]: Cleaning up
        [component_container_isolated-1] [INFO] [1714441322.693630963] [map_server]: Destroying bond (map_server) to lifecycle manager.
        [1714441322.693756963] [local_costmap.local_costmap]: Running Nav2 LifecycleNode rcl preshutdown (local_costmap)
        [component_container_isolated-1] [INFO] [1714441322.693775463] [local_costmap.local_costmap]: Cleaning up
        [component_container_isolated-1] [INFO] [1714441322.705001363] [local_costmap.local_costmap]: Destroying bond (local_costmap) to lifecycle manager.
        [component_container_isolated-1] [INFO] [1714441322.705076463] [behavior_server]: Running Nav2 LifecycleNode rcl preshutdown (behavior_server)
        [component_container_isolated-1] [INFO] [1714441322.705115363] [behavior_server]: Destroying bond (behavior_server) to lifecycle manager.
        [component_container_isolated-1] [INFO] [1714441322.762122163] [controller_server]: Destroying bond (controller_server) to lifecycle manager.
        [ERROR] [component_container_isolated-1]: process[component_container_isolated-1] failed to terminate '5' seconds after receiving 'SIGINT', escalating to 'SIGTERM'
        [INFO] [component_container_isolated-1]: sending signal 'SIGTERM' to process[component_container_isolated-1]
        [component_container_isolated-1] [INFO] [1714441328.285173574] [rclcpp]: signal_handler(signum=15)
        [ERROR] [component_container_isolated-1]: process[component_container_isolated-1] failed to terminate '10.0' seconds after receiving 'SIGTERM', escalating to 'SIGKILL'
        [INFO] [component_container_isolated-1]: sending signal 'SIGKILL' to process[component_container_isolated-1]
        [ERROR] [component_container_isolated-1]: process has died [pid 48210, exit code -9, cmd '/opt/ros/humble/lib/rclcpp_components/component_container_isolated --ros-args --log-level info --ros-args -r __node:=nav2_container --params-file /tmp/launch_params_bn8j221x --params-file /tmp/launch_params_mlv9_qat -r /tf:=tf -r /tf_static:=tf_static'].
        
        1 条回复 最后回复 回复 引用 0
        • 4
          开心 @43996173
          最后由 编辑

          @43996173 nav2_params.yaml全部代码:

          amcl:
            ros__parameters:
              use_sim_time: True
              alpha1: 0.2
              alpha2: 0.2
              alpha3: 0.2
              alpha4: 0.2
              alpha5: 0.2
              base_frame_id: "base_footprint"
              beam_skip_distance: 0.5
              beam_skip_error_threshold: 0.9
              beam_skip_threshold: 0.3
              do_beamskip: false
              global_frame_id: "map"
              lambda_short: 0.1
              laser_likelihood_max_dist: 2.0
              laser_max_range: 100.0
              laser_min_range: -1.0
              laser_model_type: "likelihood_field"
              max_beams: 60
              max_particles: 2000
              min_particles: 500
              odom_frame_id: "odom"
              pf_err: 0.05
              pf_z: 0.99
              recovery_alpha_fast: 0.0
              recovery_alpha_slow: 0.0
              resample_interval: 1
              robot_model_type: "nav2_amcl::DifferentialMotionModel"
              save_pose_rate: 0.5
              sigma_hit: 0.2
              tf_broadcast: true
              transform_tolerance: 1.0
              update_min_a: 0.2
              update_min_d: 0.25
              z_hit: 0.5
              z_max: 0.05
              z_rand: 0.5
              z_short: 0.05
              scan_topic: scan
          
          bt_navigator:
            ros__parameters:
              use_sim_time: True
              global_frame: map
              robot_base_frame: base_link
              odom_topic: /odom
              bt_loop_duration: 10
              default_server_timeout: 20
              # 'default_nav_through_poses_bt_xml' and 'default_nav_to_pose_bt_xml' are use defaults:
              # nav2_bt_navigator/navigate_to_pose_w_replanning_and_recovery.xml
              # nav2_bt_navigator/navigate_through_poses_w_replanning_and_recovery.xml
              # They can be set here or via a RewrittenYaml remap from a parent launch file to Nav2.
              plugin_lib_names:
                - nav2_compute_path_to_pose_action_bt_node
                - nav2_compute_path_through_poses_action_bt_node
                - nav2_smooth_path_action_bt_node
                - nav2_follow_path_action_bt_node
                - nav2_spin_action_bt_node
                - nav2_wait_action_bt_node
                - nav2_assisted_teleop_action_bt_node
                - nav2_back_up_action_bt_node
                - nav2_drive_on_heading_bt_node
                - nav2_clear_costmap_service_bt_node
                - nav2_is_stuck_condition_bt_node
                - nav2_goal_reached_condition_bt_node
                - nav2_goal_updated_condition_bt_node
                - nav2_globally_updated_goal_condition_bt_node
                - nav2_is_path_valid_condition_bt_node
                - nav2_initial_pose_received_condition_bt_node
                - nav2_reinitialize_global_localization_service_bt_node
                - nav2_rate_controller_bt_node
                - nav2_distance_controller_bt_node
                - nav2_speed_controller_bt_node
                - nav2_truncate_path_action_bt_node
                - nav2_truncate_path_local_action_bt_node
                - nav2_goal_updater_node_bt_node
                - nav2_recovery_node_bt_node
                - nav2_pipeline_sequence_bt_node
                - nav2_round_robin_node_bt_node
                - nav2_transform_available_condition_bt_node
                - nav2_time_expired_condition_bt_node
                - nav2_path_expiring_timer_condition
                - nav2_distance_traveled_condition_bt_node
                - nav2_single_trigger_bt_node
                - nav2_goal_updated_controller_bt_node
                - nav2_is_battery_low_condition_bt_node
                - nav2_navigate_through_poses_action_bt_node
                - nav2_navigate_to_pose_action_bt_node
                - nav2_remove_passed_goals_action_bt_node
                - nav2_planner_selector_bt_node
                - nav2_controller_selector_bt_node
                - nav2_goal_checker_selector_bt_node
                - nav2_controller_cancel_bt_node
                - nav2_path_longer_on_approach_bt_node
                - nav2_wait_cancel_bt_node
                - nav2_spin_cancel_bt_node
                - nav2_back_up_cancel_bt_node
                - nav2_assisted_teleop_cancel_bt_node
                - nav2_drive_on_heading_cancel_bt_node
                - nav2_is_battery_charging_condition_bt_node
          
          bt_navigator_navigate_through_poses_rclcpp_node:
            ros__parameters:
              use_sim_time: True
          
          bt_navigator_navigate_to_pose_rclcpp_node:
            ros__parameters:
              use_sim_time: True
          
          controller_server:
            ros__parameters:
              use_sim_time: True
              controller_frequency: 20.0
              min_x_velocity_threshold: 0.001
              min_y_velocity_threshold: 0.5
              min_theta_velocity_threshold: 0.001
              failure_tolerance: 0.3
              progress_checker_plugin: "progress_checker"
              goal_checker_plugins: ["general_goal_checker"] # "precise_goal_checker"
              controller_plugins: ["FollowPath"]
          
              # Progress checker parameters
              progress_checker:
                plugin: "nav2_controller::SimpleProgressChecker"
                required_movement_radius: 0.5
                movement_time_allowance: 10.0
              # Goal checker parameters
              #precise_goal_checker:
              #  plugin: "nav2_controller::SimpleGoalChecker"
              #  xy_goal_tolerance: 0.25
              #  yaw_goal_tolerance: 0.25
              #  stateful: True
              general_goal_checker:
                stateful: True
                plugin: "nav2_controller::SimpleGoalChecker"
                xy_goal_tolerance: 0.15
                yaw_goal_tolerance: 0.15
              # DWB parameters
              FollowPath:
                plugin: "dwb_core::DWBLocalPlanner"
                #plugin: "nav2_custom_controller::CustomController"
                #max_linear_speed: 0.1
                #max_angular_speed: 1.0
                debug_trajectory_details: True
                min_vel_x: 0.0
                min_vel_y: 0.0
                max_vel_x: 0.26
                max_vel_y: 0.0
                max_vel_theta: 0.8
                min_speed_xy: 0.0
                max_speed_xy: 0.26
                min_speed_theta: 0.0
                # Add high threshold velocity for turtlebot 3 issue.
                # https://github.com/ROBOTIS-GIT/turtlebot3_simulations/issues/75
                acc_lim_x: 2.5
                acc_lim_y: 0.0
                acc_lim_theta: 2.0
                decel_lim_x: -2.5
                decel_lim_y: 0.0
                decel_lim_theta: -3.2
                vx_samples: 20
                vy_samples: 5
                vtheta_samples: 20
                sim_time: 1.7
                linear_granularity: 0.05
                angular_granularity: 0.025
                transform_tolerance: 0.2
                xy_goal_tolerance: 0.15
                trans_stopped_velocity: 0.25
                short_circuit_trajectory_evaluation: True
                stateful: True
                critics: ["RotateToGoal", "Oscillation", "BaseObstacle", "GoalAlign", "PathAlign", "PathDist", "GoalDist"]
                BaseObstacle.scale: 0.02
                PathAlign.scale: 32.0
                PathAlign.forward_point_distance: 0.1
                GoalAlign.scale: 24.0
                GoalAlign.forward_point_distance: 0.1
                PathDist.scale: 32.0
                GoalDist.scale: 24.0
                RotateToGoal.scale: 32.0
                RotateToGoal.slowing_factor: 5.0
                RotateToGoal.lookahead_time: -1.0
          
          local_costmap:
            local_costmap:
              ros__parameters:
                update_frequency: 5.0
                publish_frequency: 2.0
                global_frame: odom
                robot_base_frame: base_link
                use_sim_time: True
                rolling_window: true
                width: 3
                height: 3
                resolution: 0.05
                robot_radius: 0.12
                plugins: ["voxel_layer", "inflation_layer"]
                inflation_layer:
                  plugin: "nav2_costmap_2d::InflationLayer"
                  cost_scaling_factor: 3.0
                  inflation_radius: 0.24
                voxel_layer:
                  plugin: "nav2_costmap_2d::VoxelLayer"
                  enabled: True
                  publish_voxel_map: True
                  origin_z: 0.0
                  z_resolution: 0.05
                  z_voxels: 16
                  max_obstacle_height: 2.0
                  mark_threshold: 0
                  observation_sources: scan
                  scan:
                    topic: /scan
                    max_obstacle_height: 2.0
                    clearing: True
                    marking: True
                    data_type: "LaserScan"
                    raytrace_max_range: 3.0
                    raytrace_min_range: 0.0
                    obstacle_max_range: 2.5
                    obstacle_min_range: 0.0
                static_layer:
                  plugin: "nav2_costmap_2d::StaticLayer"
                  map_subscribe_transient_local: True
                always_send_full_costmap: True
          
          global_costmap:
            global_costmap:
              ros__parameters:
                update_frequency: 1.0
                publish_frequency: 1.0
                global_frame: map
                robot_base_frame: base_link
                use_sim_time: True
                robot_radius: 0.12
                resolution: 0.05
                track_unknown_space: true
                plugins: ["static_layer", "obstacle_layer", "inflation_layer"]
                obstacle_layer:
                  plugin: "nav2_costmap_2d::ObstacleLayer"
                  enabled: True
                  observation_sources: scan
                  scan:
                    topic: /scan
                    max_obstacle_height: 2.0
                    clearing: True
                    marking: True
                    data_type: "LaserScan"
                    raytrace_max_range: 3.0
                    raytrace_min_range: 0.0
                    obstacle_max_range: 2.5
                    obstacle_min_range: 0.0
                static_layer:
                  plugin: "nav2_costmap_2d::StaticLayer"
                  map_subscribe_transient_local: True
                inflation_layer:
                  plugin: "nav2_costmap_2d::InflationLayer"
                  cost_scaling_factor: 3.0
                  inflation_radius: 0.24
                always_send_full_costmap: True
          
          map_server:
            ros__parameters:
              use_sim_time: True
              # Overridden in launch by the "map" launch configuration or provided default value.
              # To use in yaml, remove the default "map" value in the tb3_simulation_launch.py file & provide full path to map below.
              yaml_filename: ""
          
          map_saver:
            ros__parameters:
              use_sim_time: True
              save_map_timeout: 5.0
              free_thresh_default: 0.25
              occupied_thresh_default: 0.65
              map_subscribe_transient_local: True
          
          planner_server:
            ros__parameters:
              #expected_planner_frequency: 20.0
              use_sim_time: True
              planner_plugins: ["GridBased"]
              GridBased:
                #plugin: "nav2_navfn_planner/NavfnPlanner"
                plugin: "nav2_custom_planner/CustomPlanner"
                #tolerance: 0.5
                #use_astar: false
                #allow_unknown: true
                interpolation_resolution: 0.1
          
          smoother_server:
            ros__parameters:
              use_sim_time: True
              smoother_plugins: ["simple_smoother"]
              simple_smoother:
                plugin: "nav2_smoother::SimpleSmoother"
                tolerance: 1.0e-10
                max_its: 1000
                do_refinement: True
          
          behavior_server:
            ros__parameters:
              costmap_topic: local_costmap/costmap_raw
              footprint_topic: local_costmap/published_footprint
              cycle_frequency: 10.0
              behavior_plugins: ["spin", "backup", "drive_on_heading", "assisted_teleop", "wait"]
              spin:
                plugin: "nav2_behaviors/Spin"
              backup:
                plugin: "nav2_behaviors/BackUp"
              drive_on_heading:
                plugin: "nav2_behaviors/DriveOnHeading"
              wait:
                plugin: "nav2_behaviors/Wait"
              assisted_teleop:
                plugin: "nav2_behaviors/AssistedTeleop"
              global_frame: odom
              robot_base_frame: base_link
              transform_tolerance: 0.1
              use_sim_time: true
              simulate_ahead_time: 2.0
              max_rotational_vel: 1.0
              min_rotational_vel: 0.4
              rotational_acc_lim: 3.2
          
          robot_state_publisher:
            ros__parameters:
              use_sim_time: True
          
          waypoint_follower:
            ros__parameters:
              use_sim_time: True
              loop_rate: 20
              stop_on_failure: false
              waypoint_task_executor_plugin: "wait_at_waypoint"
              wait_at_waypoint:
                plugin: "nav2_waypoint_follower::WaitAtWaypoint"
                enabled: True
                waypoint_pause_duration: 200
          
          velocity_smoother:
            ros__parameters:
              use_sim_time: True
              smoothing_frequency: 20.0
              scale_velocities: False
              feedback: "OPEN_LOOP"
              max_velocity: [0.26, 0.0, 1.0]
              min_velocity: [-0.26, 0.0, -1.0]
              max_accel: [2.5, 0.0, 3.2]
              max_decel: [-2.5, 0.0, -3.2]
              odom_topic: "odom"
              odom_duration: 0.1
              deadband_velocity: [0.0, 0.0, 0.0]
              velocity_timeout: 1.0
          
          小鱼小 1 条回复 最后回复 回复 引用 0
          • 小鱼小
            小鱼 技术大佬 @43996173
            最后由 编辑

            @43996173 [component_container_isolated-1] [FATAL] [1714441291.653694823] [planner_server]: Failed to create global planner. Exception: Could not find library corresponding to plugin nav2_custom_planner/CustomPlanner. Make sure that the library 'nav2_custom_planner_plugin' actually exists

            看这句提示应该是插件编写问题,贴一下 插件配置xml ,cmake 和 packages.xml

            新书配套视频:https://www.bilibili.com/video/BV1GW42197Ck/

            4 1 条回复 最后回复 回复 引用 0
            • 4
              开心 @小鱼
              最后由 编辑

              @小鱼
              custom_planner_plugin.xml代码:

              <library path="nav2_custom_planner_plugin">
                  <class name="nav2_custom_planner/CustomPlanner" 
                  type="nav2_custom_planner::CustomPlanner" 
                  base_class_type="nav2_core::GlobalPlanner">
                      <description>是一个自定义示例插件,用于生成自定义路径。</description>
                  </class>
              </library>
              

              cmakelists.txt代码:“

              cmake_minimum_required(VERSION 3.8)
              project(nav2_custom_planner)
              
              if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
                add_compile_options(-Wall -Wextra -Wpedantic)
              endif()
              
              # find dependencies
              find_package(ament_cmake REQUIRED)
              find_package(nav2_core REQUIRED)
              find_package(pluginlib REQUIRED)
              #包含头文件目录
              include_directories(include)
              #定义库名称
              set(library_name ${PROJECT_NAME}_Plugin)
              #创建共享库
              add_library(${library_name} SHARED src/nav2_custom_planner.cpp)
              #指定库的依赖关系
              ament_target_dependencies(${library_name} nav2_core pluginlib)
              #安装库文件到指定目录
              install(TARGETS ${library_name}
                ARCHIVE DESTINATION lib 
                LIBRARY DESTINATION lib 
                RUNTIME DESTINATION lib/${PROJECT_NAME}
              )
              #安装头文件到指定目录
              install(DIRECTORY include/
                DESTINATION include/ )
              #导出插件描述文件
              pluginlib_export_plugin_description_file(nav2_core custom_planner_plugin.xml)
              
              if(BUILD_TESTING)
                find_package(ament_lint_auto REQUIRED)
                # the following line skips the linter which checks for copyrights
                # comment the line when a copyright and license is added to all source files
                set(ament_cmake_copyright_FOUND TRUE)
                # the following line skips cpplint (only works in a git repo)
                # comment the line when this package is in a git repo and when
                # a copyright and license is added to all source files
                set(ament_cmake_cpplint_FOUND TRUE)
                ament_lint_auto_find_test_dependencies()
              endif()
              
              ament_package()
              

              package.xml代码:

              <?xml version="1.0"?>
              <?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
              <package format="3">
                <name>nav2_custom_planner</name>
                <version>0.0.0</version>
                <description>TODO: Package description</description>
                <maintainer email="tingbo01@qq.com">tingbo</maintainer>
                <license>Apache-2.0</license>
              
                <buildtool_depend>ament_cmake</buildtool_depend>
              
                <depend>nav2_core</depend>
                <depend>pluginlib</depend>
              
                <test_depend>ament_lint_auto</test_depend>
                <test_depend>ament_lint_common</test_depend>
              
                <export>
                  <build_type>ament_cmake</build_type>
                  <nav2_core plugin="${prefix}/custom_planner_plugin.xml" />
                </export>
              </package>
              
              1 条回复 最后回复 回复 引用 0
              • 第一个帖子
                最后一个帖子
              皖ICP备16016415号-7
              Powered by NodeBB | 鱼香ROS