forked from LiamBindle/PyVESC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmytest.py
76 lines (53 loc) · 1.72 KB
/
mytest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/python3
# import pyvesc
import time
import agrorobot
# serial_port_1 = '/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A50285BI-if00-port0'
# serial_port_2 = '/dev/serial/by-id/usb-STMicroelectronics_ChibiOS_RT_Virtual_COM_Port_304-if00'
serial_port_1 = "/dev/ttyUSB1"
serial_port_2 = "/dev/ttyUSB2"
robot = agrorobot.Agrorobot(serial_port_1, serial_port_2)
# motor_1 = pyvesc.VESC(serial_port=serial_port_1)
# motor_2 = pyvesc.VESC(serial_port=serial_port_2)
# speed = -1.0
# print(f"Firmware: {motor_1.get_firmware_version()}")
# print(f"Firmware: {motor_2.get_firmware_version()}")
robot.move_forward(5000)
time.sleep(3)
robot.move_back(2000)
time.sleep(3)
robot.move_left_one_cat(1000)
time.sleep(3)
robot.move_right_around(2500)
# motor_1.set_current(speed)
# motor_2.set_current(speed)
# motor_1.set_servo(0)
# motor_2.set_servo(0)
# motor_1.set_rpm(-2500)
# motor_2.set_rpm(-2500)
# time.sleep(1)
# motor_1.set_rpm(1500)
# motor_2.set_rpm(1500)
# time.sleep(2)
# motor_1.set_rpm(5000)
# motor_2.set_rpm(5000)
# time.sleep(2)
# motor_1.set_rpm(-1000)
# motor_2.set_rpm(-1000)
# motor_1.set_duty_cycle(-10)
# motor_2.set_duty_cycle(-10)
time.sleep(3)
robot.stop()
# print("Measurements:")
# print(f"Incoming voltage: {motor_1.get_v_in()}")
# print(f"Incoming voltage: {motor_2.get_v_in()}")
# measurements_1 = motor_1.get_measurements()
# measurements_2 = motor_2.get_measurements()
# print(f"m.rpm: {measurements_1.rpm}")
# print(f"m.rpm: {measurements_2.rpm}")
# print(f"m.v_in: {measurements_1.v_in}")
# print(f"m.v_in: {measurements_2.v_in}")
# print(f"RPM: {motor_1.get_rpm()}")
# print(f"RPM: {motor_2.get_rpm()}")
# print(f"Baudrate: {motor_1.serial_port.baudrate}")
# print(f"Baudrate: {motor_2.serial_port.baudrate}")