cra-ros-pkg / robot_localization

robot_localization is a package of nonlinear state estimation nodes. The package was developed by Charles River Analytics, Inc. Please ask questions on answers.ros.org.
http://www.cra.com
Other
1.41k stars 902 forks source link

Robot_localization listener node- ERROR unexpected process noise covariance matrix size (0) #844

Open marco-indino opened 1 year ago

marco-indino commented 1 year ago

Hi, i'm using Ros2 Humble on Ubuntu 22.04 to simulate an autonomous robot that localizes with EKF within the Robot_localization package and use Nav2 to navigate. I have followed all the guides to set up properly the robot_localization and i obtained good results. I was able to localize correctly the robot and my tf tree is as it should be(utm->map->odom->base_footprint->base_link->sensors and wheel).

I'm opening this issue because the problem i am about to describe concern also the Nav2 using GPS Localization https://navigation.ros.org/tutorials/docs/navigation2_with_gps.html.

I start by launching the simulation and the dual_ekf_navsat node to obtain the proper localization. then I start also a launch file that contains all the necessary server to activate Nav2 and until here everything works fine since i can visualize in rviz my robot correctly localized and all the obstacle that he see via lidar.

Now when i start a different node that contains the code for the autonomous navigation , it get stuck on the line that says: navigator.waitUntilNav2Active(localizer='robot_localization') and in the terminal i have this debug line: [INFO] [1700586809.391086991] [basic_navigator]: robot_localization/get_state service not available, waiting... (that is the same line that i also have when i run the test in the link above).

This is due to the missing getState service which i read is not present in the robot_localization node that i ran(ekf and navsat). so by doing some digging i found out that according to #318 the getState service was added in the robot_localization_listener_node but when i try to run this one :

launch_ros.actions.Node(package="robot_localization",
executable="robot_localization_listener_node",
name="robot_localization_listener",
output="screen",
parameters=[rl_params_file, {"use_sim_time": True}],
remappings=[("odom/filtered","odometry/global"),("acceleration/filtered","accel/filtered")]),

with rl_params_file containing the custom ekf.yaml in which usually we specify the sensor we are fusing and the parameter for the navsat node.

When i run this node after everything i obtain the following error: [INFO] [test_robot_localization_estimator-1]: process has finished cleanly [pid 49180] [ERROR] [robot_localization_listener_node-2]: process has died [pid 49182, exit code -11, cmd '/opt/ros/humble/lib/robot_localization/robot_localization_listener_node --ros-args -r __node:=robot_localization_listener -r odom/filtered:=odometry/global -r acceleration/filtered:=accel/filtered'].

What can i do? i search everything and also tried to understand the cpp file of the robot_listener but seems it does not retrieve the size of the process noise covariance matrix.

marco-indino commented 12 months ago

I managed to solve the problem by reading the file in the following link answered by @SteveMacenski : https://robotics.stackexchange.com/questions/105711/nav2-interactive-waypoint-follower-example-can-not-get-robot-localization-state

Basically the problem was that in the robot_navigation.py in the nav2_simple_commander package were missing some lines under the function WaitUntilNav2IsActive that are present in the IRON version.

The code in Humble was:

    def waitUntilNav2Active(self, navigator='bt_navigator', localizer='amcl'):
        """Block until the full navigation system is up and running."""
        self._waitForNodeToActivate(localizer)
        if localizer == 'amcl':
            self._waitForInitialPose()
        self._waitForNodeToActivate(navigator)
        self.info('Nav2 is ready for use!')
        return

And the correct version taken from the IRON version is:

def waitUntilNav2Active(self, navigator='bt_navigator', localizer='amcl'):
        """Block until the full navigation system is up and running."""
        if localizer != "robot_localization":
            self._waitForNodeToActivate(localizer)
        if localizer == 'amcl':
            self._waitForInitialPose()
        self._waitForNodeToActivate(navigator)
        self.info('Nav2 is ready for use!')
        return

I think it could be changed as well in the HUMBLE branch, is it possible?