Visit multiple goals autonomously

asked 2016-10-21 04:40:07 -0600

gazebot gravatar image

Hi everyone, We are working on a project to integrate battery performance into path planning using a Turtlebot 2 with ROS Indigo on Ubuntu Trusty. We're both civil engineering students working on a mapping project, and are new to robotics and coding. Preferably we would work in Python, and continue to modify this code, instead of starting from scratch. We want to modify the go_to_specific_points.py provided in the tutorials to visit multiple points of a known map. We simply used ‘publish point’ in Rviz to determine a path as an entered the points as an array in place of a single goal in the code. However, we wanted to know if there is a simple way to call on a text file that contains the predetermined coordinates with this function, so we don't have to edit the code for each new map we work with. Sorry, this is such a basic question, but we have searched around and cannot understand how to implement this. We have also followed most of the tutorials at learn.turtlebot and here at ROS.org , as reading through the navigation stack information. We want to eventually get the robot to determine its own path, but one step at a time. Our goal is aligned to this question, asked by danielq: http://answers.ros.org/question/66146... Our simple modification of the go_to_specific_point.py:

test_array=[0.0363,1.510,-3.970,1.870,-4.10,1.23,-0.475,0.717,-1.03,-2.69,2.39,-3.59,2.63,-2.83,-0.37,-1.93,0.00,0.00]  
for i in range(0,18,2):
        rospy.init_node('nav_test', anonymous=False)
        navigator = GoToPose()

Within the code looks like:

if __name__ == '__main__': try:

test_array=[0.0363,1.510,-3.970,1.870,-4.10,1.23,-0.475,0.717,-1.03,-2.69,2.39,-3.59,2.63,-2.83,-0.37,-1.93,0.00,0.00]  
for i in range(0,18,2):
        rospy.init_node('nav_test', anonymous=False)
        navigator = GoToPose()

    # Customize the following values so they are appropriate for your location Hi everyone,
        position = {'x': test_array[i], 'y' : test_array[i+1]}
        quaternion = {'r1' : 0.000, 'r2' : 0.000, 'r3' : 0.000, 'r4' : 1.000}

        rospy.loginfo("Go to (%s, %s) pose", position['x'], position['y'])
        success = navigator.goto(position, quaternion)

        if success:
                rospy.loginfo("Hooray, reached the desired pose")
        else:
                rospy.loginfo("The base failed to reach the desired pose")

    # Sleep to give the last log messages time to be sent
    rospy.sleep(1)

except rospy.ROSInterruptException:
    rospy.loginfo("Ctrl-C caught. Quitting")

Cheers

edit retag flag offensive close merge delete