tf broadcasting rate
hello
im trying to increase the rate of which tf transform is being published it seems that no matter what i do the rate stays 1 hz even if cout prints at 10 hz, when i tf_echo the transform it still appears to be published at 1 hz i didnt find in ROS ANSWER any documentation about that
thanks!
#include <ros/ros.h>
#include <iostream>
#include <tf/transform_broadcaster.h>
int main(int argc, char** argv){
ros::init(argc, argv, "tfpub");
ros::NodeHandle n;
ros::Rate r(10.0);
tf::TransformBroadcaster broadcaster;
while(n.ok()){
broadcaster.sendTransform(
tf::StampedTransform(
tf::Transform(tf::Quaternion(0, 0, 0, 1), tf::Vector3(0.1, 0.0, 0.2)),
ros::Time::now(),"map", "odom"));
std::cout<< ros::Time::now() <<std::endl;
r.sleep();
ros::spinOnce();
}
}
This probably won't fix the issue, but put the
ros::spinOnce();
call before ther.sleep();
call. You should never have anything after aRate.sleep()
call as this messes with loop timing.