linorobot / linorobot2

Autonomous mobile robots (2WD, 4WD, Mecanum Drive)
Apache License 2.0
436 stars 148 forks source link

No transform from [ALL_WHEELS] to map #64

Open JoaquinUrrisa opened 1 year ago

JoaquinUrrisa commented 1 year ago

Issue Summary

Hi, I'm new to ROS2 and I'm trying to run the mecanum robot simulated in gazebo and with SLAM. However I get an error when trying to see the RobotModel in RViz.

Issue Details

I followed the README, first using the linorobot2_desciption launch and i could see the RobotModel perfectly in Rviz. Then i used the linorobot_gazebo launch and everithing worked (i even moved the robot with the teleop package). But when i tried linorobot_navigation slam.launch.py with rviz:=true i got the following warning:

[rviz2-2] Warning: Invalid frame ID "front_left_wheel_link" passed to canTransform argument source_frame - frame does not exist
[rviz2-2]          at line 93 in ./src/buffer_core.cpp
[rviz2-2] Warning: Invalid frame ID "front_right_wheel_link" passed to canTransform argument source_frame - frame does not exist
[rviz2-2]          at line 93 in ./src/buffer_core.cpp
[rviz2-2] Warning: Invalid frame ID "rear_left_wheel_link" passed to canTransform argument source_frame - frame does not exist
[rviz2-2]          at line 93 in ./src/buffer_core.cpp
[rviz2-2] Warning: Invalid frame ID "rear_right_wheel_link" passed to canTransform argument source_frame - frame does not exist
[rviz2-2]          at line 93 in ./src/buffer_core.cpp

and the following error in Rviz: rviz_error

Steps to Reproduce

  1. In one terminal I run ros2 launch linorobot2_gazebo gazebo.launch.py
  2. Then, in another terminal I run ros2 launch linorobot2_navigation slam.launch.py rviz:=true sim:=true

System Information

Additional Information

Despite the error the mapping works.

I noticed that the TF tree did not have tfs for the wheels. Upon some reasearch i found that usually the joint_state_publisher node is used for that purpose. So I changed the publish_joints argument from false to true in:

        IncludeLaunchDescription(
            PythonLaunchDescriptionSource(description_launch_path),
            launch_arguments={
                'use_sim_time': str(use_sim_time),
                'publish_joints': 'false',
            }.items()
        ),

in the gazebo.launch.py file and was able to see the robot model in Rviz (i also had to change the fixed frame from map to base_link despite the TF tree being as shown below).

tf

grassjelly commented 1 year ago

there's no TF between map frame and odom frame at runtime, you have to set the robot's initialpose (either from Rviz or programmatically https://github.com/ros-planning/navigation2/blob/main/nav2_simple_commander/nav2_simple_commander/robot_navigator.py#L109) to give the robot its prior

JoaquinUrrisa commented 1 year ago

Hi, thanks for the quick response!

I tried setting the initial pose (both with Rviz 2D pose estimate tool and with 'ros topic pub /set_pose') but got the same result.

Can you explain a bit more why there's no TF between map and odom? Because without me setting the initialpose, the TF Tree already shows a TF from map to odom:

tf_publisher_false

grassjelly commented 1 year ago

sorry my bad, setting initialpose is only for navigation. Did you manage to create a full map even with those errors?

JoaquinUrrisa commented 1 year ago

Yes, mapping works fine just two errors: