pi@raspberrypi:~ $ nano event_start.sh
GNU nano 3.2 event_start.sh
#!/bin/bash
#本シェルスクリプトの置いてあるディレクトリに移動(pythonがはくlogが適切に吐き出されるように。)
cd $(dirname $0)
#トークンを記述
token="xxxご自身のtokenを記載xxx"
#LINEにメッセージを送信
curl -X POST -H "Authorization: Bearer ${token}" -F "message = ラズパイからのメッセージstart" https://notify-api.line.me/api/notify
#ドローンを動かす。result.txtに直近実行のlogを吐けるようにしとく。
python /home/pi/Tello-Python/Single_Tello_Test/tello_test.py /home/pi/Tello-Python/Single_Tello_Test/flight_test2.txt 2>&1 | tee /home/pi/result.txt
#motionを一時停止。暴走しないように。後述。
curl http://localhost:8080/0/detection/pause
pi@raspberrypi:~ $ chmod +x event_start.sh
pi@raspberrypi:~ $ nano event_end.sh
GNU nano 3.2 event_end.sh
#!/bin/bash
#トークンを記述
token="xxxご自身のtokenを記載xxx"
#LINEにメッセージを送信
curl -X POST -H "Authorization: Bearer ${token}" -F "message = ラズパイからのメッセージend" https://notify-api.line.me/api/notify
pi@raspberrypi:~ $ chmod +x event_end.sh
pi@raspberrypi:~ $ sudo nano /etc/motion/motion.conf
GNU nano 3.2 /etc/motion/motion.conf
# %v = event, %q = frame number, %t = camera id number,
# %D = changed pixels, %N = noise level,
# %i and %J = width and height of motion area,
# %K and %L = X and Y coordinates of motion center
# %C = value defined by text_event
# %f = filename with full path
# %n = number indicating filetype
# Both %f and %n are only defined for on_picture_save,
# on_movie_start and on_movie_end
# Quotation marks round string are allowed.
############################################################
# Do not sound beeps when detecting motion (default: on)
# Note: Motion never beeps when running in daemon mode.
quiet on
# Command to be executed when an event starts. (default: none)
# An event starts at first motion detected after a period of no motion defined by event_gap
#; on_event_start value
on_event_start /home/pi/event_start.sh
# Command to be executed when an event ends after a period of no motion
# (default: none). The period of no motion is defined by option event_gap.
#; on_event_end value
on_event_end /home/pi/event_end.sh
# Command to be executed when a picture (.ppm|.jpg) is saved (default: none)
# To give the filename as an argument to a command append it with %f
; on_picture_save value
pi@raspberrypi:~ $ mkdir log
pi@raspberrypi:~ $ sudo motion
pi@raspberrypi:~ $ cat result.txt
id: 0
command: command
response: ok
start time: 2021-05-29 13:08:52.257217
end_time: 2021-05-29 13:08:52.315474
duration: 0.058257
id: 1
command: takeoff
response: ok
start time: 2021-05-29 13:08:52.315591
end_time: 2021-05-29 13:08:57.701102
duration: 5.385511
id: 2
command: flip b
response: ok
start time: 2021-05-29 13:08:59.703400
end_time: 2021-05-29 13:09:03.325487
duration: 3.622087
id: 3
command: flip f
response: ok
start time: 2021-05-29 13:09:05.327844
end_time: 2021-05-29 13:09:08.921326
duration: 3.593482
id: 4
command: flip l
response: ok
start time: 2021-05-29 13:09:10.923559
end_time: 2021-05-29 13:09:14.479949
duration: 3.55639
id: 5
command: flip r
response: ok
start time: 2021-05-29 13:09:16.482158
end_time: 2021-05-29 13:09:20.089971
duration: 3.607813
id: 6
command: land
response: ok
start time: 2021-05-29 13:09:22.092242
end_time: 2021-05-29 13:09:25.904518
duration: 3.812276
pi@raspberrypi:~/log $ ls
'2021-05-23 16:42:56.109620.txt' '2021-05-23 18:13:02.157302.txt'
'2021-05-23 17:30:33.422215.txt' '2021-05-23 18:13:52.863802.txt'
'2021-05-23 17:55:20.817894.txt' '2021-05-23 18:14:50.656453.txt'
'2021-05-23 17:58:11.359075.txt' '2021-05-29 13:07:00.454953.txt'
'2021-05-23 17:59:02.850064.txt' '2021-05-29 13:08:52.256574.txt'
'2021-05-23 17:59:53.879250.txt' '2021-05-30 12:15:42.879107.txt'
'2021-05-23 18:11:40.650572.txt'
pi@raspberrypi:~ $ curl http://localhost:8080/0/detection/pause #motion一時停止
pi@raspberrypi:~ $ curl http://localhost:8080/0/detection/start #motion再開
0 件のコメント:
コメントを投稿