• ROS多点导航


    cd ~/catkin_ws/src
    catkin_create_pkg myrobot rospy geometry_msgs sensor_msgs
    

      

    cd ~/catkin_ws/src/myrobot/src
    vim patrol.py
    

      

    #!/usr/bin/env python
     
    import rospy
    import actionlib
     
    from move_base_msgs.msg import MoveBaseAction, MoveBaseGoal
     
     
    waypoints = [  # <1>
        [(1.522, 0.444, 0.0), (0.0, 0.0, -0.519, 0.85)],
        [(-2.0432, -0.439, 0.0), (0.0, 0.0, -0.559, 0.82902)]
    ]
    

      

    def goal_pose(pose):  # <2>
        goal_pose = MoveBaseGoal()
        goal_pose.target_pose.header.frame_id = 'map'
        goal_pose.target_pose.pose.position.x = pose[0][0]
        goal_pose.target_pose.pose.position.y = pose[0][1]
        goal_pose.target_pose.pose.position.z = pose[0][2]
        goal_pose.target_pose.pose.orientation.x = pose[1][0]
        goal_pose.target_pose.pose.orientation.y = pose[1][1]
        goal_pose.target_pose.pose.orientation.z = pose[1][2]
        goal_pose.target_pose.pose.orientation.w = pose[1][3]
     
        return goal_pose
     
    

      

    if __name__ == '__main__':
        rospy.init_node('patrol')
     
        client = actionlib.SimpleActionClient('move_base', MoveBaseAction)  # <3>
        client.wait_for_server()
         
        while True:
            for pose in waypoints:   # <4>
                print("goal:x=%f y=%f"%(pose[0][0],pose[0][1]))
                goal = goal_pose(pose)
                client.send_goal(goal)
                client.wait_for_result()
    

      

    rostopic echo amcl_pose -n 1
    

      

    rosrun myrobot patrol.py
    

      

    chmod 777 patrol.py
    

      

    参考:

    https://www.guyuehome.com/10949

  • 相关阅读:
    汉语-词语-转世:百科
    汉语-词语-往生:百科
    中缀表达式值
    车厢调度(train.cpp)
    字符串匹配问题
    计算(calc.cpp)
    2、括弧匹配检验
    2058 括号序列
    7909:统计数字
    1007. 计算余数
  • 原文地址:https://www.cnblogs.com/kay2018/p/16312619.html
Copyright © 2020-2023  润新知