예제 #1
0
def plot_log(file_path):
    """
    Read a path log file and plot it
    :param file_path: Path log file path
    """
    with open(file_path) as log:
        i = csv.reader(log)
        for line in i:
            dibrobot([float(line[0]),
                      float(line[1]),
                      float(line[2])], 'r', 'p')
    plt.show()
예제 #2
0
def loop_robot_drawer(finished, robot):
    """
    Loop that plot the robot position every 0.3 seconds
    :param finished: if finish is true, must stop updating position
    :param robot: Robot object
    """
    print("Drawer started")
    plt.ion()

    # Wait until update odometry start
    plt.pause(0.5)

    while not finished.value:
        [x, y, th] = robot.readOdometry()
        dibrobot([x, y, th], 'r', 'p')
        plt.pause(0.3)
예제 #3
0
    def plotLive(self):
        """
        Plots the robot position every self.PLOT_TIME seconds until self.finished.value == True
        """
        tEnd = time.time()
        while not self.finished.value:
            # current processor time in a floating point value, in seconds
            tIni = time.time()

            # Read odometry variables
            [x, y, th] = self.readOdometry()

            # Show plot live
            plot_robot.dibrobot([x, y, th], 'red', 'p')
            plot_robot.draw()

            tEnd = time.time()

            waitTime = self.PLOT_TIME - (tEnd - tIni)
            if waitTime > 0:
                time.sleep(waitTime)