Task2.py my code show no error and follow the instruction but the gradebot telling me wrong [2 weeks issue]

**I adjust the speed by using this **

  1. I open the robot_control_class.py file where the RobotControl class is defined.
  2. Find the move_straight function definition inside the RobotControl class. It should look like this:
def move_straight(self):
    # code to move the robot straight
  1. Modify the function definition to accept a speed parameter, like this:
def move_straight(self, speed=1):
    # code to move the robot straight

I back to my code I add the parameter in this line :

Here my Full Code After Edit

from robot_control_class import RobotControl
import time

current_time = time.time()

# Create an instance of the RobotControl class
robotcontrol = RobotControl()


# initially get a laser scan
a = robotcontrol.get_laser(360)
# use a conditional while loop
while (a >= 1.0):

    # move robot slowly
    robotcontrol.move_straight(speed=0.1)
    print("Current distance to wall: %f" % a)
    # wait delay for 0.5 seconds to move straight
    time.sleep(0.2)
    # update laser scan reading for while loop
    a = robotcontrol.get_laser(360)

# once while loop exits, stop the robot
robotcontrol.stop_robot()

# Turn the robot 90 degrees to the right
robotcontrol.turn(90, -1, 1.8)
time.sleep(5)
print("measurement after turn 90: %f" % a)

# Concatenate a string and an integer
clockwise = "clockwise"
t = 5
print("Turned robot {} for {} seconds".format(clockwise, t))

Video Second Test :

Thank you Girish you always helpful i will try to work and edit my code to fullfill this steps

i add more measurement to check the stop

Current distance after Stop: 0.835756
measurement after turn 90 should be inf …
testing …
measurement after turn 90: 0.835756

Notice the measurement after turn 90 is the same measurement when the stop at the wall
even I add time delay for the print statement around 5 second

i add update the measurement now the code show diffrenet readings …
great success
now adjustment
to get inf reading result

Hi @nass2usa ,

Yes, it will be the same, because you have not updated the a variable after the while loop finished.
Update a again after doing the 90 degree turn to measure frontal range of the robot! The variable is not going to update itself, unless you update it!

Regards,
Girish

Here the update version :

from robot_control_class import RobotControl
import time

current_time = time.time()

# Create an instance of the RobotControl class
robotcontrol = RobotControl()


# initially get a laser scan
a = robotcontrol.get_laser(360)
# use a conditional while loop
while (a >= 1.1):  # change here: stop just less than 1m in front of the wall

    # move robot
    robotcontrol.move_straight()
    print("Current distance to wall: %f" % a)
    # wait delay for 1.0 seconds to move straight
    time.sleep(0.1)
    # update laser scan reading for while loop
    a = robotcontrol.get_laser(360)

# once while loop exits, stop the robot
robotcontrol.stop_robot()

# Update measurement after the robot stops
a = robotcontrol.get_laser(360)
print("Current distance after Stop: %f" % a)

# Turn the robot 90 degrees to the right
robotcontrol.turn(90, -1, 1.8)
time.sleep(5)
print("measurement after turn 90 should be inf ..")
print("testing .....")

# Update measurement after the robot turns
a = robotcontrol.get_laser(360)
print("measurement after turn 90: %f" % a)

# Concatenate a string and an integer
clockwise = "clockwise"
t = 5
print("Turned robot {} for {} seconds".format(clockwise, t))

Sample:
facing an issue : I must now get inf reading but now giving me 5.1 m

Update :

I got inf reading after turn 90
i adjust the turn speed

Update
Even the code works well
the Gradebot showing me error :

Hi @nass2usa ,

You seem to have 2 problems:

  1. Front laser not correct :
    seems that when gradebot checks your robot, your robot does not read “inf”.
  2. Left laser not correct :
    gradebot is expecting 0.5 < value < 1.0. Close to 1.0, but strictly < 1.0.

Fix these two issues and you should be fine. I believe you have infinite attempts in that course!

Regards,
Girish

Dear Girish

I did what exactly you said
Please See the Terminal in The Video

My Output

Current distance to wall: 3.417782
Current distance to wall: 2.875315
Current distance to wall: 2.339479
Current distance to wall: 1.789348
Current distance to wall: 1.269653
Current distance after Stop: 0.674259
measurement after turn 90 should be inf ..
testing .....
front laser value after turn 90: inf
Left Laser Value after turn 90:  0.654951
Turned robot clockwise for 5 seconds

Distance before wall 0.632359
Reading Front Laser after turn 90 right inf
Reading Left Laser after turn 90 right 0.657384

Hi @nass2usa ,

I just saw your video, the robot actually takes around 2 seconds to turn 90 degrees, not 5 seconds.
Anyways, that is not a problem now. It has turned 90 degrees and measures “inf”.
Left laser scan value also seems fine to me.

I am not sure how to help you with this. Maybe someone from TheConstruct team can help you!

Regards,
Girish

So my work is fine @girishkumar.kannan ?
happy and sad in same time hahaha

Hi @nass2usa ,

It looks fine to me. I finished this course over 3 months back - not too long, fairly recent - but I do remember doing the same thing and I got everything right.

I guess at this point, only TheConstruct team can help you out with this.
This task is a very simple task and if anything is wrong then there might be an issue with the Autograder (I believe so, I am not sure!).

Regards,
Girish

PS: Please don’t bold your sentences! Also avoid salutations like “dear”. You can just tag my name.

Hello @nass2usa ,

I was testing your files to figure out why it’s failing, but I’m getting the following error when running task 2.py script:

Are you not getting this error?

Hi @albertoezquerro ,

@nass2usa has already pointed out this error to me. It seems that the issue is coming from the provided robot_control_class.py which the student is supposed to just copy and paste.

I had already instructed him to fix it and I also think that he did. But the autograder seems to be failing.

I also vaguely remember that robotcontrol.turn() function did not take all the three arguments as a number. It was more like robotcontrol.turn(string, float, float) where the string was direction “clockwise” or “counterclockwise” and other two numbers were angular speed and degrees to rotate.

– Girish

Hello @girishkumar.kannan ,

And how did you solve that issue? I’m asking because the error comes from a system file. In any case, I’ve already fixed that file in our system so now it works correctly. Also, I’ve updated the notebook to remove the Python class from there, since it’s not required to copy it.

UPDATE: After doing this modification from our side, Task 2 passes correctly. Now it’s failing in Task 3, but because the code is wrong.

1 Like

Hi @albertoezquerro ,

I instructed him to change the str(time) to str(t) in the robot_control_class.py. He told me that import time line was already on the top of the code, so time variable cannot be used. Therefore, I guess he changed all variables that was time to t in the robot_control_class.py, that came after the import time line.

Now this is something @nass2usa must work on.

– Girish

1 Like

Thanks for The Support

regarding the error you face i posted a thread for the issue with a fix

about task 3 i didn’t focus on it until task2 is passed correctly

i appreaciate the help Construct Team