Skip to content

Commit a265eb2

Browse files
committed
Remove single-letter variables
1 parent 5baee80 commit a265eb2

File tree

10 files changed

+106
-102
lines changed

10 files changed

+106
-102
lines changed

docs/programming/arduino.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The Arduino can be accessed using the `arduino` property of the `Robot`
1313
object.
1414

1515
``` python
16-
my_arduino = r.arduino
16+
my_arduino = robot.arduino
1717
```
1818

1919
You can use the GPIO *(General Purpose Input/Output)* pins for anything,
@@ -43,7 +43,7 @@ performing an action with that pin. You can read about the possible pin
4343
modes below.
4444

4545
``` python
46-
r.arduino.pins[3].mode = GPIOPinMode.DIGITAL_INPUT_PULLUP
46+
robot.arduino.pins[3].mode = GPIOPinMode.DIGITAL_INPUT_PULLUP
4747
```
4848

4949
### `GPIOPinMode.DIGITAL_INPUT`
@@ -52,9 +52,9 @@ In this mode, the digital state of the pin (whether it is high or low)
5252
can be read.
5353

5454
``` python
55-
r.arduino.pins[4].mode = GPIOPinMode.DIGITAL_INPUT
55+
robot.arduino.pins[4].mode = GPIOPinMode.DIGITAL_INPUT
5656

57-
pin_value = r.arduino.pins[4].digital_state
57+
pin_value = robot.arduino.pins[4].digital_state
5858
```
5959

