Naviagation goal through command terminal

How to give the robots their navigation goals through command terminal or some scripting? It can be used to give series of nav goals at one stretch! Thank you!

Hi @dhanaprakaashg,

In order to send a navigation goal via the command line you have to publish to the topic move_base_simple/goal
a message of type: geometry_msgs/PoseStamped.

Here is an example command for you to test:
rostopic pub /move_base_simple/goal geometry_msgs/PoseStamped '{header: {stamp: now, frame_id: "map"}, pose: {position: {x: 1.0, y: 0.0, z: 0.0}, orientation: { x: 0, y: 0, z: 0, w: 1 }}}'

In order to send a goal programmatically you can use an action. Here is a minimal python script that does just that:

#!/usr/bin/env python

import rospy
import actionlib
from move_base_msgs.msg import MoveBaseAction, MoveBaseGoal

def movebase_action_client():

    client = actionlib.SimpleActionClient('move_base',MoveBaseAction)

    goal = MoveBaseGoal()
    goal.target_pose.header.frame_id = "map"
    goal.target_pose.header.stamp =
    goal.target_pose.pose.position.x = 1.0
    goal.target_pose.pose.position.y = 5.0
    goal.target_pose.pose.orientation.w = 1.0
    goal.target_pose.pose.orientation.x = 0.0
    goal.target_pose.pose.orientation.y = 0.0
    goal.target_pose.pose.orientation.z = 0.0

    wait = client.wait_for_result()
    if not wait:
        rospy.logerr("Action server not available!")
        rospy.signal_shutdown("Action server not available!")
        return client.get_result()

if __name__ == '__main__':
        result = movebase_action_client()
        if result:
            rospy.loginfo("Goal execution done!")
    except rospy.ROSInterruptException:
        rospy.loginfo("Navigation test finished.")

Hope this helps,


1 Like