コード例 #1
0
ファイル: main.py プロジェクト: midhun-pm/CodeSample
def main():
    # Reads from the data file and runs estimate for each row
    # Then plots the trajectory
    data_array = util.read_csv(config.DATASET_ABSOLUTE_PATH)

    row = data_array[0]
    time, encoder, angular_velocity, steering_angle = np.ravel(row)
    resulting_pos_heading = []
    pose_estimator = PoseEstimator((0, 0, 0), time, encoder, angular_velocity,
                                   steering_angle)
    i = 1
    while i < len(data_array):
        row = data_array[i]
        time, encoder, angular_velocity, steering_angle = np.ravel(row)
        x, y, heading = pose_estimator.estimate(
            time=time,
            steering_angle=steering_angle,
            encoder_ticks=encoder,
            angular_velocity=angular_velocity)
        resulting_pos_heading.append([x, y, heading])
        i = i + 1
    visualizer.plot_points(
        np.asarray(resulting_pos_heading)[:, 0],
        np.asarray(resulting_pos_heading)[:, 1])
    visualizer.show()
コード例 #2
0
    def test_turn_location_position(self):
        # Human assisted test
        # Ensure that the car returns to the same location if we drive around in circles.

        import visualizer
        pose_estimator = PoseEstimator((0, 0, 0), 0, 0, 0, 0)
        d = 4
        steering_angle_radians = np.pi / d
        outer_turn_radius_meters = pose_estimator.calc_outer_turn_radius(
            steering_angle_radians)
        front_wheel_turn_circumference = 2 * np.pi * config.FRONT_WHEEL_RADIUS_METERS
        turn_circle_circumference = 2 * np.pi * outer_turn_radius_meters
        ticks_required = config.ENCODER_RESOLUTION_FRONT_WHEEL * turn_circle_circumference / front_wheel_turn_circumference
        result_loc = []
        ticks = 0
        for i in range(2 * d):
            result_loc.append(
                pose_estimator.estimate(time=i,
                                        steering_angle=steering_angle_radians,
                                        encoder_ticks=ticks,
                                        angular_velocity=0))
            ticks = ticks + ticks_required / (2 * d)
        for loc in result_loc:
            visualizer.draw_car(loc[0], loc[1], loc[2])
        visualizer.show()
コード例 #3
0
 def _btnDescribeClicked(self):
     """
     Callback for button btnDescribe Click Event
     """
     self.txtOutput.delete(0.0,tk.END)
     result=self.parent.btnDescribeClicked(self.varsVar.get())
     self.txtOutput.insert(tk.END,result)
     if result is not None:
         visualizer.show(result)
コード例 #4
0
 def _btnDisplayClicked(self):
     """
     Callback For button btnDisplay Click event
     """
     self.txtOutput.delete(0.0,tk.END)
     result=self.parent.btnDisplayClicked(self.varsVar.get())
     self.txtOutput.insert(tk.END,str(result))
     if result is not None:
         visualizer.show(result)
コード例 #5
0
import random


def get_random_array(length):
    n = list(range(length))
    random.shuffle(n)
    return n


array_size = 50

algorithms = [s.bubble_sort, s.heap_sort, s.selection_sort,
              s.insertion_sort, s.quick_sort, s.insertion_sort, s.merge_sort]

if len(sys.argv) < 2:
    print('Usage:', 'python', sys.argv[0], 'function_name', '\n')
    print('Choose from:', '\n')
    for algorithm in algorithms:
        print(algorithm.__name__)
    print('\n')
    sys.exit(0)

algorithms = list(filter(lambda a: a.__name__ == sys.argv[1], algorithms))
if (len(algorithms) == 0):
    print('Method does not exist.')
else:
    algorithm = algorithms[0]
    arr = s.Array(get_random_array(array_size))
    algorithm(arr)
    vs.show()
コード例 #6
0
ファイル: main.py プロジェクト: xeno1991/GPIOVisualizer
import visualizer
import sys
from PyQt4 import QtGui
import ui_mainwindow

if __name__ == '__main__':
    app = QtGui.QApplication(sys.argv)
    ui = ui_mainwindow.Ui_MainWindow()

    visualizer = visualizer.GPIOVisualizer(ui)
    #
    # visualizer.createGPIO(ui.gridLayoutWidget,
    #                       ui.gridLayout)
    #
    # visualizer.setButton(ui.pushButton, ui.label)
    # visualizer.setTextEdit(ui.textEdit)

    visualizer.show()

    sys.exit(app.exec_())
コード例 #7
0
import torch
import torch.optim as optim

from model import NeuralNet
from train import train, test, test_dataset
from visualizer import show

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

model = NeuralNet().to(device)
optimizer = optim.SGD(model.parameters(), lr=0.01)

if __name__ == '__main__':
    for epoch in range(1, 10 + 1):
        train(epoch, model, optimizer, device)
        test(model, device)

    show(model, test_dataset, device)