Setting up parameters for selective application of nav2 libraries
I want to use the tracking controllers from nav2
as part of my simulation environment, in real life there will be a 3rd party tracking controller to which I can supply paths, but for simulation I am trying to emulate it.
As such, I am in a weird situation because I have paths generated, contours and AB lines, and I have obstacle avoidance and localization handled elsewhere. I purely want nav2
to act as a path->cmd_vel
handler and nothing more. Setting this up has proven difficult as I don't have so much experience with nav2
.
I am under the impression that it requires a map, therefore I've made an empty map, filled with only pixels of 254 grayscale. This is because this part should not consider obstacles, as that will be handled elsewhere. I'm not sure then if I need to enable the local or only the global map parameter configurations? Furthermore I have disabled amcl
, in favor of using robot_localization
instead.
Upon startup I get many error messages of
[bt_navigator-5] [INFO] [1638782303.256835846] [bt_navigator]: Configuring
[bt_navigator-5] [ERROR] [1638782303.285669115] []: Caught exception in callback for transition 10
[bt_navigator-5] [ERROR] [1638782303.285699955] []: Original error: Could not load library: libnav2_compute_path_through_poses_action_bt_node.so: cannot open shared object file: No such file or directory
[bt_navigator-5] [WARN] [1638782303.285730258] []: Error occurred while doing error handling.
[bt_navigator-5] [FATAL] [1638782303.285741871] [bt_navigator]: Lifecycle node bt_navigator does not have error state implemented
[lifecycle_manager-7] [ERROR] [1638782303.286312696] [lifecycle_manager_navigation]: Failed to change state for node: bt_navigator
[lifecycle_manager-7] [ERROR] [1638782303.286358255] [lifecycle_manager_navigation]: Failed to bring up all requested nodes. Aborting bringup.
As I said I'm not very experienced with nav2, so I'm not entirely sure which of the 20+ plugins are necessary, or if what I am trying to do is even really feasible. Note, using this and this as inspiration. Does anyone know of any examples of something similar?
map.yaml
image: default.pgm
resolution: 0.1
origin: [-50.0, -50.0, 0.0] # [0.0, 0.0, 0.0]
negate: 0
occupied_thresh: 0.65
free_thresh: 0.196
my navigation.launch.py
import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.actions.execute_process import ExecuteProcess
from launch.actions.include_launch_description import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
def generate_launch_description():
# Get the launch directory
bringup_dir = get_package_share_directory("nav2_bringup")
tractor_gazebo_dir = get_package_share_directory("tractor_gazebo")
# Create the launch configuration variables
use_sim_time = LaunchConfiguration("use_sim_time")
autostart = LaunchConfiguration("autostart")
params_file = LaunchConfiguration("params_file")
map_file = LaunchConfiguration("map_file")
# declare launch arguments
declare_use_sim_time = DeclareLaunchArgument(
"use_sim_time",
default_value="True",
description="Flag to enable use_sim_time",
)
declare_autostart = DeclareLaunchArgument(
"autostart",
default_value="True",
description="Automatically startup the nav2 stack",
)
declare_params_file = DeclareLaunchArgument(
"params_file",
default_value=os.path.join(
tractor_gazebo_dir, "config", "nav2.yaml" # "nav2_pure_pursuit.yaml"
),
description="Full path to the ROS2 parameters file to use",
)
declare_map_file = DeclareLaunchArgument(
"map_file",
default_value=os.path.join(tractor_gazebo_dir, "map", "default.yaml"),
description="Full path to the nav2 map yaml file to use",
)
nav2_map_server = Node(
package="nav2_map_server",
executable="map_server",
name="map_server",
output="screen",
parameters=[params_file ...