ROS机器人底盘(13)-move_base(1)

作者: PIBOT导航机器人 | 来源:发表于2018-01-23 12:00 被阅读183次

    概述

    movebase利用actionlib包提供使得我们的机器人到达一个设置的目标点的包
    先上一张官方经典的图


    movebase
    • 图中蓝色部分与特定机器人平台有关,灰色部分是可选的,白色部分是必须的
    • 可以看到amclmap_server都是不必须的
    • 机器人平台输入相关传感器、里程计及tf信息
    • 输入为一个goal(目标点坐标)
    • 输出一个cmd_vel(速度)

    指定导航点

    首先我们查看下MoveBaseActionGoal的定义
    rosmsg show MoveBaseActionGoal

    MoveBaseActionGoal

    运行导航逻辑后,rostopic echo /move_base/goal, 点击2D Nav Goal,输出

    image.png

    结合上面2个输出可以看到geometry_msgs/PoseStamped

    • frame_id为参考坐标系
    • goal为目标点的位置(pose)与姿态(orientation)

    官方有个例子navigation_tutorials

    #include <ros/ros.h>
    #include <move_base_msgs/MoveBaseAction.h>
    #include <actionlib/client/simple_action_client.h>
    #include <tf/transform_datatypes.h>
    
    #include <boost/thread.hpp>
    
    typedef actionlib::SimpleActionClient<move_base_msgs::MoveBaseAction> MoveBaseClient;
    
    void spinThread(){
      ros::spin();
    }
    
    int main(int argc, char** argv){
      ros::init(argc, argv, "simple_navigation_goals");
    
      ros::NodeHandle n;
    
      boost::thread spin_thread = boost::thread(boost::bind(&spinThread));
    
      MoveBaseClient ac("pose_base_controller");
    
      //give some time for connections to register
      sleep(2.0);
    
      move_base_msgs::MoveBaseGoal goal;
    
      //we'll send a goal to the robot to move 2 meters forward
      goal.target_pose.header.frame_id = "base_link";
      goal.target_pose.header.stamp = ros::Time::now();
    
      goal.target_pose.pose.position.x = 2.0;
      goal.target_pose.pose.position.y = 0.2;
      goal.target_pose.pose.orientation = tf::createQuaternionMsgFromYaw(M_PI);
    
      ROS_INFO("Sending goal");
      ac.sendGoal(goal);
    
      ac.waitForResult();
    
      if(ac.getState() == actionlib::SimpleClientGoalState::SUCCEEDED)
        ROS_INFO("Hooray, the base moved 2 meters forward");
      else
        ROS_INFO("The base failed to move forward 2 meters for some reason");
    
      return 0;
    }
    

    base_link为参考坐标系, 目标就是前面2.0(x = 2.0),左0.2(y = 0.2),方向选择180°(orientation = tf::createQuaternionMsgFromYaw(M_PI))

    相关文章

      网友评论

        本文标题:ROS机器人底盘(13)-move_base(1)

        本文链接:https://www.haomeiwen.com/subject/zbsjvxtx.html