Problem in TF tutorial - Broadcasting a moving frame

asked 2019-12-26 10:12:03 -0500

english137 gravatar image

I'm learning the tutorial http://wiki.ros.org/tf/Tutorials/Addi... and I added a coefficient 'coeff' in the last part (6. Broadcasting a moving frame) as follows:

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

int main(int argc, char** argv)
{
    ros::init(argc, argv, "my_tf_broadcaster");
    ros::NodeHandle node;
    tf::TransformBroadcaster br;
    tf::Transform transform;
    ros::Rate rate(10.0);

    while (node.ok())
    {
        transform.setOrigin( tf::Vector3(2.0*sin(coeff*ros::Time::now().toSec()), 2.0*cos(coeff*ros::Time::now().toSec()), 0.0) );
        transform.setRotation( tf::Quaternion(0, 0, 0, 1) );
        br.sendTransform(tf::StampedTransform(transform, ros::Time::now(), "turtle1", "carrot1"));
        rate.sleep();  
     }  
return 0;
};

I just want to change the frequency of the circle movement, so I changed the 'coeff' respectively to 1.0, 2.0 and 0.5. But the result comes out that, the radius of the circle (the trajectory of turtle2) was also changed. When I set the coeff = 1.0, the radius is normal; coeff = 2.0, the radius shrinks to about half of the original one; coeff = 0.5, the radius was also enlarged, about 2 times as before.

So why does the radius change? How can I maintain the same radius and only change the speed of the movement.

edit retag flag offensive close merge delete