WHY I just got angry, and now I'm reflecting on it.
WHAT It is a method of fishing smelt using Raspberry Pi. Smelt fishing is that of making a hole in the ice and catching a fish.
--A camera and a motor are attached to the Raspberry Pi --When the image processing can detect the attack on the tip of the rod, the motor is turned. --Automated invitation (movement to invite fish by moving a little) --Atari used a tracking algorithm called a particle filter
I've never done electronic work, so I've only made the minimum preparations. Basically, the Raspberry Pi just comes with:
--Power supply: The trouble is that there is no power supply on the ice, so I use the battery for charging the smartphone.
--Camera: An ordinary WEB camera for about 1000 yen
--Wifi adapter
――The trouble is that Wifi doesn't fly on the ice.
-Create an ad-hoc network Communicate with mac
--Display the camera image with SSH -X
and test it.
By switching the GPIO output (0, 1), it is possible to rotate clockwise or counterclockwise.
Install rpi.gpio
to control it from python.
sudo apt-get install python-rpi.gpio
Test code that rotates clockwise for 2 seconds → rotates counterclockwise for 2 seconds.
import RPi.GPIO as GPIO
import time
def init_gpio():
GPIO.setmode(GPIO.BCM)
channel_list = [14, 15, 18]
GPIO.setup(channel_list, GPIO.OUT)
def stop():
GPIO.output(14, False)
GPIO.output(15, False)
GPIO.output(18, False)
def rotate_right(duration):
stop()
GPIO.output(14, True)
GPIO.output(15, False)
GPIO.output(18, True)
time.sleep(duration)
stop()
def rotate_left(duration):
stop()
GPIO.output(14, False)
GPIO.output(15, True)
GPIO.output(18, True)
time.sleep(duration)
stop()
def cleanup():
GPIO.cleanup()
init_gpio()
rotate_right(2)
rotate_left(2)
cleanup()
It seems that I can somehow turn the thread.
The camera alone must detect small movements at the tip of the rod. This time I tried using a particle filter. The particle filter is an algorithm that randomly generates a large number of particles, selects particles that are close to the desired state, and repeatedly tracks them. Since it is difficult to detect only the tip of the rod, this time we implemented a painstaking solution of ** putting green paper on the tip of the rod **.
Taking it seriously, the algorithm is as follows.
--In the initial mode, move the rod in attract mode
--When the shaking of the rod has subsided, the next step is to switch to detect mode.
――If
――If there is a strong shaking of the rod, raise it in fish mode and switch to wait mode.
--Wait until the s
key is pressed in standby mode
--If there is no detection for a certain period of time, it shifts to the initial attract mode. Repeat this
A python script mainly built on ice.
https://github.com/tan-z-tan/raspi_fishing/blob/master/src/RaspiFishing.py
Skip GUI with SSH -X
It is written on the assumption.
This is all because I implemented it on ice without thinking about anything.
motor.rotate_left(0.53)
motor.rotate_right(0.7)
Constants like 0.53 and 0.7 are warm constants for craftsmen who have taken the time and effort. This is due to the fact that the rotation angle is slightly different even if the number of seconds is the same for winding and lowering the motor.
I was able to catch it. The appearance of a poor smelt caught by a machine. I'm happy.
** Raspberry Pi: 2 animals ** ** Human average: 6.75 animals **
** Conclusion: You can catch better if you do it **
When I wrote it seriously, there were too few fish on the whole and I could hardly do a test. When it is time to catch 100 smelts, it is a mechanical task just to put them in and raise them, so mechanization will be effective. .. .. Should be.
I want to hold a Raspberry Pi Fishing contest.
Recommended Posts