-
Notifications
You must be signed in to change notification settings - Fork 178
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
feat(api): Heater Shaker Firmware Level Emulator #11121
feat(api): Heater Shaker Firmware Level Emulator #11121
Conversation
remove files Fix some parsing errors Formatting Change rpm_per_tick
Codecov Report
@@ Coverage Diff @@
## heater-shaker-firmware-emulator-wip #11121 +/- ##
====================================================================
Coverage 73.76% 73.76%
====================================================================
Files 2077 2077
Lines 57372 57372
Branches 5741 5741
====================================================================
Hits 42318 42318
Misses 13816 13816
Partials 1238 1238
Flags with carried forward coverage won't be shown. Click here to find out more.
|
I confirmed that what I run the docker-compose.yaml file in the monorepo everything starts correctly and I am able to hit the /modules endpoint successfully. |
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.
This is great! Tested the docker-built emulator with dev server and it works! (simply running emulator app with make -C api emulator
results in an unrelated error but I think it's been like that for a while now)
Two things I noticed-
- Sending a
deactivate_shaker
makes the heater-shaker in emulator unresponsive for a few seconds. It eventually responds with shake deactivated though so was wondering if that's an intentional silence. deactivate_heater
is not yet implemented. Left out intentionally?
Thanks so much for implementing this so quickly!
Formatting and linting
So after much fruitless investigation, I have no idea why the emulator does not handle the Had a meeting with Robot Services and they are going to take over the task of getting the command to work. |
@sanni-t please note that I have changed the base from |
@sanni-t can I get a re-review? |
await heatershaker.wait_next_poll() | ||
await heatershaker.start_set_temperature(50.0) | ||
|
||
# Have to wait for next poll because target temp will not update until then |
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.
Is this the intended API contract of the Heater-Shaker hardware controller? If I do hs.start_set_temperature(...)
and then do t = hs.target_temperature
, I'm not guaranteed to get back what I just set?
If yes: I think this is surprising, and we need to document it in the HeaterShaker
class. Doesn't have to happen in this PR, but I'd like confirmation/consensus.
If no: this indicates a bug, I guess?
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.
You know, it makes sense that target temp should be set and it would be just current temp that hasn't update yet.
Looking into it now.
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 left out a line. Fixing it in a followup commit
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.
The behavior is almost there!
|
🙌
That is a good point. It won't matter for manual testing but it would for the unit tests & automated tests. What do we do for unit tests that need to wait for, say, speed to ramp up? Are we changing the duration of a tick to something very small? In that case, maybe we could modify the tick function to ramp down with |
return f"M241 STATUS:{self._latch_status.value.upper()}" | ||
|
||
def _deactivate_heater(self, command: Command) -> str: | ||
self._temperature.set_target(TEMPERATURE_ROOM) |
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.
This makes the temperature status respond with a target of room temperature value. We want the target to return as None
. It looks like the thermocycler & tempdeck's deactivate emulator simply sets the target to None
and current temp to room temperature. So, I'm fine with implementing the same thing here for now. We can revisit them all later.
Or if that isn't easy to implement, just set the target & current rpm to 0 and send the gcode response. And leave a TODO note to improve this behavior to mimic the hardware's true behavior. We can address all improvements in a follow-up ticket when we're not pressed for time. |
Let's do the latter. We really need to resist the urge to implement too much behavior here. This is a testing aid and nothing more, and even then because this interacts with a physical system and we're not simulating the world, there's always going to be little places where the behavior doesn't match. We should definitely make the exact format of communications on the wire the same as firmware, like changing an unset target 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.
This works as expected! Thank you!
* feat: Heater-Shaker Firmware Emulator remove files Fix some parsing errors Formatting Change rpm_per_tick * Tests * Modify home functionality Formatting and linting * fix rpm emulator g-code and add deactivate test * Fix tests * Add deactivate_heater G-Code * Add start_set_temperature * Update home and deactivate_heater functionality Based off of #11121 (comment) * Linting * fix: Fix deactivate_heater function * Make home_delay_time customizable * Linting Co-authored-by: jbleon95 <[email protected]> Co-authored-by: jbleon95 <[email protected]>
Overview
Add firmware level emulator and tests for Heater Shaker
Changelog
Review requests
Risk assessment
Low