ROS-动态tf坐标转换

#include "ros/ros.h"
#include "tf/transform_broadcaster.h"//tf发布
#include "tf/transform_datatypes.h"

int main(int argc, char **argv){
        ros::init(argc, argv, "robot_tf_publisher");
        ros::NodeHandle n;
        ros::Rate r(10);

        tf::TransformBroadcaster broadcaster;//tf发布器
        float angle = 0.0;
        float x = 0.0;
        float y = 0.0;
        float z = 0.0;

        ROS_INFO("start TF transform");

        while(n.ok()){
                x = cos(angle)*0.3;
                y = sin(angle)*0.3;
                z = 0.2;
                broadcaster.sendTransform(
                        tf::StampedTransform(
                                tf::Transform(tf::createQuaternionFromRPY(0.0,0.0,angle), tf::Vector3(x, y, z)),
                                ros::Time::now(),"tf1","tf3"));//(弧度到四源数转换,3相对1变
                angle += 0.01;
                r.sleep();
                
        
        }
}

你可能感兴趣的:(自动驾驶,机器学习,人工智能)