README.md 4.32 KB
Newer Older
cgbsat's avatar
cgbsat committed
1 2
# auto-scheduler

3 4 5
This is a tool to automatically compute passes of satellites and schedule observations on the
[SatNOGS Network](https://network.satnogs.org/). It is based on the scheduling code from
SatNOGS network and requires [python-satellitetle](https://gitlab.com/librespacefoundation/python-satellitetle) for downloading TLEs.
Fabian P. Schmidt's avatar
Fabian P. Schmidt committed
6

7
## Installation
Fabian P. Schmidt's avatar
Fabian P. Schmidt committed
8

9 10
You will need Python 3 and the Python virtualenv utility. The following example assumes that you are using Debian.

11
```bash
12
sudo apt-get update
13 14 15 16
sudo apt-get install git virtualenv python3-virtualenv

git clone https://gitlab.com/librespacefoundation/satnogs/satnogs-auto-scheduler.git
cd satnogs-auto-scheduler
17 18
virtualenv -p python3 env
source env/bin/activate
19
pip install .
Fabian P. Schmidt's avatar
Fabian P. Schmidt committed
20
```
21

22 23 24 25 26 27
You can verify your installed version with the following command:
```
$ ./schedule_single_station.py --version
satnogs-auto-scheduler 0+untagged.160.g3a8e121
```

28 29
## Configuration

cgbsat's avatar
cgbsat committed
30
Copy the env-dist file to .env and edit this file to add your SatNOGS Network API token.
31

cgbsat's avatar
cgbsat committed
32 33 34 35 36
## Test run

Perform a test run to download orbital elements and transmitter priorities (these are stored in `/tmp/cache`) with

```bash
cgbsat's avatar
cgbsat committed
37
./schedule_single_station.py -s <ground station ID> -n
cgbsat's avatar
cgbsat committed
38 39 40 41 42
```

The `-n` option computes the passes but does not schedule them. To schedule these passes, run

```bash
cgbsat's avatar
cgbsat committed
43
./schedule_single_station.py -s <ground station ID>
cgbsat's avatar
cgbsat committed
44 45
```

46 47 48
## Setup priority scheduling

The following commands will add a list consisting of all DUV, BPSK1k2, BPSK9k6, [G]MSK and [G]FSK transmitters into `priorities_37.txt`.
49
Please change the station id (here `37` - in the cache file and the list file name) to your corresponding one!
50 51

```bash
52 53 54 55 56 57 58 59 60
STATION_ID=37
TRM_FILE="/tmp/cache/transmitters_${STATION_ID}.txt"
PRIO_FILE="priorities_${STATION_ID}.txt"

awk '{if ($3>=80) print $0 }' ${TRM_FILE} | grep -e "FSK" | awk '{printf("%s 1.0 %s\n",$1,$2)}' > ${PRIO_FILE}
awk '{if ($3>=0) print $0 }' ${TRM_FILE} | grep -e "BPSK1k2" | awk '{printf("%s 1.0 %s\n",$1,$2)}' >> ${PRIO_FILE}
awk '{if ($3>=0) print $0 }' ${TRM_FILE} | grep -e "BPSK9k6" | awk '{printf("%s 1.0 %s\n",$1,$2)}' >> ${PRIO_FILE}
awk '{if ($3>=80) print $0 }' ${TRM_FILE} | grep -e "MSK" | awk '{printf("%s 1.0 %s\n",$1,$2)}' >> ${PRIO_FILE}
sort -n -k 4 ${TRM_FILE} | grep -e "DUV" | awk '{printf("%s 1.0 %s\n",$1,$2)}' >> ${PRIO_FILE}
61 62
```

cgbsat's avatar
cgbsat committed
63
## Add cron-job
64 65 66 67 68 69 70 71

Start editing your default user's cron (select your preferred editor):
```bash
crontab -e
```

Add a line like this - execute the scheduling script on each full hour:
```bash
72
0 */1 * * * <path_to_auto_scheduler>/env/bin/python <path_to_auto_scheduler>/schedule_single_station.py -s <station_id> -d 1.2 -P <path_to_priority_list>/<priority_file>.txt -f -z
73 74
```

75 76
Omit the `-f` option to also fill in the gaps, but be aware if using a rotator setup! This will wear-out your rotator very quickly!
Add `-w 60` for a delay if you want to give your rotator a bit of time (60 s) to reset or home.
77

78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
## Add systemd-timer
The advantage of using a systemd-timer for invoking the auto-scheduler lies in the better logging output (you can use `journalctl -u satnogs-auto-scheduler.service` to access the log output).

- Add a systemd service unit file at `/etc/systemd/system/satnogs-auto-scheduler.service`:
   ```
   [Unit]
   Description=Schedule SatNOGS observations for 1.2h on station 132
   
   [Service]
   Type=oneshot
   ExecStart=<path_to_auto_scheduler>/env/bin/python <path_to_auto_scheduler>/schedule_single_station.py -s <station_id> -d 1.2 -P <path_to_priority_list>/<priority_file>.txt -z
   User=pi
   ```

- Add a systemd timer unit file at `/etc/systemd/system/satnogs-auto-scheduler.timer`:
  ```
  [Unit]
  Description=Run satnogs-auto-scheduler hourly and on boot
  
  [Timer]
  OnBootSec=2min
  OnUnitActiveSec=1h
  
  [Install]
  WantedBy=timers.target
  ```

- Start the timer with
  ```bash
  sudo systemctl start satnogs-auto-scheduler.timer
  ```
  
- Enable the timer to be started on boot with
  ```bash
  sudo systemctl enable satnogs-auto-scheduler.timer
  ```

If you want to run the auto-scheduler once manually, you can do so with
```bash
sudo systemctl start satnogs-auto-scheduler.service
```
119

120 121 122
## Usage

The following command will list all available command-line arguments:
123
```bash
124 125 126
./schedule_single_station.py --help
```

127 128
## License
[![license](https://img.shields.io/badge/license-AGPL%203.0-6672D8.svg)](LICENSE)
129
Copyright 2019 - Cees Bassa, Fabian Schmidt, Pierros Papadeas