ROS 小海龟turtle 原地画圈 C++实现

小海龟turtle原地转圈 C++实现

/turtle1/cmd_vel
[geometry_msgs/Twist] /
linear.x
angular.z

#include <ros/ros.h>
#include "geometry_msgs/Twist.h"
using namespace ros;

int main(int argc, char **argv){
    init(argc, argv, "publisher");
    NodeHandle node;

    Publisher pub = node.advertise<geometry_msgs::Twist>("/turtle1/cmd_vel",100);

    Rate rate(1);
    while (ok()) {
        geometry_msgs::Twist msg;
        msg.linear.x = 0.5;
        msg.angular.z = 0.2;

        pub.publish(msg);
        ROS_INFO("publish turtle message command[%0.2f m/s,%0.2f rad/s]", msg.linear.x, msg.angular.z);
        rate.sleep();
    }
    return 0;
}

运行如下:
运行如下

原创文章 44 获赞 8 访问量 3885

猜你喜欢

转载自blog.csdn.net/weixin_44692299/article/details/104292597