Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gazebo_ros: Wait spawning Gazebo Model until ros::Time::now() is not 0. #1024

Open
wants to merge 1 commit into
base: melodic-devel
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions gazebo_ros/src/gazebo_ros_api_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2660,6 +2660,8 @@ bool GazeboRosApiPlugin::spawnAndConform(TiXmlDocument &gazebo_model_xml, const

/// \brief poll and wait, verify that the model is spawned within Hardcoded 10 seconds
ros::Duration model_spawn_timeout(10.0);
/// Wait until time can be read.
while (ros::Time::now().is_zero());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If simulation is started paused, this line will hang until simulation starts running. I'm not sure if this is desired.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might make more sense to switch this to be wall time not ROS time. I'm assuming this is resource contention based and not simulation time passing. Then we won't need to worry about whether ROS time is initialized.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand the comment form @spark4160 it is related to simulation time passing.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where would I find the file gazebo_ros_api_plugin?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

@hichamhendy hichamhendy Jun 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I installed gazebo ros packages using sudo apt-get install ros-melodic-gazebo-ros-pkgs ros-melodic-gazebo-ros-control and I can not find this directory!
image

Where would I find the file on melodic distribution?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hichamhendy did you find a solution for this

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I skipped it!!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the terminal that launched my gazebo world and found the errors that I needed to fix there. So if the URDF file has any issues, it doesn't load and times out.

ros::Time timeout = ros::Time::now() + model_spawn_timeout;

while (ros::ok())
Expand Down