Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I 'm working with an ev3 robot, I have 2 functions :
Python
<pre>
def Straight(x,y):
    
    if x > 0:
        while robot.distance() <= x:
            correction = (gyro.angle()) * 3
            robot.drive(y,correction)
            
    if x < 0:
        while robot.distance() >= x:
            correction = (gyro.angle()) * 3
            robot.drive(-y,correction)




and
Python
def Phase1():

    Straight(1000,500)
    robot.turn(-360)
    robot.distance() = 0
    Straight(300,500)

When I call the Straight function for the second time "Straight(300,500)" nothing happens because robot.distance() is greater than 300

So my question is, how do I reset the value of robot.distance() ?

Thanks in advance.

What I have tried:

I tried to rewrite the Straight function.
Posted
Comments
Richard MacCutchan 8-Jan-22 11:57am    
robot.distance() = 0

That line is incorrect, you cannot assign a value to a function call.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900