Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Tf: refresh broadcaster's sendTransform parameters

Hy Community!

I am really new in ROS tf, but i am starting to be familiar with it. I just need a little help with my thesis work. I get the main code from this tutorial.

double X_w, Y_w, Z_w, theta_dx;
ros::Subscriber operationTopic;

void callbackCallback(const DroneNavigationPackage::TransformParameters::ConstPtr& msg)
{
    X_w = msg -> X_w;
    Y_w = msg -> Y_w;
    Z_w = msg -> Z_w;
    theta_dx = msg -> theta_dx;
}

I added this callback function to help my node to fulfill it's task. The goal of this callback function is to refresh the transformation parameters of my Drone's coordinate system related to the world coordinate system (i have an indoor ultrasonic localization system, and i would like to calculate the destination's coordinates in the drone's coordinate system). I get this sensitive data long after my DroneNavigationPackage is started (along with this node too).

ros::init(argc, argv, "w2d_tf_broadcaster");
ros::NodeHandle node;

ros::Rate r(100);

tf::TransformBroadcaster broadcaster;

while( node.ok() )
{

    operationTopic = node.subscribe("/ControlCenter/set_transform_params", 100, callbackCallback);
    broadcaster.sendTransform(
        tf::StampedTransform(
            tf::Transform(tf::Quaternion(0, 0, 0, 1), tf::Vector3(X_w, Y_w, Z_w)),
            ros::Time::now(),"{W}", "{D}"));

    r.sleep();
}

But the problem is when I send the new values on the topic, the new data does not appear in the broadcasted relation. So my question is: how can I refresh the sendTransform parameters to their new values? I mean i want to add

  • new tf::Vector3 variable
  • new tf:Quaternion() variable

to this tf imaging: world -> drone.

Thanks in advance! Steve