Skip to content

Commit

Permalink
Updated dev install instructions
Browse files Browse the repository at this point in the history
Made the javascript build step clear.
  • Loading branch information
dkumor committed Aug 15, 2019
1 parent a92f648 commit 4c4a9fc
Show file tree
Hide file tree
Showing 10 changed files with 179 additions and 235 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
# Empty rule for forcing rebuilds
phony:

js/node_modules:
cd js; npm i

js: phony
js: phony js/node_modules
cd js; npm run build
cp js/dist/rtcbot.umd.js rtcbot/rtcbot.js

Expand Down
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ The library is explained piece by piece in [the documentation](https://rtcbot.re

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

## Installing

```
pip install rtcbot
```

## Example

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).
Expand Down Expand Up @@ -103,3 +109,21 @@ Browser code (index.html) that displays the video stream:
</body>
</html>
```

## Development

To use `rtcbot` code directly, clone the repository, and install the requirements:

```
pip install -r requirements.txt
```

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:

```
make js
```

This creates `rtcbot/rtcbot.js`, which is returned by `rtcbot.getRTCBotJS()`.

After these two steps, you should be able to successfully import and use the library.
14 changes: 0 additions & 14 deletions docs/inputs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,17 @@ This code gives the following results:
{'timestamp': 1552629001.833567, 'code': 'REL_X', 'state': 1, 'event': 'Relative'}
{'timestamp': 1552629001.833567, 'code': 'REL_Y', 'state': 1, 'event': 'Relative'}
{'timestamp': 1552629001.833567, 'code': 'SYN_REPORT', 'state': 0, 'event': 'Sync'}
{'timestamp': 1552629001.841518, 'code': 'REL_X', 'state': 2, 'event': 'Relative'}
{'timestamp': 1552629001.841518, 'code': 'SYN_REPORT', 'state': 0, 'event': 'Sync'}
{'timestamp': 1552629001.889522, 'code': 'REL_X', 'state': 2, 'event': 'Relative'}
{'timestamp': 1552629001.889522, 'code': 'SYN_REPORT', 'state': 0, 'event': 'Sync'}
{'timestamp': 1552629001.905525, 'code': 'REL_X', 'state': 3, 'event': 'Relative'}
{'timestamp': 1552629001.905525, 'code': 'REL_Y', 'state': -2, 'event': 'Relative'}
{'timestamp': 1552629001.905525, 'code': 'SYN_REPORT', 'state': 0, 'event': 'Sync'}
{'timestamp': 1552629002.16957, 'code': 'REL_X', 'state': 2, 'event': 'Relative'}
{'timestamp': 1552629002.16957, 'code': 'SYN_REPORT', 'state': 0, 'event': 'Sync'}
{'timestamp': 1552629004.233588, 'code': 'MSC_SCAN', 'state': 589825, 'event': 'Misc'}
{'timestamp': 1552629004.233588, 'code': 'BTN_LEFT', 'state': 1, 'event': 'Key'}
{'timestamp': 1552629004.233588, 'code': 'SYN_REPORT', 'state': 0, 'event': 'Sync'}
{'timestamp': 1552629004.361593, 'code': 'MSC_SCAN', 'state': 589825, 'event': 'Misc'}
{'timestamp': 1552629004.361593, 'code': 'BTN_LEFT', 'state': 0, 'event': 'Key'}
{'timestamp': 1552629004.361593, 'code': 'SYN_REPORT', 'state': 0, 'event': 'Sync'}
{'timestamp': 1552629005.361596, 'code': 'MSC_SCAN', 'state': 589826, 'event': 'Misc'}
{'timestamp': 1552629005.361596, 'code': 'BTN_RIGHT', 'state': 1, 'event': 'Key'}
{'timestamp': 1552629005.361596, 'code': 'SYN_REPORT', 'state': 0, 'event': 'Sync'}
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).

Expand Down Expand Up @@ -91,17 +83,11 @@ This code gives the following results:
{'timestamp': 1552629513.7494, 'code': 'BTN_SOUTH', 'state': 1, 'event': 'Key'}
{'timestamp': 1552629513.7494, 'code': 'ABS_Y', 'state': -1, 'event': 'Absolute'}
{'timestamp': 1552629513.7494, 'code': 'SYN_REPORT', 'state': 0, 'event': 'Sync'}
{'timestamp': 1552629513.969403, 'code': 'BTN_SOUTH', 'state': 0, 'event': 'Key'}
{'timestamp': 1552629513.969403, 'code': 'SYN_REPORT', 'state': 0, 'event': 'Sync'}
{'timestamp': 1552629517.089424, 'code': 'ABS_X', 'state': -253, 'event': 'Absolute'}
{'timestamp': 1552629517.089424, 'code': 'SYN_REPORT', 'state': 0, 'event': 'Sync'}
{'timestamp': 1552629517.097385, 'code': 'ABS_X', 'state': -64, 'event': 'Absolute'}
{'timestamp': 1552629517.097385, 'code': 'SYN_REPORT', 'state': 0, 'event': 'Sync'}
{'timestamp': 1552629517.109388, 'code': 'ABS_X', 'state': -211, 'event': 'Absolute'}
{'timestamp': 1552629517.109388, 'code': 'SYN_REPORT', 'state': 0, 'event': 'Sync'}
{'timestamp': 1552629517.117379, 'code': 'ABS_X', 'state': -242, 'event': 'Absolute'}
{'timestamp': 1552629517.117379, 'code': 'SYN_REPORT', 'state': 0, 'event': 'Sync'}
The resulting events are all button presses and joystick control. For example, ABS_X here refers to the
horizontal position of the right joystick on a wired Xbox controller.
Expand Down
20 changes: 20 additions & 0 deletions examples/misc/audiolouder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

import asyncio
from rtcbot import Microphone, Speaker

microphone = Microphone()
speaker = Speaker()


@microphone.subscribe
def onData(data):
data = data * 5
if speaker.ready:
speaker.put_nowait(data)


try:
asyncio.get_event_loop().run_forever()
finally:
microphone.close()
speaker.close()
20 changes: 20 additions & 0 deletions examples/misc/bwvideo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

import asyncio
from rtcbot import CVCamera, CVDisplay
import cv2

camera = CVCamera()
display = CVDisplay()


@camera.subscribe
def onFrame(frame):
bwframe = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
display.put_nowait(bwframe)


try:
asyncio.get_event_loop().run_forever()
finally:
camera.close()
display.close()
18 changes: 18 additions & 0 deletions examples/misc/gamepad.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# import logging

# logging.basicConfig(level=logging.DEBUG)
import asyncio
from rtcbot import Gamepad

g = Gamepad()


@g.subscribe
def onkey(key):
print(key)


try:
asyncio.get_event_loop().run_forever()
finally:
g.close()
17 changes: 17 additions & 0 deletions examples/misc/keyboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# import logging
# logging.basicConfig(level=logging.DEBUG)
import asyncio
from rtcbot import Keyboard

kb = Keyboard()


@kb.subscribe
def onkey(key):
print(key)


try:
asyncio.get_event_loop().run_forever()
finally:
kb.close()
18 changes: 18 additions & 0 deletions examples/misc/mouse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# import logging

# logging.basicConfig(level=logging.DEBUG)
import asyncio
from rtcbot import Mouse

m = Mouse()


@m.subscribe
def onkey(key):
print(key)


try:
asyncio.get_event_loop().run_forever()
finally:
m.close()
Loading

0 comments on commit 4c4a9fc

Please sign in to comment.