Ask Your Question
0

How to increase the rate of broadcasting

asked 2016-08-22 01:52:37 -0500

patrchri gravatar image

updated 2016-08-22 01:53:41 -0500

Hello,

I have written a base_link to map broadcaster and I am trying to increase the rate of broadcasting to 50 hz.

#include <ros/ros.h>
#include <tf/transform_broadcaster.h>
#include <geometry_msgs/PoseStamped.h>

void poseCallback(const geometry_msgs::PoseStamped::ConstPtr& msg){
  static tf::TransformBroadcaster broadcaster;
  tf::Transform transform;
  transform.setOrigin( tf::Vector3(-msg->pose.position.x, -msg->pose.position.y, -msg->pose.position.z));
  transform.setRotation(tf::Quaternion(-msg->pose.orientation.x, -msg->pose.orientation.y, -msg->pose.orientation.z, msg->pose.orientation.w));
  broadcaster.sendTransform(tf::StampedTransform(transform, ros::Time::now(), "base_link", "map"));
  ROS_INFO("Broadcasting between map and base_link successful !!!");
}

int main(int argc, char** argv){
  ros::init(argc, argv, "tf_broadcaster_node");

  ros::NodeHandle node;
  ros::Subscriber sub = node.subscribe("/slam_out_pose", 7, &poseCallback);
  ros::spin();
  return 0;
};

How can I do that ?

I checked the tf::Transform::sendTransform member function but I didn't find an input for that.

I also wanted to ask if is there another way to broadcast the connection from base_link to map ?

Thanks for your answer in advance.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-08-22 02:33:30 -0500

Shay gravatar image

You can try this:

  void poseCallback(){
     modify your transform......
  }
  int main(){
    ros::Rate rate(50.0);
    ....
    while (node.ok()){
    send your transform.....
    rate.sleep();
    ros::spinOnce();
    }
  }
edit flag offensive delete link more

Comments

or use a Timer callback.

Dimitri Schachmann gravatar image Dimitri Schachmann  ( 2016-08-22 07:09:13 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-08-22 01:52:37 -0500

Seen: 385 times

Last updated: Aug 22 '16