Esempio n. 1
0
    def __init__(self, name, wheelbase=0.352):
        """
        :param name: <string> that will be the 'name'.log file and the name of the node created
        :return: None
        """


        """ SETUP::
            1) will instantiate the base logging class and start the node
            2) sets up all the publishers and subscribers
            3) ...
        """
        ## Loggers and node information
        rospy.init_node(name)

        self.map = gMap(name+"Map")
        self.local = localMap(name+'Local Map')
        self._name_ = name

        self._x_offset = None
        self._y_offset = None
        self._x, self._y = 0,0


        ## Pub/Sub information
        self._vel_pub = rospy.Publisher('cmd_vel_mux/input/teleop', Twist, queue_size=1)
        # self._mov_pub = rospy.Publisher('/move_base/goal',PoseStamped,queue_size=1)


        self._odom_sub = rospy.Subscriber('/odom', Odometry, self.odomCallback, queue_size=3)
        self._click_sub = rospy.Subscriber('/move_base_simple/goalRBE', PoseStamped, self.storeGoal, queue_size=1) # check out the self.map.storeGoal thing
        self._local_cost = rospy.Subscriber('/move_base/local_costmap/costmap',OccupancyGrid,self.storeCostmap, queue_size=1)
        # self._map_sub = rospy.Subscriber('/move_base/global_costmap/costmap_updates', OccupancyGridUpdate , self._updateMap, queue_size=1)
        self._map_sub = rospy.Subscriber('/map', OccupancyGrid, self._updateMap, queue_size=1)
        # self._bmp_sub = rospy.Subscriber('/mobile_base/events/bumper', BumperEvent, turtlebot.setBumper, queue_size=3)


        #### Private variables that get updated by callbacks.
        ## Odom Handlers ##
        self._odom_list = tf.TransformListener()
        self._odom_tf = tf.TransformBroadcaster()
        self._odom_tf.sendTransform((0, 0, 0),(0, 0, 0, 1),rospy.Time.now(),"base_footprint","odom")
        ## Map Handlers ##
        self._map_list = tf.TransformListener()
        ## Goal Handlers ##
        self._goal_list = tf.TransformListener()

        #### Private robot Information
        self._wheelbase = wheelbase

        ## After creation, wait 1 second in order to ensure that your
        self.sleeper = rospy.Duration(1)
        rospy.sleep(self.sleeper)

        print '\n\n'
        print "Robot Created"
        print "Robot Created"
        print "Robot Created"
        print "Robot Created"
        print '\n\n'
Esempio n. 2
0
    def __init__(self, name, wheelbase=0.352):
        """
        :param name: <string> that will be the 'name'.log file and the name of the node created
        :param wheelbase: <float> that will be the width of the robot
        :return: None
        """

        """ SETUP::
            1) Will initialize ROS node under name passed
            2) Will initialize subclass information
            3) Will initialize localization variables
            4) Will Create Publishers and Subscribers in the class
            5) Will initialize specific robot variables
        """
        # Loggers and node information
        rospy.init_node(name)

        # # Subclass Functions
        self.map = gMap(name + "Map", "/GOAL")
        self._name_ = name

        # # Localization Variables
        self.frontierX, self.frontierY = None, None
        self._x_offset = None
        self._y_offset = None
        self._x, self._y = 0, 0
        self._notDoneExploring = False

        # # Pub/Sub information
        self._drivePublisher = rospy.Publisher('/move_base_simple/goal', PoseStamped, queue_size=1)
        self._cmdVelPub = rospy.Publisher('/cmd_vel_mux/input/teleop', Twist, queue_size=1)

        self._baseResultSubscriber = rospy.Subscriber('/move_base/result', MoveBaseActionResult,self._storeMoveBaseResult, queue_size=1)
        self._mapSubscriber = rospy.Subscriber('/map',OccupancyGrid, self._updateMap, queue_size=1)

        # #### Private robot Information
        self._wheelbase = wheelbase
        self._startupSpinVel = 0.5
        self._moveError = False
        self._moving = False
        self._failedList = []
        self._recovery = 0

        # # After creation and initialization, wait a second to ensure that we don't go too fast.
        self.sleeper = rospy.Duration(1)
        rospy.sleep(self.sleeper)

        print '\n'
        print "Robot Created"
        print '\n'