コード例 #1
0
ファイル: unit_tests.py プロジェクト: pachterlab/pegasus
def test_run_silent():
    port = populate_ports()[-2]
    s = connect(port)

    time.sleep(5)  # wait for the arduino to initialize

    talk(s, setup_cmds)

    time.sleep(1)

    talk(s, [run_short_cmds[0]])
    time.sleep(1.5)
    talk(s, [run_short_cmds[1]])
    time.sleep(1.5)
    talk(s, [run_short_cmds[0]])
    time.sleep(1.5)
    talk(s, [run_short_cmds[1]])
    time.sleep(1.5)
    talk(s, [run_short_cmds[0]])
    time.sleep(1.5)
    talk(s, [run_short_cmds[1]])

    time.sleep(2)

    s.close()

    return
コード例 #2
0
ファイル: unit_tests.py プロジェクト: pachterlab/pegasus
def test_run():
    port = populate_ports()[-2]
    print("\n[setup] Connecting to port: {}".format(port))
    s = connect(port)

    time.sleep(5)  # wait for the arduino to initialize
    print(listen(s))

    print("\n[setup] Sending setup commands..")
    talk(s, setup_cmds)

    time.sleep(1)

    print("\n[action] Sending run commands..")
    # talk(s, run_cmds)
    talk(s, [run_short_cmds[0]])
    time.sleep(1.5)
    talk(s, [run_short_cmds[1]])

    time.sleep(2)

    print("\n[action] Closing port..")
    s.close()

    return
コード例 #3
0
ファイル: unit_tests.py プロジェクト: pachterlab/pegasus
def test_pause_resume():
    port = populate_ports()[-1]
    print("\n[setup] Connecting to port: {}".format(port))
    s = connect(port)

    time.sleep(5)  # wait for the arduino to initialize
    print(listen(s))

    print("\n[setup] Sending setup commands..")
    talk(s, setup_cmds)

    time.sleep(1)

    print("\n[action] Sending run commands..")
    talk(s, run_cmds)

    time.sleep(1)

    print("\n[action] Sending pause commands..")
    talk(s, pause_cmds)

    time.sleep(1)

    print("\n[action] Sending resume commands..")
    talk(s, resume_cmds)

    print("\n[action] Closing port..")
    s.close()

    return
コード例 #4
0
	def populate_ports(self):
		self.ui.motor_port_COMBO_BOX.clear()
		self.ui.encoder_port_COMBO_BOX.clear()

		ports = populate_ports()
		self.ui.motor_port_COMBO_BOX.addItems(ports)
		self.ui.encoder_port_COMBO_BOX.addItems(ports)
		self.ui.motor_port_COMBO_BOX.setCurrentIndex(0)
		self.ui.encoder_port_COMBO_BOX.setCurrentIndex(0)

		self.motor_port = ports[0]
		self.encoder_port = ports[0]
コード例 #5
0
def test_stream():
	print(populate_ports())
	port = populate_ports()[1]
	print("\n[setup] Connecting to port: {}".format(port))
	s = connect(port)

	time.sleep(5) # wait for the arduino to initialize
	print(listen(s))


	plt.ion() ## Note this correction
	fig=plt.figure()
	t = []
	x = []
	v = []

	while True:
		while s.inWaiting() == 0:
			pass


		data = listen(s).split(",")
		data = [float(i) for i in data]
		t_tmp, x_tmp, v_tmp = data
		print("{}\t{}\t{}".format(t_tmp, x_tmp, v_tmp))
		t.append(t_tmp)
		x.append(x_tmp)
		v.append(v_tmp)

		plt.scatter(t_tmp, x_tmp)
		plt.pause(0.0001)


    	#print(t_tmp, "\t", x_tmp, "\t", v_tmp)
	#plt.show()
	s.close()
コード例 #6
0
ファイル: unit_tests.py プロジェクト: pachterlab/pegasus
def test_valid_cmd():
    port = populate_ports()[-1]
    print("\n[setup] Connecting to port: {}".format(port))
    s = connect(port)

    time.sleep(5)  # wait for the arduino to initialize
    print(listen(s))

    print("\n[setup] Sending setup commands..")
    talk(s, setup_cmds)

    time.sleep(1)

    print("\n[action] Sending invalid run commands.. nothing should happen..")
    talk(s, invalid_cmds)

    print("\n[action] Closing port..")
    s.close()

    return
コード例 #7
0
ファイル: unit_tests.py プロジェクト: pachterlab/pegasus
def test_profile_1():
    port = populate_ports()[-1]
    print("\n[setup] Connecting to port: {}".format(port))
    s = connect(port)

    time.sleep(5)
    print(listen(s))

    print("\n[setup] Sending setup commands..")
    talk(s, setup_cmds)

    time.sleep(1)

    print("\n[action] Sending first profile.. speed = 0")
    talk(s, ["<SET_SPEED,100,0,0,0>"])
    talk(s, ["<RUN,100,5000,0,0>"])
    time.sleep(2)
    print("\n[action] Sending first profile.. speed = 400")
    # talk(s, ["<STOP,100,0,0,0>"])
    talk(s, ["<SET_SPEED,100,400,0,0>"])
    talk(s, ["<RUN,100,5000,0,0>"])
    time.sleep(2)
    print("\n[action] Sending first profile.. speed = 200")
    # talk(s, ["<STOP,100,0,0,0>"])
    talk(s, ["<SET_SPEED,100,200,0,0>"])
    talk(s, ["<RUN,100,5000,0,0>"])
    time.sleep(2)
    print("\n[action] Sending first profile.. speed = 800")
    # talk(s, ["<STOP,100,0,0,0>"])
    talk(s, ["<SET_SPEED,100,800,0,0>"])
    talk(s, ["<RUN,100,5000,0,0>"])
    time.sleep(2)
    print("\n[action] Stopping..")
    talk(s, ["<STOP,100,0,0,0>"])

    print("\n[action] Closing port..")
    s.close()