ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

How to recognize when tf has stopped publishing?

asked 2012-07-12 10:54:00 -0600

Antares gravatar image

I use /tf topic to calculate a parameter with C++. I use what is written in the tf tutorial to listen to the transforms. I use a callback with "ros::spinOnce(); rate.sleep();" so only when I press Ctrl+C the program stops. My problem is that I need to know when I do not have publishing tf; that means when the /tf stops publishing. Is there any function that checks the existence of /tf and for example becomes False when the /tf is not published anymore?

edit retag flag offensive close merge delete

Comments

Thanks really cagatay it is working!!

Antares gravatar image Antares  ( 2012-07-17 04:16:10 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
4

answered 2012-07-12 12:52:48 -0600

cagatay gravatar image

updated 2012-07-12 12:56:17 -0600

hello,

you may check out waitForTransform()

bool tf::TransformListener::waitForTransform (const std::string &target_frame, const std::string &source_frame, const ros::Time &time, const ros::Duration &timeout, const ros::Duration &polling_sleep_duration=ros::Duration(0.01), std::string *error_msg=NULL) const

Test if source_frame can be transformed to target_frame at time time. The waitForTransform() methods return a bool whether the transform can be evaluated. It will sleep and retry every polling_duration until the duration of timeout has been passed. It will not throw. If you pass a non NULL string pointer it will fill the string error_msg in the case of an error. (Note: That this takes notably more resources to generate the error message.)

or

The canTransform() methods return a bool whether the transform can be evaluated. It will not throw. If you pass a non NULL string pointer it will fill the string error_msg in the case of an error.

bool tf::TransformListener::canTransform (const std::string &target_frame, const std::string &source_frame, const ros::Time &time, std::string *error_msg=NULL) const
edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-07-12 10:54:00 -0600

Seen: 500 times

Last updated: Jul 12 '12