Closed LMManto closed 1 year ago
The API of these plugins have changed over time due to changes in the interfaces as we've continued to develop the stack.
If you have an older distribution, you may need to change the newer API in the tutorial code to match them. If you have a new distribution and its not working, it may have been that we didn't update them here to reflect the current API. What distribution are you on?
See https://github.com/ros-planning/navigation2/blob/main/nav2_core/include/nav2_core/global_planner.hpp (check out the right branch based on your distribution to see the API)
Looks like the current master of both are in line, so you're maybe running Foxy where you have to update the API?
Dear @SteveMacenski
Thank you for your kind reply.
At the end I figured out how to compile it, because I found out some errors in the straightline plugin code. I am going to write them here, in the case someone has the same issue.
All the problems are related to the configure() function. In the _nav2_straightline_planner/src/straight_lineplanner.cpp file, the function:
void StraightLine::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)
Should be replaced with:
void StraightLine::configure(
rclcpp_lifecycle::LifecycleNode::SharedPtr parent,
std::string name, std::shared_ptr<tf2_ros::Buffer> tf,
std::shared_ptr<nav2_costmap_2d::Costmap2DROS> costmap_ros)
The problem is related to the first parameter of the funcion, the parent argument. It should be _rclcpplifecycle::LifecycleNode::SharedPtr parent type, not _const rclcpplifecycle::LifecycleNode::WeakPtr & parent, because this function derives from the _nav2core::GlobalPlanner configure() function (since the StraightLine class inherits from the GlobalPlanner one: _class StraightLine : public nav2core::GlobalPlanner).
In fact, in the _globalplanner.hpp file, the function is like this:
virtual void configure(
rclcpp_lifecycle::LifecycleNode::SharedPtr parent,
std::string name, std::shared_ptr<tf2_ros::Buffer> tf,
std::shared_ptr<nav2_costmap_2d::Costmap2DROS> costmap_ros) = 0;
Another error is related to the first line of the void StraightLine::configure() function, the one related to the parent argument, that was:
node_ = parent.lock();
Now it should be replaced simply with:
node_ = parent;
That's because this parent parameter has changed, and now it hasn't the .lock method.
Of course, it is necessary to update the configure() function in the _nav2_straightline_planner/include/nav2_straightline_planner/straight_lineplanner.hpp file:
void configure(
rclcpp_lifecycle::LifecycleNode::SharedPtr parent,
std::string name, std::shared_ptr<tf2_ros::Buffer> tf,
std::shared_ptr<nav2_costmap_2d::Costmap2DROS> costmap_ros) override;
Now, my problem: I can compile successfully the package:
source /opt/ros/foxy/setup.bash
colcon build --symlink-install
And I have changed the _nav2params.yaml file (_src/navigation2/nav2_bringup/bringup/params/nav2params.yaml):
planner_server:
ros__parameters:
expected_planner_frequency: 20.0
use_sim_time: True
planner_plugins: ["GridBased"]
GridBased:
plugin: "nav2_straightline_planner/StraightLine"
interpolation_resolution: 0.1
But when I run the simulator, using:
source /opt/ros/foxy/setup.bash
export TURTLEBOT3_MODEL=waffle
export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:/opt/ros/foxy/share/turtlebot3_gazebo/models
ros2 launch nav2_bringup tb3_simulation_launch.py params_file:=/home/srl/Documents/Github/nav_ws/src/navigation2/nav2_bringup/bringup/params/nav2_params.yaml
I get the following error:
[planner_server-9] [FATAL] [1655722824.154346143] [planner_server]: Failed to create global planner. Exception: According to the loaded plugin descriptions the class nav2_straightline_planner/StraightLine with base class type nav2_core::GlobalPlanner does not exist. Declared types are nav2_navfn_planner/NavfnPlanner smac_planner/SmacPlanner smac_planner/SmacPlanner2D
[lifecycle_manager-13] [ERROR] [1655722824.154701256] [lifecycle_manager_navigation]: Failed to change state for node: planner_server
[lifecycle_manager-13] [ERROR] [1655722824.154726900] [lifecycle_manager_navigation]: Failed to bring up all requested nodes. Aborting bringup.
[rviz2-4] Start navigation
[rviz2-4] [ERROR] [1655722916.989770691] [rviz2]: FollowWaypoints action server is not available. Is the initial pose set?
So it seems that the nav2_straightline_planner::StraightLine plugin class is not between the declared types for the _nav2core::GlobalPlanner.
Can you think of any solution to this problem?
Thank you very much Best regards
The tutorial is correct for the current status of rolling
which all tutorials target. The changes you made are w.r.t. Foxy
distribution use.
You probably just need to re-source your workspace's install space. When you successfully built the plugin package, it adds a file for the plugin index that you need to re-source so your system is aware of it.
I close this issue since it wasn't possible for us to integrate these tutorials using ROS2 Foxy version, so we are trying to do it using ROS2 Humble.
Hello to everybody,
I am trying to build the _nav2_straightlineplanner package following the navigation2 Planner plugin tutorial.
When I compile:
I get the following error:
I saw there was a closed issue related to this, but it was closed without writing the solution, and the one proposed by Philison doesn't work for me.
Can anyone help me?
Thank you very much