Skip to content

Commit 30e5db6

Browse files
authored
chore: usage docs
1 parent 90970ad commit 30e5db6

1 file changed

Lines changed: 1 addition & 46 deletions

File tree

docs/01-usage.md

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,4 @@
11
# Usage
22

3-
Roverlib comes installed by default on every rover, but if for some reason it isn't, [ssh into the rover](https://ase.vu.nl/docs/tutorials/Fundamental%20Concepts/connecting) and run the following pip install command:
3+
Refer to the [service-template-python](https://github.com/VU-ASE/service-template-python) for a complete example on how to use this library.
44

5-
``` bash
6-
pip install roverlib
7-
```
8-
9-
After that, you can use it in a script as shown below, refer to the [service-template-python](https://github.com/VU-ASE/service-template-python) for a complete example.
10-
11-
``` python
12-
#!/usr/bin/python3
13-
import roverlib
14-
import signal
15-
import time
16-
import roverlib.rovercom as rovercom
17-
18-
def run(service : roverlib.Service, configuration : roverlib.ServiceConfiguration):
19-
20-
# Unlike roverlib-go, these functions do not return an error object, but rather throw an error on failure
21-
speed = configuration.GetFloatSafe("speed")
22-
23-
name = configuration.GetStringSafe("name")
24-
25-
write_stream : roverlib.WriteStream = service.GetWriteStream("motor_movement")
26-
27-
write_stream.Write(
28-
29-
rovercom.SensorOutput(
30-
sensor_id=2,
31-
timestamp=int(time.time() * 1000),
32-
controller_output=rovercom.ControllerOutput(
33-
steering_angle=float(1),
34-
left_throttle=float(speed),
35-
right_throttle=float(speed),
36-
front_lights=False
37-
),
38-
)
39-
)
40-
41-
42-
43-
44-
def on_terminate(sig : signal):
45-
logger.info("Terminating")
46-
47-
48-
roverlib.Run(run, on_terminate)
49-
```

0 commit comments

Comments
 (0)