You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tutorials/basic-movement.md
+45-45Lines changed: 45 additions & 45 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,30 +17,30 @@ from sbot import Robot
17
17
robot = Robot()
18
18
19
19
whileTrue:
20
-
r.motor_board.motors[0].power =0.5
21
-
r.motor_board.motors[1].power =0.5
22
-
r.sleep(3)
20
+
robot.motor_board.motors[0].power =0.5
21
+
robot.motor_board.motors[1].power =0.5
22
+
robot.sleep(3)
23
23
24
-
r.motor_board.motors[0].power =0
25
-
r.motor_board.motors[1].power =0
26
-
r.sleep(1.4)
24
+
robot.motor_board.motors[0].power =0
25
+
robot.motor_board.motors[1].power =0
26
+
robot.sleep(1.4)
27
27
28
-
r.motor_board.motors[0].power =-0.5
29
-
r.motor_board.motors[1].power =-0.5
30
-
r.sleep(1)
28
+
robot.motor_board.motors[0].power =-0.5
29
+
robot.motor_board.motors[1].power =-0.5
30
+
robot.sleep(1)
31
31
32
-
r.motor_board.motors[0].power =0
33
-
r.motor_board.motors[1].power =0
32
+
robot.motor_board.motors[0].power =0
33
+
robot.motor_board.motors[1].power =0
34
34
35
-
r.sleep(4)
35
+
robot.sleep(4)
36
36
```
37
37
38
-
You're familiar with the first few lines; in fact, the only lines you may not be familiar with are the `r.motor_board...` lines. For a comprehensive reference to the `motor` object, see [`motor` API](../programming/motor-board.md) page.
38
+
You're familiar with the first few lines; in fact, the only lines you may not be familiar with are the `robot.motor_board...` lines. For a comprehensive reference to the `motor` object, see [`motor` API](../programming/motor-board.md) page.
39
39
40
40
But, to summarise:
41
41
42
-
`r.motor_board.motors[0].power = 0.5` sets the target power of the motor connected to output 0 on the first [motor board](../kit/motor-board.md) to half speed forwards (i.e. a duty-cycle of 50% forwards). As you would expect, then, `-0.5` will put this motor into reverse at half power.
43
-
`r.motor_board.motors[0].power = 0` will brake the motor and stop it.
42
+
`robot.motor_board.motors[0].power = 0.5` sets the target power of the motor connected to output 0 on the first [motor board](../kit/motor-board.md) to half speed forwards (i.e. a duty-cycle of 50% forwards). As you would expect, then, `-0.5` will put this motor into reverse at half power.
43
+
`robot.motor_board.motors[0].power = 0` will brake the motor and stop it.
44
44
45
45
So, if you put the above code on your robot, you should be able to see a motor spin forwards, stop, spin backwards, stop, and then repeat...
0 commit comments