ROS小车移动固定距离or转向固定角度

您所在的位置:网站首页 ros小车走正方形 ROS小车移动固定距离or转向固定角度

ROS小车移动固定距离or转向固定角度

2024-07-16 06:14| 来源: 网络整理| 查看: 265

#include #include #include #include

ros::Publisher cmdVelPub;

void shutdown(int sig) {   cmdVelPub.publish(geometry_msgs::Twist());//ctrl+c   ROS_INFO("goforward cpp ended!");   ros::shutdown(); }

int main(int argc, char** argv) {   ros::init(argc, argv, "GoForward");//int ros   std::string topic = "/cmd_vel";   ros::NodeHandle node;   cmdVelPub = node.advertise(topic, 1); //=========================   double rate = 10 ;   ros::Rate loopRate(rate);   float linear_speed     = 0.2;   float goal_distance     = 1.0;   float linear_duration = goal_distance / linear_speed;

  float angular_speed    = 1.0;   float goal_angle    = M_PI;   float angular_duration= goal_angle / angular_speed;

  int count = 0;   int ticks; //================================   signal(SIGINT, shutdown);   ROS_INFO("goforward cpp start...");   geometry_msgs::Twist speed;  //================================   while (ros::ok())   {     speed.linear.x = linear_speed;     ticks = int(linear_duration*rate);         for(int i = 0;i



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3