Why "ROS_INFO" can correct my "runtime_error"?

asked 2020-09-07 21:16:08 -0600

larrydong gravatar image

When launching a lidar driver, the program gives me

"terminate called after throwing an instance of 'std::runtime_error' what(): Time is out of dual 32-bit range".

It seems that the type of time is wrong. But when debugging the codes, I found that when adding a "ROS_INFO("111")" line, the program can surprisingly run.

So does ROS_INFO change the time in ROS, or something else?


edit retag flag offensive close merge delete



It's probably not the ROS_INFO() specifically that "fixes" the issue. It's probably some race condition / accesing a variable before it is set by dvr(). I would bet if you sleep for some microseconds there instead of ROS_INFO() the behavior would be similar.

Reamees gravatar image Reamees  ( 2020-09-09 07:36:15 -0600 )edit

Thanks for your reply. Turely it's not because of ROS_INFO, but some delay there can solve the problem. Thanks so much!

larrydong gravatar image larrydong  ( 2020-09-28 07:40:58 -0600 )edit

A bit late and I'm not sure how you ended up solving the issue, but just adding some delay is not a proper fix. The amount of time you would generally need to wait is to some extent random and definitely system specific. To properly solve it you would need to add some checks that all required data is initialized. Most appropriate would probably be in the driver class initialization function. If that is out of your control then you can add a check instead of the ROS_INFO(). By the error it seems that some Time variable is probably not initialized before trying to use it.

Reamees gravatar image Reamees  ( 2020-11-30 02:45:07 -0600 )edit