from robot_control_class import RobotControl
class robot(RobotControl):
def __init__(self):
RobotControl.__init__(self)
def forward(self):
laser_forward = self.get_laser(306)
while laser_forward > 1 :
self.move_straight()
laser_forward = self.get_laser(306)
self.stop_robot()
def right_or_left(self):
ls_full = self.get_laser_full()
ls_right = ls_full[0:360]
ls_left = ls_full[360:719]
#index_left = ls_left.index(max(ls_left))
#print("right:",index_right)
#print("left:",index_left)
if(max(ls_right) > max(ls_left)):
index_right = ls_right.index(max(ls_right))
print("right:",index_right)
degree_right = index_right / 4
self.rotate(-1 * (90 - degree_right)-19)
else:
index_left = ls_left.index(max(ls_left))
print("left",index_left)
degree_left = index_left / 4
self.rotate((90 - degree_left)+19)
rc = robot()
rc.forward()
rc.right_or_left()
Hello @moha.lola90,
Why is not working? Are you getting any error? What is the expected behavior? From a first look at the pasted code, I can tell that the constructor (init) of the class is wrong, so that might be giving problems.
Best,