-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add file for OT-2 MQTT #170
base: main
Are you sure you want to change the base?
Conversation
experiment_id = payload["experiment_id"] | ||
|
||
total = int(R + Y + B) | ||
if total <= 300: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you meant total > 300, not total <= 300
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops
session_id = payload["session_id"] | ||
experiment_id = payload["experiment_id"] | ||
|
||
total = int(R + Y + B) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think int() may be unnecessary here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yah, I got some round out error from previous version(R+Y+B=300) not sure if it is resulted by passing data between device. For total <= 300, int is unnecessary
if total <= 300: | ||
raise ValueError("The sum of the proportions must be smaller than 300") | ||
|
||
position = ["B1", "B2", "B3"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small explanations here would help. Unsure what position and B1-3 refer to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are the location of the 3-color tips and 3-color vials(on the 6-slot rack), since we reuse them so I put it in same position.
# To DO: start the mixing from the color with the smallest volume | ||
|
||
for pos in position: | ||
if float(portion[pos]) != 0.0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, pos of the tip in the tip rack, to be reused
p300.pick_up_tip(tiprack_1[pos]) | ||
p300.aspirate(color_volume[pos], reservoir[pos]) | ||
p300.dispense(color_volume[pos], plate[mix_well]) | ||
p300.default_speed = 100 # reduce pipette speed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the units here? Add comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also maybe clarify reduction is to prevent droplets falling during transfer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default speed is 400 mm/sec
p300.drop_tip(tiprack_1[pos]) | ||
|
||
p300.pick_up_tip(tiprack_2["A2"]) | ||
p300.move_to(plate[mix_well].top(z=3)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is the logic for knowing which well is next? How does that work? (Relevant for our Bambu lab task)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a MongoDB saving all the well status (used/empty) and every time student submit a valid mix will be assigned one, which I would also use for the credit quota as well. This is on HF and not on OT-2. Currently I inefficiently request the data and send back the used one as "used" every time. Later I think caching a list for each deployment would be more reasonable.
|
||
print("Sending status to HF...") | ||
|
||
payload = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
print("Sending status to HF...") | ||
|
||
payload = ( | ||
f'{{"status": {{"sensor_status":"in_place"}}, ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor, consider "sensor_in_place": True
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nvm, I see you use "charging" as a status. I'm fine with this
client.publish(OT2_STATUS_TOPIC, payload, qos=2) # send a status message back to HF | ||
|
||
|
||
def move_sensor_back(payload): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider separating operation fn from MQTT logic (i.e., move_sensor_back wouldn't assume an MQTT payload). Just a thought
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nvm, didn't realize there was only a single ot2-specific line
session_id = payload["session_id"] | ||
experiment_id = payload["experiment_id"] | ||
|
||
p300.drop_tip(tiprack_2["A2"].top(z=-80)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is the entire OT-2 code for this function, so nvm about splitting
) | ||
client.publish(OT2_STATUS_TOPIC, payload, qos=2) # send a status message back to HF | ||
|
||
if results_status == "sensor_timeout": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we need to think about what happens if we get a sensor timeout from a user perspective
# Keep protocol active | ||
while True: | ||
try: | ||
command = command_queue.get(timeout=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this timeout duration make sense?
I need to come back and finish the review |
OT-2 MQTT for Hugging face liquid color matching demo