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: examples/basics/README.md
+13-8Lines changed: 13 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -94,7 +94,7 @@ The `camera.subscribe` function allows you to subscribe to video frames incoming
94
94
firing the `onFrame` function 30 times a second with [numpy](https://en.wikipedia.org/wiki/NumPy) arrays containing BGR images captured by the camera.
95
95
The `put_nowait` function is then used to send the frame to the window where the image is displayed.
96
96
97
-
These two functions form the core of RTCBot's abilities. Every producer of data (like `CVCamera`) has a `subscribe()` method, and every consumer of data (like `CVDisplay`) has a `put_nowait` method to insert data.
97
+
These two functions are part of RTCBot's core abilities. Every producer of data (like `CVCamera`) has a `subscribe()` method, and every consumer of data (like `CVDisplay`) has a `put_nowait` method to insert data.
98
98
99
99
```eval_rst
100
100
.. note::
@@ -108,19 +108,25 @@ These two functions form the core of RTCBot's abilities. Every producer of data
108
108
109
109
## Subscriptions
110
110
111
-
In RTCBot, a subscription is any object with a `put_nowait` method, and a `get` coroutine:
111
+
Using a callback function with the `subscribe` method is not the only way to
112
+
get data out of a data-producing object. The `subscribe` method is also able
113
+
to create what is called a `subscription`.
114
+
115
+
To understand subscriptions, let's take a quick detour to python Queues:
112
116
113
117
```python
114
118
import asyncio
115
119
116
-
# An asyncio Queue is a subscription
120
+
# An asyncio Queue has put_nowait and get coroutine
Here, the `sender` function sends data, and the `receiver` awaits for incoming data, and prints it.
140
+
Here, the `sender` function sends data, and the `receiver` awaits for incoming data, and prints it. Notice how the queue had a `get` coroutine from which data could be awaited.
135
141
136
-
In the example where we viewed a video feed, `subscribe` was used as a decorator for a callback function.
137
-
This is just a small part of the actual power of the `subscribe` method. When run without an argument, it actually returns a subscription, which `CVCamera` automatically keeps updated with new video frames as they come in:
142
+
We can use the `subscribe` method in a similar way to the above code snippet. When run without an argument, `subscribe` actually returns a subscription, which `CVCamera` automatically keeps updated with new video frames as they come in:
138
143
139
144
```python
140
145
import asyncio
@@ -200,7 +205,7 @@ finally:
200
205
201
206
## Generalizing to Audio
202
207
203
-
The above code examples created a video stream, and displayed it in a window. RTCBot uses _exactly the same_ API for **everything**. This means that we can trivially add audio to the previous example:
208
+
The above code examples all created a video stream, and displayed it in a window. RTCBot uses _exactly the same_ API for **everything**. This means that we can trivially add audio to the previous example:
204
209
205
210
```python
206
211
import asyncio
@@ -223,7 +228,7 @@ finally:
223
228
speaker.close()
224
229
```
225
230
226
-
With this example, a video stream should be displayed in a window, and all microphone input should be playing in your headphones (or speakers).
231
+
Here, a video stream should be displayed in a window, and all microphone input should be playing in your headphones (or speakers).
The output for the `Gamepad` object is currently different in Javascript and in Python. Make sure you don't mix them up!
132
132
```
133
133
134
-
## Machine Learning a Controller
135
-
136
-
This portion of the tutorial focuses on modifying the desktop code from the previous portion to include
137
-
a neural network which is trained exploiting the computational power available on a desktop PC.
138
-
139
-
This is an _advanced_ topic, requiring a working knowledge of machine learning basics. It is also assumed
140
-
that you are using linux on your desktop, and that you have an nvidia graphics card compatible with [pytorch](https://pytorch.org). If you choose to attempt this part on a windows desktop or on a mac, be aware that you might run into some problems that might require some googling skills to solve.
The controller's buttons give boolean values, and the joysticks give float values between -1 and 1. By default, the controller is polled at 10Hz as not to overwhelm an embedded computer like the Pi with tons of data each time a joystick is moved.
217
+
The controller's buttons give boolean values, and the joysticks give float values between -1 and 1. By default, the controller is polled at 10Hz as not to overwhelm a Pi 3 with tons of data each time a joystick is moved.
0 commit comments