Skip to content

Commit f0bebdf

Browse files
committed
Merge branch 'update-motor-tutorial'
2 parents 10295cc + 31a1e50 commit f0bebdf

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

tutorials/basic_motor_control.md

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ The aim of this tutorial is to get a motor turning with your kit.
1010
To complete this tutorial, you'll need the following:
1111

1212
* The [power board](/docs/kit/power_board)
13-
* The battery (charged, of course)
14-
* The cable to connect the battery to the power board
13+
* A battery (charged, of course)
1514
* A [motor board](/docs/kit/motor_board)
1615
* 2 large (7.5mm) green _CamCon_ connectors to plug the power board and motor board together
1716
* 2 lengths of a suitable gauge of wire for powering the motor board from the power board (one should be black/grey)
@@ -42,9 +41,9 @@ The criteria are as follows:
4241

4342
<div class="info">
4443
When designing your robot you should bear in mind that while each motor board can deliver 10A on each output,
45-
all the power needs to go through the power board, which is fused at 15A.
46-
This means that across all the outputs for all the motors,
47-
you can only draw up to 15A at any time.
44+
all the power needs to go through the power board, which is limited to 30A overall.
45+
This means that across all the outputs for all the motors (as well as the rest of your kit),
46+
you can only draw up to 30A at any time.
4847
</div>
4948

5049
Connecting a Motor
@@ -128,7 +127,7 @@ while True:
128127
~~~~~
129128

130129
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.
131-
For a comprehensive reference to the `motor` object, see the `sr.robot3` module's [`motor`](/docs/programming/sr/motors/) page.
130+
For a comprehensive reference to the `motor` object, see the `sr.robot3` module's [Motors](/docs/programming/sr/motors/) page.
132131
But, to summarise:
133132

134133
<div class="info" markdown="1">
@@ -140,6 +139,7 @@ But, to summarise:
140139

141140
So, `R.motor_board.motors[0].power = 0.5` sets the target power of the motor connected to output 0 on the first [motor board](/docs/kit/motor_board)
142141
plugged in to a USB hub to 50% forwards (i.e. a duty-cycle of 0.5 forwards).
142+
143143
As you would expect, then, `R.motor_board.motors[0].power = -0.5` will put the this motor into reverse at 50% power.
144144
`R.motor_board.motors[0].power = 0` will output no power to the motor and stop it.
145145

@@ -214,16 +214,18 @@ while True:
214214

215215
Again, as you've seen most of that before, it shouldn't be too difficult to get your head around.
216216
The `for` loop may be new, however.
217+
217218
The [`for`](https://docs.python.org/tutorial/controlflow.html#for-statements)
218-
loop accepts a Python `list` (a `list`, when `print`ed, appears in square brackets like so: `[1, 2, 3]`).
219+
loop accepts anything that Python can iterate over to get multiple values, such as a `list` (a `list`, when `print`ed, appears in square brackets like so: `[1, 2, 3]`).
220+
219221
For a comprehensive introduction to to `list`s, have a look at [this WikiBooks article](https://en.wikibooks.org/wiki/Python_Programming/Lists).
220222
The `for` loop will iterate over the `list` (i.e. take each element in turn)
221223
and make it available in the loop's body as the variable after the the `for` keyword.
222224
Here's an example:
223225

224226
~~~~~ python
225227
for i in [1, 2, 3]:
226-
print(i)
228+
print(i)
227229
~~~~~
228230

229231
The above would output:
@@ -234,25 +236,22 @@ The above would output:
234236
3
235237
~~~~~
236238

237-
Then there's the [`range()`](https://docs.python.org/library/functions.html#range) function.
238-
The `range()` function returns a `list` with its contents dependent on the arguments passed to it.
239-
The Python documentation explains it quite nicely:
239+
Then there's the [`range()`](https://docs.python.org/3/library/stdtypes.html#typesseq-range) object.
240+
241+
`range()` objects represent a sequence of numbers. They can be constructed with
242+
one, two or three arguments to describe what the sequence of numbers should be.
240243

241-
> `range([start], stop[, step])` (note: the square brackets here mean 'optional')
242-
>
243-
> If the `step` argument is omitted, it defaults to `1`. If the `start` argument is
244-
> omitted, it defaults to `0`. The full form returns a list of plain integers
245-
> `[start, start + step, start + 2 * step, ...]`. If `step` is positive, the last
246-
> element is the largest `start + i * step` less than `stop`; if `step` is negative,
247-
> the last element is the smallest `start + i * step` greater than `stop`.
244+
If only one argument is provided then the sequence starts at `0` and stops just
245+
before the given number. Otherwise the first argument is the number to start at,
246+
the second argument is the number to stop before and the (optional) third
247+
argument is how big the steps should be (by default steps are `1`).
248248

249-
So, based on that, `range(3)` would return the list `[0, 1, 2]` because it is shorthand for `range(0, 3, 1)`.
250-
From the quote, you can see that this would return a list starting from `0`,
251-
and finishing with the integer one less than `3`, hence the `[0, 1, 2]`.
249+
So, based on this, `range(3)` would represent the sequence `0`, `1`, `2` because
250+
it is shorthand for `range(0, 3, 1)`.
252251

253252
So, taking `range(10, 80, 10)`, for example, would output `10` as the first element,
254253
then `20, 30, ...` up until `x=10+i*10` for some `i` where `i` ensures `x < stop` (which, in this case, is `80`).
255-
So, the `80` I've used could equally have been `77` or even `71` and the outputted `list` would still be `[10, 20, 30, 40, 50, 60, 70]`.
254+
So, the `80` we've used could equally have been `77` or even `71` and the outputted sequence would still be `10`, `20`, `30`, `40`, `50`, `60`, `70`.
256255

257256
Putting all of that together should mean you understand the above code.
258257
You might want to run the code on your kit to see if it does what you expect it to.

0 commit comments

Comments
 (0)