forked from iitbmartian/hw_training
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautonomous.py
58 lines (43 loc) · 1.74 KB
/
autonomous.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
#!/usr/bin/env python
from roboclaw import RoboClaw
import rospy
#----------------------------------------------------
class Drive:
def __init__(self,driver1,driver2):
self.rightClaw = driver1
self.leftClaw = driver2
def drive_callback(self,inp):
# A bit of help! These are arrays of data
axes = inp.axes
buttons = inp.buttons
'''Trying to edit in github vs'''
"""TODO - INSERT YOUR CODE HERE
Problem Statement: Insert Code here to make the rover move
forwards, Backwards, left, right according to input given
"""
if (axes[1] >= 0.1):
driver1.ForwardM1(axes[1]*100/0.9)
driver1.ForwardM2(axes[1]*100/0.9)
driver2.ForwardM1(axes[1]*100/0.9)
driver2.ForwardM2(axes[1]*100/0.9)
elif (axes[1] <= -0.1):
driver1.BackwardM1(axes[1]*100/0.9)
driver1.BackwardM2(axes[1]*100/0.9)
driver2.BackwardM1(axes[1]*100/0.9)
driver2.BackwardM2(axes[1]*100/0.9)
elif (axes[0] <= -0.1):
driver1.TurnRightMixed(axes[0]*100/0.9)
driver2.TurnRightMixed(axes[0]*100/0.9)
elif (axes[0] >= 0.1):
driver1.TurnLeftMixed(axes[0]*100/0.9)
driver2.TurnLeftMixed(axes[0]*100/0.9)
def current_limiter(self):
"""BONUS:
Try to implement this function as well. It is a saftey feature.
How would you decide the current threshold? - Please elaborate
"""
if (driver1.GETCURRENTS < 400) && (driver2.GETCURRENTS < 400):
return False
else:
return True
#---------------------------------------------------