Skip to content

Commit 4c4a9fc

Browse files
committed
Updated dev install instructions
Made the javascript build step clear.
1 parent a92f648 commit 4c4a9fc

File tree

10 files changed

+179
-235
lines changed

10 files changed

+179
-235
lines changed

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
# Empty rule for forcing rebuilds
44
phony:
55

6+
js/node_modules:
7+
cd js; npm i
68

7-
js: phony
9+
js: phony js/node_modules
810
cd js; npm run build
911
cp js/dist/rtcbot.umd.js rtcbot/rtcbot.js
1012

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ The library is explained piece by piece in [the documentation](https://rtcbot.re
2020

2121
### [See Documentation & Tutorials](https://rtcbot.readthedocs.io/en/latest/index.html)
2222

23+
## Installing
24+
25+
```
26+
pip install rtcbot
27+
```
28+
2329
## Example
2430

2531
This example uses RTCBot to live stream a webcam to the browser. For details, please look at [the tutorials](https://rtcbot.readthedocs.io/en/latest/examples/index.html).
@@ -103,3 +109,21 @@ Browser code (index.html) that displays the video stream:
103109
</body>
104110
</html>
105111
```
112+
113+
## Development
114+
115+
To use `rtcbot` code directly, clone the repository, and install the requirements:
116+
117+
```
118+
pip install -r requirements.txt
119+
```
120+
121+
Then, you will need to perform the javascript build step, to prepare the browser code. This step requires both `make` and `npm` to be installed on your machine. To build the javascript, type in:
122+
123+
```
124+
make js
125+
```
126+
127+
This creates `rtcbot/rtcbot.js`, which is returned by `rtcbot.getRTCBotJS()`.
128+
129+
After these two steps, you should be able to successfully import and use the library.

docs/inputs.rst

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,17 @@ This code gives the following results:
4141
4242
{'timestamp': 1552629001.833567, 'code': 'REL_X', 'state': 1, 'event': 'Relative'}
4343
{'timestamp': 1552629001.833567, 'code': 'REL_Y', 'state': 1, 'event': 'Relative'}
44-
{'timestamp': 1552629001.833567, 'code': 'SYN_REPORT', 'state': 0, 'event': 'Sync'}
4544
{'timestamp': 1552629001.841518, 'code': 'REL_X', 'state': 2, 'event': 'Relative'}
46-
{'timestamp': 1552629001.841518, 'code': 'SYN_REPORT', 'state': 0, 'event': 'Sync'}
4745
{'timestamp': 1552629001.889522, 'code': 'REL_X', 'state': 2, 'event': 'Relative'}
48-
{'timestamp': 1552629001.889522, 'code': 'SYN_REPORT', 'state': 0, 'event': 'Sync'}
4946
{'timestamp': 1552629001.905525, 'code': 'REL_X', 'state': 3, 'event': 'Relative'}
5047
{'timestamp': 1552629001.905525, 'code': 'REL_Y', 'state': -2, 'event': 'Relative'}
51-
{'timestamp': 1552629001.905525, 'code': 'SYN_REPORT', 'state': 0, 'event': 'Sync'}
5248
{'timestamp': 1552629002.16957, 'code': 'REL_X', 'state': 2, 'event': 'Relative'}
53-
{'timestamp': 1552629002.16957, 'code': 'SYN_REPORT', 'state': 0, 'event': 'Sync'}
5449
{'timestamp': 1552629004.233588, 'code': 'MSC_SCAN', 'state': 589825, 'event': 'Misc'}
5550
{'timestamp': 1552629004.233588, 'code': 'BTN_LEFT', 'state': 1, 'event': 'Key'}
56-
{'timestamp': 1552629004.233588, 'code': 'SYN_REPORT', 'state': 0, 'event': 'Sync'}
5751
{'timestamp': 1552629004.361593, 'code': 'MSC_SCAN', 'state': 589825, 'event': 'Misc'}
5852
{'timestamp': 1552629004.361593, 'code': 'BTN_LEFT', 'state': 0, 'event': 'Key'}
59-
{'timestamp': 1552629004.361593, 'code': 'SYN_REPORT', 'state': 0, 'event': 'Sync'}
6053
{'timestamp': 1552629005.361596, 'code': 'MSC_SCAN', 'state': 589826, 'event': 'Misc'}
6154
{'timestamp': 1552629005.361596, 'code': 'BTN_RIGHT', 'state': 1, 'event': 'Key'}
62-
{'timestamp': 1552629005.361596, 'code': 'SYN_REPORT', 'state': 0, 'event': 'Sync'}
6355
6456
The REL_X and REL_Y codes refer to relative mouse motion. Here, the mouse started by moving 1 unit to the right (REL_X).
6557

@@ -91,17 +83,11 @@ This code gives the following results:
9183
9284
{'timestamp': 1552629513.7494, 'code': 'BTN_SOUTH', 'state': 1, 'event': 'Key'}
9385
{'timestamp': 1552629513.7494, 'code': 'ABS_Y', 'state': -1, 'event': 'Absolute'}
94-
{'timestamp': 1552629513.7494, 'code': 'SYN_REPORT', 'state': 0, 'event': 'Sync'}
9586
{'timestamp': 1552629513.969403, 'code': 'BTN_SOUTH', 'state': 0, 'event': 'Key'}
96-
{'timestamp': 1552629513.969403, 'code': 'SYN_REPORT', 'state': 0, 'event': 'Sync'}
9787
{'timestamp': 1552629517.089424, 'code': 'ABS_X', 'state': -253, 'event': 'Absolute'}
98-
{'timestamp': 1552629517.089424, 'code': 'SYN_REPORT', 'state': 0, 'event': 'Sync'}
9988
{'timestamp': 1552629517.097385, 'code': 'ABS_X', 'state': -64, 'event': 'Absolute'}
100-
{'timestamp': 1552629517.097385, 'code': 'SYN_REPORT', 'state': 0, 'event': 'Sync'}
10189
{'timestamp': 1552629517.109388, 'code': 'ABS_X', 'state': -211, 'event': 'Absolute'}
102-
{'timestamp': 1552629517.109388, 'code': 'SYN_REPORT', 'state': 0, 'event': 'Sync'}
10390
{'timestamp': 1552629517.117379, 'code': 'ABS_X', 'state': -242, 'event': 'Absolute'}
104-
{'timestamp': 1552629517.117379, 'code': 'SYN_REPORT', 'state': 0, 'event': 'Sync'}
10591
10692
The resulting events are all button presses and joystick control. For example, ABS_X here refers to the
10793
horizontal position of the right joystick on a wired Xbox controller.

examples/misc/audiolouder.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
import asyncio
3+
from rtcbot import Microphone, Speaker
4+
5+
microphone = Microphone()
6+
speaker = Speaker()
7+
8+
9+
@microphone.subscribe
10+
def onData(data):
11+
data = data * 5
12+
if speaker.ready:
13+
speaker.put_nowait(data)
14+
15+
16+
try:
17+
asyncio.get_event_loop().run_forever()
18+
finally:
19+
microphone.close()
20+
speaker.close()

examples/misc/bwvideo.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
import asyncio
3+
from rtcbot import CVCamera, CVDisplay
4+
import cv2
5+
6+
camera = CVCamera()
7+
display = CVDisplay()
8+
9+
10+
@camera.subscribe
11+
def onFrame(frame):
12+
bwframe = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
13+
display.put_nowait(bwframe)
14+
15+
16+
try:
17+
asyncio.get_event_loop().run_forever()
18+
finally:
19+
camera.close()
20+
display.close()

examples/misc/gamepad.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# import logging
2+
3+
# logging.basicConfig(level=logging.DEBUG)
4+
import asyncio
5+
from rtcbot import Gamepad
6+
7+
g = Gamepad()
8+
9+
10+
@g.subscribe
11+
def onkey(key):
12+
print(key)
13+
14+
15+
try:
16+
asyncio.get_event_loop().run_forever()
17+
finally:
18+
g.close()

examples/misc/keyboard.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# import logging
2+
# logging.basicConfig(level=logging.DEBUG)
3+
import asyncio
4+
from rtcbot import Keyboard
5+
6+
kb = Keyboard()
7+
8+
9+
@kb.subscribe
10+
def onkey(key):
11+
print(key)
12+
13+
14+
try:
15+
asyncio.get_event_loop().run_forever()
16+
finally:
17+
kb.close()

examples/misc/mouse.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# import logging
2+
3+
# logging.basicConfig(level=logging.DEBUG)
4+
import asyncio
5+
from rtcbot import Mouse
6+
7+
m = Mouse()
8+
9+
10+
@m.subscribe
11+
def onkey(key):
12+
print(key)
13+
14+
15+
try:
16+
asyncio.get_event_loop().run_forever()
17+
finally:
18+
m.close()

0 commit comments

Comments
 (0)