ROS机器人turtlesim画圆轨迹的示例代码?
时间: 2023-03-29 21:00:16 浏览: 186
Python 用turtle实现用正方形画圆的例子
以下是画圆轨迹的示例代码:
#include <ros/ros.h>
#include <geometry_msgs/Twist.h>
int main(int argc, char** argv)
{
ros::init(argc, argv, "turtle_circle");
ros::NodeHandle nh;
ros::Publisher pub = nh.advertise<geometry_msgs::Twist>("/turtle1/cmd_vel", 100);
ros::Rate rate(10);
while(ros::ok())
{
geometry_msgs::Twist msg;
msg.linear.x = 1.;
msg.angular.z = 1.;
pub.publish(msg);
rate.sleep();
}
return ;
}
阅读全文