ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
3

TURTLEBOT Autonomous Navigation without Rviz

asked 2012-03-22 00:53:57 -0600

McMurdo gravatar image

updated 2012-03-22 12:41:32 -0600

Eric Perko gravatar image

I would like to navigate the robot autonomously, without the use of Rviz. This is what I would want to do:

  1. I want to start the robot only from a desired location and orientation at all times. Hence I want to use rviz the first time, put the robot in this pose and then give it the estimate and allow it to know it's position. This way I can also know the co-ordinates of this position on the map. I can know what this pose means on the map.
  2. Then I want to change the way the turtlebot starts the amcl_demo. I want it to take the pose I give it - the one obtained from step 1 - and it should take it as a serious estimate. But without RVIZ.
  3. Then I would want to specify the co-ordinates of a point on the map, which is my 2D Nav Goal. This one too I would like to do without RVIZ.
edit retag flag offensive close merge delete

4 Answers

Sort by ยป oldest newest most voted
4

answered 2012-03-22 08:24:11 -0600

brianpen gravatar image

updated 2012-03-22 08:29:13 -0600

I was just looking at this the other day. RViz just publishes on certain topics (or calls actionlib actions). Here's some code for setting the initial position of the robot. You can "rostopic echo /initialpose" while setting the initialpose in RViz to see what it looks like.

As others have mentioned, you can also specify an initial pose using parameters in the launch file. Just copy amcl_demo.launch to your development directory and add in the parameters.

To give the robot a goal, just publish a PoseStamped to /move_base_simple/goal or use the actionlib interface to move_base.

python for setting initial pose:

#!/usr/bin/env python

import roslib; roslib.load_manifest('proto')
import rospy
from geometry_msgs.msg import *

def gen_pose():
    pub = rospy.Publisher('initialpose', PoseWithCovarianceStamped)
    rospy.init_node('initial_pose'); #, log_level=roslib.msg.Log.INFO)
    rospy.loginfo("Setting Pose")

    p   = PoseWithCovarianceStamped();
    msg = PoseWithCovariance();
    msg.pose = Pose(Point(-0.767, -0.953, 0.000), Quaternion(0.000, 0.000, -0.0149, 0.9999));
    msg.covariance = [0.25, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.25, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.06853891945200942];
    p.pose = msg;
    pub.publish(p);

if __name__ == '__main__':
    try:
        gen_pose()
        rospy.loginfo("done")
    except Exception, e:
        print "error: ", e

Here's some python for setting a movement goal:

... snip ...
        location =  Pose(Point(15.322, 11.611, 0.000), Quaternion(0.000, 0.000, 0.629, 0.777))
        self.goal = MoveBaseGoal()
        self.goal.target_pose.pose = location
        self.goal.target_pose.header.frame_id = 'map'
        self.goal.target_pose.header.stamp = rospy.Time.now()

        self.move_base.send_goal(self.goal)

        time = self.move_base.wait_for_result(rospy.Duration(300))
edit flag offensive delete link more
5

answered 2012-03-22 06:20:56 -0600

Mac gravatar image

All rviz does when you click the various buttons is publish messages on certain topics (possibly through actionlib). Take a look at the topics rviz publishes while it's running, and see what happens when you click things...

edit flag offensive delete link more
3

answered 2012-03-22 06:58:42 -0600

Murph gravatar image

You can set the initial pose and covariance in your .launch file as a parameter.

http://ros.org/wiki/amcl

initial_pose_x, initial_pose_y, initial_pose_a, initial_cov_xx, initial_cov_yy, initial_cov_aa

edit flag offensive delete link more
2

answered 2012-03-22 09:32:20 -0600

McMurdo gravatar image

Yes, We wrote some code for the autonomous navigation in the exact same way you guys mentioned. We figured the solution just after creating the question. Since there was no such question, I thought this would help a lot of people. Thanks a lot, people...

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2012-03-22 00:53:57 -0600

Seen: 4,386 times

Last updated: Mar 22 '12