-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmove_control.py
29 lines (23 loc) · 901 Bytes
/
move_control.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
#!/usr/bin/env python3
import ev3dev.ev3 as ev3
from time import sleep
def go_line(position, speed):
motor_l = ev3.LargeMotor('outB')
motor_r = ev3.LargeMotor('outC')
motor_l.reset()
motor_r.reset()
motor_l.run_to_rel_pos(position_sp=position, speed_sp=speed, stop_action="brake")
motor_r.run_to_rel_pos(position_sp=position, speed_sp=speed, stop_action="brake")
time = position/speed + 1
sleep(int(time))
return motor_l.position, motor_r.position
def rotate(position, speed):
motor_l = ev3.LargeMotor('outB')
motor_r = ev3.LargeMotor('outC')
motor_l.reset()
motor_r.reset()
motor_l.run_to_rel_pos(position_sp=position, speed_sp=speed, stop_action="hold")
motor_r.run_to_rel_pos(position_sp=-position, speed_sp=speed, stop_action="hold")
time = position/speed + 1
sleep(int(time))
return motor_l.position, motor_r.position