summaryrefslogtreecommitdiff
path: root/tf2_watch
blob: 5cf294aa0a93dd2def3b33506ccd211ab12722a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/env bash

TIME_BETWEEN_SAMPLES="$1"

set -euo pipefail
IFS=$'\n\t'

if [ -z "${TIME_BETWEEN_SAMPLES}" ]; then
	TIME_BETWEEN_SAMPLES="25"
fi

depends() {
	if ! type "$1" >/dev/null; then
		die "\"$1\" must be installed and in your \$PATH"
	fi
}

depends pkill
depends mupdf
depends rosrun

GENERATED_PDF="frames.pdf"
GENERATED_RV="frames.gv"

cleanstop() {
	rm -rf "./${GENERATED_PDF}" "./${GENERATED_RV}"
	pkill mupdf
}

trap "cleanstop" EXIT


MU_LAUNCHED=""

while : ; do
	rosrun tf2_tools view_frames.py

	if [ -z "${MU_LAUNCHED}" ]; then
		mupdf "${GENERATED_PDF}" &
		MU_LAUNCHED="y"
	else
		pkill -hup mupdf
	fi

	sleep "${TIME_BETWEEN_SAMPLES}"
done