6060
### `GPIOPinMode.DIGITAL_INPUT_PULLUP`
@@ -64,21 +64,21 @@ resistor](https://learn.sparkfun.com/tutorials/pull-up-resistors)
6464
enabled.
6565

6666
``` python
67-
r.arduino.pins[4].mode = GPIOPinMode.DIGITAL_INPUT_PULLUP
67+
robot.arduino.pins[4].mode = GPIOPinMode.DIGITAL_INPUT_PULLUP
6868

69-
pin_value = r.arduino.pins[4].digital_state
69+
pin_value = robot.arduino.pins[4].digital_state
7070
```
7171

7272
### `GPIOPinMode.DIGITAL_OUTPUT`
7373

7474
In this mode, we can set binary values of `0V` or `5V` to the pin.
7575

7676
``` python
77-
r.arduino.pins[4].mode = GPIOPinMode.DIGITAL_OUTPUT
78-
r.arduino.pins[6].mode = GPIOPinMode.DIGITAL_OUTPUT
77+
robot.arduino.pins[4].mode = GPIOPinMode.DIGITAL_OUTPUT
78+
robot.arduino.pins[6].mode = GPIOPinMode.DIGITAL_OUTPUT
7979

80-
r.arduino.pins[4].digital_state = True
81-
r.arduino.pins[6].digital_state = False
80+
robot.arduino.pins[4].digital_state = True
81+
robot.arduino.pins[6].digital_state = False
8282
```
8383

8484
### `GPIOPinMode.ANALOGUE_INPUT`
@@ -96,9 +96,9 @@ cannot be used.
9696
``` python
9797
from sbot import AnaloguePin
9898

99-
r.arduino.pins[AnaloguePin.A0].mode = GPIOPinMode.ANALOGUE_INPUT
99+
robot.arduino.pins[AnaloguePin.A0].mode = GPIOPinMode.ANALOGUE_INPUT
100100

101-
pin_value = r.arduino.pins[AnaloguePin.A0].analogue_value
101+
pin_value = robot.arduino.pins[AnaloguePin.A0].analogue_value
102102
```
103103

104104
!!! tip
@@ -112,7 +112,7 @@ You can also measure distance using an ultrasound sensor from the arduino.
112112
# Trigger pin: 4
113113
# Echo pin: 5
114114

115-
distance_metres = r.arduino.ultrasound_measure(4, 5)
115+
distance_metres = robot.arduino.ultrasound_measure(4, 5)
116116
```
117117

118118
!!! warning

docs/programming/game-state.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Your robot can be in 1 of 2 modes: `DEVELOPMENT` and `COMPETITION`. By
1515
default, your robot will be in `DEVELOPMENT` mode:
1616

1717
``` python
18-
r.is_competition
18+
robot.is_competition
1919
>> False
2020
```
2121

@@ -29,9 +29,9 @@ zone. The number of zones depends on the game. Each zone is given a
2929
number, which you can access with the `zone` property:
3030

3131
``` python
32-
r.zone
32+
robot.zone
3333
>> 1
3434
```
3535

3636
During a competition match, a USB drive will be used to tell your robot
37-
which corner it's in. By default during development, this is `0`.
37+
which corner it's in. By default during development, this is `0`.

docs/programming/index.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@ kit:
1414
``` python
1515
from sbot import *
1616

17-
r = Robot()
17+
robot = Robot()
1818
```
1919

2020
Once this has been done, this `Robot` object can be used to control the
2121
robot's functions.
2222

2323
The remainder of the tutorials pages will assume your `Robot` object is
24-
defined as `r`.
24+
defined as `robot`.
25+
26+
!!! note
27+
In Python, variables are case-sensitive. `robot` is an instance of `Robot`.
2528

2629
## Running your code
2730

@@ -47,11 +50,11 @@ what it didn't do, and any errors it raised. The file is saved to log.txt in the
4750
If you want to do things before the start button press, such as setting up servos or motors, you can pass `wait_start` to the `Robot` constructor. You will then need to wait for the start button manually.
4851

4952
```python
50-
r = Robot(wait_start=False)
53+
robot = Robot(wait_start=False)
5154

5255
# Do your setup here
5356

54-
r.wait_start()
57+
robot.wait_start()
5558
```
5659

5760
## Debug mode
@@ -62,7 +65,8 @@ In "Debug Mode", your robot will print more information about what it is doing.
6265

6366
```python
6467
from sbot import Robot
65-
r = Robot(debug=True)
68+
69+
robot = Robot(debug=True)
6670
```
6771

6872
!!! info

docs/programming/motor-board.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ If there is exactly one motor board attached to your robot, it can be
99
accessed using the `motor_board` property of the `Robot` object.
1010

1111
``` python
12-
my_motor_board = r.motor_board
12+
my_motor_board = robot.motor_board
1313
```
1414

1515
!!! warning
16-
If there is more than one motor board on your kit, you *must* use the `motor_boards` property. `r.motor_board` *will cause an error*. This is because the kit doesn't know which motor board you want to access.
16+
If there is more than one motor board on your kit, you *must* use the `motor_boards` property. `robot.motor_board` *will cause an error*. This is because the kit doesn't know which motor board you want to access.
1717

1818
Motor boards attached to your robot can be accessed under the
1919
`motor_boards` property of the `Robot`. The boards are indexed by their
2020
serial number, which is written on the board.
2121

2222
``` python
23-
my_motor_board = r.motor_boards["SRO-AAD-GBH"]
24-
my_other_motor_board = r.motor_boards["SR08U6"]
23+
my_motor_board = robot.motor_boards["SRO-AAD-GBH"]
24+
my_other_motor_board = robot.motor_boards["SR08U6"]
2525
```
2626

2727
## Controlling the Motor Board

docs/programming/power-board.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The power board can be accessed using the `power_board` property of
44
the `Robot` object.
55

66
```python
7-
my_power_board = r.power_board
7+
my_power_board = robot.power_board
88
```
99

1010
## Power outputs
@@ -21,8 +21,8 @@ The power board's six outputs can be turned on and off using the
2121
pressed.
2222

2323
```python
24-
r.power_board.outputs.power_off()
25-
r.power_board.outputs.power_on()
24+
robot.power_board.outputs.power_off()
25+
robot.power_board.outputs.power_on()
2626
```
2727

2828
You can also get information about and control each output in the group.
@@ -31,12 +31,12 @@ An output is indexed using the appropriate `PowerOutputPosition`.
3131
```python
3232
from sbot import PowerOutputPosition
3333

34-
r.power_board.outputs[PowerOutputPosition.H0].is_enabled = True
35-
r.power_board.outputs[PowerOutputPosition.L3].is_enabled = False
34+
robot.power_board.outputs[PowerOutputPosition.H0].is_enabled = True
35+
robot.power_board.outputs[PowerOutputPosition.L3].is_enabled = False
3636

37-
boolean_value = r.power_board.outputs[PowerOutputPosition.L2].is_enabled
37+
boolean_value = robot.power_board.outputs[PowerOutputPosition.L2].is_enabled
3838

39-
current_amps = r.power_board.outputs[PowerOutputPosition.H1].current
39+
current_amps = robot.power_board.outputs[PowerOutputPosition.H1].current
4040
```
4141

4242
!!! warning
@@ -51,8 +51,8 @@ The power board has some sensors that can monitor the status of your battery.
5151
This can be useful for checking the charge status of your battery.
5252

5353
```python
54-
battery_voltage = r.power_board.battery_sensor.voltage
55-
battery_current_amps = r.power_board.battery_sensor.current
54+
battery_voltage = robot.power_board.battery_sensor.voltage
55+
battery_current_amps = robot.power_board.battery_sensor.current
5656
```
5757

5858
## Buzzing 🐝
@@ -80,10 +80,10 @@ The `Note` enum provides notes in [scientific pitch notation](https://en.wikiped
8080
from sbot import Note
8181

8282
# Buzz for half a second in D6.
83-
r.power_board.piezo.buzz(0.5, Note.D6)
83+
robot.power_board.piezo.buzz(0.5, Note.D6)
8484

8585
# Buzz for 2 seconds at 400Hz
86-
r.power_board.piezo.buzz(2, 400)
86+
robot.power_board.piezo.buzz(2, 400)
8787
```
8888

8989
## Start Button
@@ -92,7 +92,7 @@ You can manually wait for the start button to be pressed, not only at
9292
the start.
9393

9494
```python
95-
r.wait_start()
95+
robot.wait_start()
9696
```
9797

9898
This may be useful for debugging, but be sure to remove it in the

docs/programming/servo-board.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The servo board can be accessed using the `servo_board` property of
99
the `Robot` object.
1010

1111
```python
12-
my_servo_board = r.servo_board
12+
my_servo_board = robot.servo_board
1313
```
1414

1515
This board object has an array containing the servos connected to it,
@@ -25,16 +25,16 @@ The position of servos can range from `-1` to `1` inclusive:
2525

2626
```python
2727
# set servo 1's position to 0.2
28-
r.servo_board.servos[1].position = 0.2
28+
robot.servo_board.servos[1].position = 0.2
2929

3030
# Set servo 2's position to -0.55
31-
r.servo_board.servos[2].position = -0.55
31+
robot.servo_board.servos[2].position = -0.55
3232
```
3333

3434
You can read the last value a servo was set to using similar code:
3535

3636
```python
37-
last_position = r.servo_board.servos[11].position
37+
last_position = robot.servo_board.servos[11].position
3838
```
3939

4040
!!! warning

docs/programming/vision/index.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ the marker relative to the webcam. Using this data, it is possible to determine
1111

1212
## Searching for markers
1313

14-
Assuming you have a webcam connected, you can use `r.camera.see()` to take a picture. The software will process the picture
14+
Assuming you have a webcam connected, you can use `robot.camera.see()` to take a picture. The software will process the picture
1515
and returns a list of the markers it sees.
1616

1717
```python
18-
markers = r.camera.see()
18+
markers = robot.camera.see()
1919
```
2020

2121
!!! tip
@@ -30,7 +30,7 @@ corner of the marker. The ID of every marker is also written next to it.
3030
Snapshots are saved to your USB drive, and can be viewed on another computer.
3131

3232
```python
33-
r.camera.save("snapshot.jpg")
33+
robot.camera.save("snapshot.jpg")
3434
```
3535

3636
![An annotated arena with Fiducial Markers.](../../assets/img/api/vision/arena_marker_annotated.jpg){ width="50%" }
@@ -44,7 +44,7 @@ The marker objects in the list expose data that may be useful to your robot.
4444
Every marker has a numeric identifier that can be used to determine what object it represents.
4545

4646
```python
47-
markers = r.camera.see()
47+
markers = robot.camera.see()
4848

4949
for m in markers:
5050
print(m.id)
@@ -57,7 +57,7 @@ Each marker has a position in 3D space, relative to your webcam.
5757
You can access the position using `m.distance`, `m.cartesian` and `m.spherical`.
5858

5959
```python
60-
markers = r.camera.see()
60+
markers = robot.camera.see()
6161

6262
for m in markers:
6363
print(m.distance) # Distance to the marker from the webcam, in metres
@@ -82,7 +82,7 @@ You can access the size of a marker using `m.size`.
8282
Check the rules to find out how big the different marker types are.
8383

8484
```python
85-
markers = r.camera.see()
85+
markers = robot.camera.see()
8686

8787
for m in markers:
8888
print(m.size)
@@ -98,7 +98,7 @@ marker. Pixels are counted from the origin of the image, which
9898
conventionally is in the top left corner of the image.
9999

100100
```python
101-
markers = r.camera.see()
101+
markers = robot.camera.see()
102102

103103
for m in markers:
104104
print(m.pixel_corners) # Pixel positions of the marker corners within the image.

docs/programming/vision/orientation.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ Orientation represents the rotation of a marker around the x, y, and z axes. The
1111
Rotations are applied in order of z, y, x.
1212

1313
```python
14-
markers = r.camera.see()
14+
markers = robot.camera.see()
1515

16-
for m in markers:
17-
print(m.orientation.rot_x) # Angle of rotation about x axis.
18-
print(m.orientation.rot_y) # Angle of rotation about y axis.
19-
print(m.orientation.rot_z) # Angle of rotation about z axis.
16+
for marker in markers:
17+
print(marker.orientation.rot_x) # Angle of rotation about x axis.
18+
print(marker.orientation.rot_y) # Angle of rotation about y axis.
19+
print(marker.orientation.rot_z) # Angle of rotation about z axis.
2020
```
2121

2222
!!! note

docs/programming/vision/position.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ The value of each coordinate indicates the distance travelled along the axis to
1919
The camera is located at the origin, where the coordinates are ``(0, 0, 0)``.
2020

2121
```python
22-
markers = r.camera.see()
22+
markers = robot.camera.see()
2323

2424
for m in markers:
2525
print(m.cartesian.x) # Displacement from the origin in millimetres, along x axis.
@@ -44,7 +44,7 @@ three values to specify a specific point in space.
4444
The camera is located at the origin, where the coordinates are `(0, 0, 0)`.
4545

4646
```python
47-
markers = r.camera.see()
47+
markers = robot.camera.see()
4848

4949
for m in markers:
5050
print(m.spherical.distance) # Distance from the origin in millimetres

0 commit comments

Comments
 (0)