RoverRobotics / roverrobotics_ros2

Rover Robotics ROS2 Packages
https://roverrobotics.com/
Apache License 2.0
24 stars 7 forks source link

Issue while using gazebo simulation #19

Closed talari-bgu closed 10 months ago

talari-bgu commented 10 months ago

Hi,

We've ordered two Zero 3 units, so I'm trying to get familiar with them through simulation. I followed the guide and successfully set up a simulation of a 2WD rover equipped with LiDAR. To ensure the simulation was functioning correctly, I used simple cmd_vel commands to move the rover around.

The next step was use the commands:

  1. ros2 launch roverrobotics_driver slam_launch.py use_sim_time:=true
  2. ros2 launch roverrobotics_driver navigation_launch.py use_sim_time:=true map_file_name:=<default maze map path>

In the slam terminal i get the errors: [async_slam_toolbox_node-2] [INFO] [1691593316.753919425] [slam_toolbox]: Message Filter dropping message: frame 'lidar_link' at time 73.701 for reason 'the timestamp on the message is earlier than all the data in the transform cache'

[async_slam_toolbox_node-2] [INFO] [1691593316.937824162] [slam_toolbox]: Message Filter dropping message: frame 'lidar_link' at time 73.800 for reason 'the timestamp on the message is earlier than all the data in the transform cache'

[async_slam_toolbox_node-2] [INFO] [1691593317.112864164] [slam_toolbox]: Message Filter dropping message: frame 'lidar_link' at time 73.902 for reason 'the timestamp on the message is earlier than all the data in the transform cache'

In the nav2 terminal i get the errors: [localization_slam_toolbox_node-2] [INFO] [1691593321.386062763] [slam_toolbox]: Message Filter dropping message: frame 'lidar_link' at time 76.500 for reason 'the timestamp on the message is earlier than all the data in the transform cache'

[localization_slam_toolbox_node-2] [INFO] [1691593321.556707462] [slam_toolbox]: Message Filter dropping message: frame 'lidar_link' at time 76.602 for reason 'the timestamp on the message is earlier than all the data in the transform cache'

[controller_server-3] [INFO] [1691593321.556724753] [local_costmap.local_costmap]: Message Filter dropping message: frame 'lidar_link' at time 76.602 for reason 'the timestamp on the message is earlier than all the data in the transform cache'

Note: I run all commands through the same pc with ROS Humble. Im not sure how to handle those errors, any ideas?

Thanks, Tal

jackarivera commented 10 months ago

Make sure you are not running these commands at the same time. They are set up to be run separately with two different functions: slam_launch.py: This launches slam toolbox in mapping mode and creates a map of the environment as you drive around.

navigation_launch.py: This launches slam toolbox in localization mode as well as navigation2.

If you launch both then there is interference between the two different slam toolbox nodes.

If you are launching them separately, then I think this must be an issue with robot localization not getting the use_sim_time parameter. I am testing this now and seeing if I can reproduce this issue.

jackarivera commented 10 months ago

I was not able to reproduce this issue on a fresh install of the repository. Here are the steps I would recommend to ensure a properly working simulation:

1) Launch the simulation: ros2 launch roverrobotics_gazebo 2wd_rover_gazebo.launch.py

2) Do not press start on the simulation yet

3) Launch either slam or navigation: ros2 launch roverrobotics_driver slam_launch.py use_sim_time:=true OR ros2 launch roverrobotics_driver navigation_launch.py use_sim_time:=true map_file_name:=<default maze map path>

4) Then press play on the simulation once slam or navigation is loaded up. This ensures everything starts at the correct time.

talari-bgu commented 10 months ago

After reinstalling the repository, Im still having the same error. The steps:

  1. Launch simulation
  2. Launch slam node with "use_sim_time:=true"
  3. Press play buttom on the simulation

I tried to do the same thing with the mini robot, and the same error occurred.

jackarivera commented 10 months ago

Interesting. I am still unable to reproduce this issue. Can you try this:

Launch the simulation with the following: ros2 launch roverrobotics_gazebo 2wd_rover_gazebo.launch.py use_sim_time:=true

Then launch slam: ros2 launch roverrobotics_driver slam_launch.py use_sim_time:=true

Then play the simulation.

After starting could you check in rviz to see if the map is getting created and laserscans are showing? If so it should be good. If you are getting the same error constantly then please report back with either screenshots or console logs. Also, I am going to push some changes to the main branch shortly to make set up for the simulation a little easier. I will mention this issue in that pull request.

jackarivera commented 10 months ago

PR #21 makes it so you don't need to enable to lidar and imu anymore. I also fixed the topic the simulated imu is publishing on to be consistent with our packages. These shouldn't necessarily have any effect on the issue you have currently but if a clean install is needed it will make it quicker to set up afterwards.

talari-bgu commented 10 months ago

I appreciate your time!

Initially, I believed the issue might be hardware-related, so I tried your last suggestion on a more powerful PC. Unfortunately, the same error occurred. I now suspect it might be related to Humble or Slam-toolbox. I'll investigate further and, hopefully, post a solution once I've found one.

jackarivera commented 10 months ago

Ok sounds good! If you find the solution or find it to be related to our packages please post back here and I will get a PR made as soon as possible to fix it.

talari-bgu commented 10 months ago

The problem was that, even though we're sending _slamlaunch.py/_navigationlaunch.py with _use_simtrue=true, the parameter _use_simtime inside of _localizationekf.yaml wouldn't change and used the default value of false. Temp fix: Changing the parameter _use_simtime manually to true inside of _localizationekf.yaml fixes the problem for both slam and navigation launches.

jackarivera commented 10 months ago

Thanks for bringing this to my attention! There was a slight issue in the launch file that caused the use_sim_time to not be correctly passed into the robot localization node. I've fixed it in PR #26 and it has been merged into the main branch for now.

I am going to close out this issue but please feel free to reopen it if for some reason this patch does not solve it for you!