Why robot doesn't move consistent with distance sensor?

Hi,

My students coded with distance sensors, basic drivetrain commands and simple if and while loops, to accomplish the competition challenge level 1 of vex vr activity “number maze”. (Number Maze - VEXcode VR - Google Docs) Something interesting is the executions are not consistent. Only 3 out of 10 executions succeeded. The drawn routes of successful execution don’t look the same. The failed executions are different as the robot just hit random walls at various locations.

I guess the reason is the distance sensor. However what is the detailed reason? And how to solve this issue to make the execution consistent?

Part of codes attached below:

def main():
32 pen.move(DOWN)
33 drivetrain.set_drive_velocity(100,PERCENT)
34 drivetrain.set_turn_velocity(100,PERCENT)
35
36 drivetrain.turn_for(RIGHT,90,DEGREES)
37 drivetrain.drive_for(FORWARD,100,MM)
38 drivetrain.turn_for(LEFT,45,DEGREES)
39 drivetrain.drive_for(FORWARD,300,MM)
40 #first turn
41 drivetrain.turn_for(RIGHT,45,DEGREES)
42 drivetrain.drive_for(FORWARD,490,MM)
43
44 drivetrain.turn_for(RIGHT,120,DEGREES)
45
46 drivetrain.drive_for(FORWARD,223,MM)
47
48
49 wait(1200,MSEC)
50
51 drivetrain.drive_for(REVERSE,223,MM)
52
53 drivetrain.turn_for(RIGHT,60,DEGREES)
54 drivetrain.drive_for(FORWARD,450,MM)
55 drivetrain.turn_for(LEFT,45,DEGREES)

56 drivetrain.drive_for(FORWARD,300,MM)
57 drivetrain.turn_for(RIGHT,45,DEGREES)
58 drivetrain.drive_for(FORWARD,100,MM)
59
60 drivetrain.turn_for(RIGHT,90,DEGREES)
61 #stop at start

I would start by actually using the distance sensor.

4 Likes

Thanks for reply. What do you mean? Could you give more details?

There is nothing in that code involving the vision sensor.

I think the OP means using distances travelled, not using the distance sensor.


Opps… Wrong screenshot earlier. Here is one including distance sensor.


And here is a screenshoot of the executation. The robot just mess up here or there. Only 3 out 10 times can succeed in running through the maze.