Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

add file for OT-2 MQTT #170

wants to merge 3 commits into from

Conversation

Neil-YL
Copy link
Contributor

@Neil-YL Neil-YL commented Jan 24, 2025

OT-2 MQTT for Hugging face liquid color matching demo

experiment_id = payload["experiment_id"]

total = int(R + Y + B)
if total <= 300:
Copy link
Member

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

Copy link
Contributor Author

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)
Copy link
Member

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

Copy link
Contributor Author

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"]
Copy link
Member

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

Copy link
Contributor Author

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:
Copy link
Member

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
Copy link
Member

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

Copy link
Member

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

Copy link
Contributor Author

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))
Copy link
Member

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)

Copy link
Contributor Author

@Neil-YL Neil-YL Jan 24, 2025

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 = (
Copy link
Member

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"}}, '
Copy link
Member

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

Copy link
Member

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):
Copy link
Member

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

Copy link
Member

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))
Copy link
Member

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":
Copy link
Member

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)
Copy link
Member

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?

@sgbaird
Copy link
Member

sgbaird commented Jan 24, 2025

I need to come back and finish the review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants