Fix bugs all around
This commit is contained in:
parent
9466cdb3fa
commit
1cf3d1df12
|
@ -68,13 +68,13 @@ This topic controls the camera and capture. The message allowed is a JSON messag
|
|||
```json
|
||||
{
|
||||
"action": "image",
|
||||
"sleep": 5,
|
||||
"pump_direction": "FORWARD",
|
||||
"volume": 1,
|
||||
"nb_frame": 200
|
||||
}
|
||||
```
|
||||
|
||||
Sleep in seconds and volume in mL.
|
||||
Volume is in mL.
|
||||
|
||||
This topic can also receive a config update message:
|
||||
```json
|
||||
|
|
1783
flows/main.json
1783
flows/main.json
File diff suppressed because it is too large
Load diff
|
@ -5,6 +5,6 @@
|
|||
"pump_steps_per_ml": 507,
|
||||
"focus_max_speed": 0.5,
|
||||
"pump_max_speed": 30,
|
||||
"stepper_type": "adafruit",
|
||||
"stepper_type": "waveshare",
|
||||
"camera_type": "HQ"
|
||||
}
|
7
scripts/bash/update.sh
Executable file
7
scripts/bash/update.sh
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
cd /home/pi/PlanktonScope
|
||||
|
||||
git stash
|
||||
git pull
|
||||
git checkout stash@{0} -- config.json hardware.json
|
|
@ -160,6 +160,7 @@ class ImagerProcess(multiprocessing.Process):
|
|||
self.__img_done = 0
|
||||
self.__sleep_before = None
|
||||
self.__pump_volume = None
|
||||
self.__pump_direction = "FORWARD"
|
||||
self.__img_goal = None
|
||||
self.imager_client = None
|
||||
|
||||
|
@ -303,7 +304,12 @@ class ImagerProcess(multiprocessing.Process):
|
|||
# Get duration to wait before an image from the different received arguments
|
||||
self.__sleep_before = float(last_message["sleep"])
|
||||
# Get volume in between two images from the different received arguments
|
||||
self.__pump_volume = float(last_message["volume"])
|
||||
# Minimal volume is 0.1mL
|
||||
self.__pump_volume = max(float(last_message["volume"]), 0.1)
|
||||
|
||||
# Get the pump direction message
|
||||
self.__pump_direction = last_message["pump_direction"]
|
||||
|
||||
# Get the number of frames to image from the different received arguments
|
||||
self.__img_goal = int(last_message["nb_frame"])
|
||||
|
||||
|
@ -471,6 +477,21 @@ class ImagerProcess(multiprocessing.Process):
|
|||
f"We did not understand the received request {action} - {last_message}"
|
||||
)
|
||||
|
||||
def __pump_message(self):
|
||||
"""Sends a message to the pump process"""
|
||||
# Pump during a given volume
|
||||
self.imager_client.client.publish(
|
||||
"actuator/pump",
|
||||
json.dumps(
|
||||
{
|
||||
"action": "move",
|
||||
"direction": self.__pump_direction,
|
||||
"volume": self.__pump_volume,
|
||||
"flowrate": 2,
|
||||
}
|
||||
),
|
||||
)
|
||||
|
||||
def __state_imaging(self):
|
||||
# TODO we should make sure here that we are not writing to an existing folder
|
||||
# otherwise we might overwrite the metadata.json file
|
||||
|
@ -516,17 +537,9 @@ class ImagerProcess(multiprocessing.Process):
|
|||
|
||||
# Set the LEDs as Blue
|
||||
planktoscope.light.setRGB(0, 0, 255)
|
||||
self.imager_client.client.publish(
|
||||
"actuator/pump",
|
||||
json.dumps(
|
||||
{
|
||||
"action": "move",
|
||||
"direction": "FORWARD",
|
||||
"volume": self.__pump_volume,
|
||||
"flowrate": 2,
|
||||
}
|
||||
),
|
||||
)
|
||||
|
||||
self.__pump_message()
|
||||
|
||||
# FIXME We should probably update the global metadata here with the current datetime/position/etc...
|
||||
|
||||
# Set the LEDs as Green
|
||||
|
@ -610,18 +623,7 @@ class ImagerProcess(multiprocessing.Process):
|
|||
"status/pump", self.pump_callback
|
||||
)
|
||||
|
||||
# Pump during a given volume
|
||||
self.imager_client.client.publish(
|
||||
"actuator/pump",
|
||||
json.dumps(
|
||||
{
|
||||
"action": "move",
|
||||
"direction": "BACKWARD",
|
||||
"volume": self.__pump_volume,
|
||||
"flowrate": 2,
|
||||
}
|
||||
),
|
||||
)
|
||||
self.__pump_message()
|
||||
|
||||
# Set the LEDs as Green
|
||||
planktoscope.light.setRGB(0, 255, 0)
|
||||
|
|
|
@ -92,6 +92,7 @@ def light(state):
|
|||
## Wait message: Green
|
||||
## Actuate message: White
|
||||
## Pumping message: Blue
|
||||
## Pumping 2 message: BLue + Green
|
||||
|
||||
# This is called if this script is launched directly
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -16,7 +16,7 @@ logger.info("planktoscope.stepper is loaded")
|
|||
|
||||
|
||||
class StepperWaveshare:
|
||||
"""A bipolar stepper motor."""
|
||||
"""A bipolar stepper motor using the Waveshare HAT."""
|
||||
|
||||
def __init__(self, dir_pin, step_pin, enable_pin):
|
||||
self.dir_pin = dir_pin
|
||||
|
@ -178,6 +178,7 @@ class StepperProcess(multiprocessing.Process):
|
|||
def __init__(self, event):
|
||||
super(StepperProcess, self).__init__()
|
||||
logger.info("Initialising the stepper process")
|
||||
RPi.GPIO.setup([12, 4], RPi.GPIO.OUT, initial=RPi.GPIO.HIGH)
|
||||
|
||||
self.stop_event = event
|
||||
|
||||
|
|
Loading…
Reference in a new issue