Hi!
I’m having issues with tasks 1 and 3.
I test them individually and the results are as required, but when I submit to the exam, they fail.
On task 1, the results are compatible with what is required, but I keep failing the test.
This also happens on task 3.
Task 3 final, after stop:
I submitted the code here, but if I’m not allowed to do it, just send me a message.
Task 1 code
from robot_control_class import RobotControl
rc=RobotControl() #Item a - Criei a instância da classe.
def get_highest_lowest ():
b=rc.get_laser_full()
i=0
n=0 #Contador do maior índice
m=0 #Contador do menor índice
high=b[1]
low=b[1]
print("Starting high", high)
print("Starting low",low)
while(i<720):
print("Index", i)
print("Actual High", high)
print("Actual Low", low)
print("Actual High index", n)
print("Actual Low index", m)
if b[i]>high and b[i]!=float("inf"):
high=b[i]
n=i
i=i+1
print("New High", high)
elif b[i]<low and b[i]<high:
low=b[i]
m=i
i=i+1
print("New Low", low)
else:
i=i+1
return [m,n]
values=get_highest_lowest()
print ("Highest value is: ", values[0])
print ("Lowest value is: ", values[1])
Task 3
from robot_control_class import RobotControl
class ExamControl:
def __init__(self):
self.rc=RobotControl()
self.rc.get_laser(0)
self.rc.get_laser(719)
def get_laser_readings(self):
self.rc=RobotControl()
le=self.rc.get_laser(719)
ld=self.rc.get_laser(0)
print("Esquerda: ",le) #Left
print("Direita, ",ld) #Right
return [le,ld] #Retorna vetor com leituras - Return a vector
def main (self):
self.rc=RobotControl()
check=self.get_laser_readings()
while (check[0] and check[1] !=float("inf")):
self.rc.move_straight()
print("Reading!")
check=self.get_laser_readings()
self.rc.stop_robot()
print("Stop!")
print("Fim!!")
mover=ExamControl()
mover.main()
Thanks for your help, and have a great 2022!
Kind regards, Gustavo Duarte