Skip to content

Commit

Permalink
Create hwp gripper agent (#487)
Browse files Browse the repository at this point in the history
* Created hwp gripper agent

* Updates from comments

* Removed unused import

* Uncommented input decorators

* Protect local src imports when building docs

* Fix permissions on Dockerfile

* Added and modified files to account for the change in gripper control scheme. Agent interfaces with a beaglebone microcontroller to perform functions. File src/gripper_server.py and files located in the pru/ directory will be moved to the beaglebone home directory. During operation two beaglebone processes will be ongoing. One process in the "src" directory "python3 gripper_server.py" and one process in the "pru" directory "sudo ./run.sh". The "src" process sets up a server to receive control commands from the agent. The "pru" process continually sends the agent encoder and limit switch data packets. The compiled code is included along with the uncompiled C code.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Changes to make the agent work in the SAT1 setup. Still WIP

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Added energency shutdown functionality by interfacing with the supervisor agent. Rearranged structure of agent processes to better utilize the OCS framework. Added two files in the pru directory which were accidentally missing.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* removed files unrelated to OCS and moved them into the "simonsobs/sobonelib" repository

* Changes for socs update compatibility

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* small change

* Remove dockerfile

* Removed unused imports and variables

* Added hwp_gripper.rst file

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* removed more unused imports

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Added docstrings

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Moved control commands from agent.py into drivers/gripper_client.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Added additional comments to explain the purpose of certain variables

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix syntax error

* Fix Gripper docs page builds

* Mock supervisor agent imports for docs builds

* Add hwp gripper agent to docs index

* Changed shutdown procedure to account for changes in supervisor agent

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Added additional limit switch functionality and renamed method `grip_mode` to `grip_is_cold`

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Simple changes in response to PR

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* minor changes and renames

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Changed communication from UDP to TCP and improved logging messages sent to agent

* Combined function of GripperBuilder.py and GripperCollector.py into single file gripper_collector.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* updated hwp_gripper.rst

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Moved pru packet collection out of the gripper agent and added additional functions to query actuator positions and limit states

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* cleanup gripper agent

and make compatible with PRU monitor

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Changes to get gripper agent working on sat1

* Changed name of gripper class and fixed typo in supervisor monitor

* Modified shutdown procedure and increased command timeout

* Added monitoring of the bias power supply iboot bar

* Disabled emergency grip procedure. Removed no data shutdown trigger. Added exception handling to state monitor

* fixed typo

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* misc gripper agent updates

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Added example session data, and fixed spelling mistakes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Added session.data description and changed structure of iboot outlet setting

* trying to fix unit test

* still trying to fix unit test

* still trying to fix unit test

* still trying to fix unit test

* Remove other hwp_supervisor mock

* still trying to fix unit test

* still trying to fix unit test

* still trying to fix unit test

* still trying to fix unit test

---------

Co-authored-by: Charles Hill <charles.a.hill01@gmail.com>
Co-authored-by: Brian Koopman <brian.koopman@yale.edu>
Co-authored-by: Bryce Bixler <bbixler@ucsd.edu>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Kevin Crowley <ktcrowley@daq-dev.simonsobs.org>
Co-authored-by: Kevin Crowley <ktcrowley@daq-satp1.simonsobs.org>
Co-authored-by: Bryce Bixler <bbixler@daq-satp1.simonsobs.org>
  • Loading branch information
8 people authored Sep 29, 2023
1 parent 593ce9d commit 147149e
Show file tree
Hide file tree
Showing 9 changed files with 966 additions and 14 deletions.
79 changes: 79 additions & 0 deletions docs/agents/hwp_gripper.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
.. highlight:: rst

.. _hwp_gripper:

=================
HWP Gripper Agent
=================

Agent which controls and monitor's the HWP's set of three LEY32C-30 linear actuators.

.. argparse::
:filename: ../socs/agents/hwp_gripper/agent.py
:func: make_parser
:prog: python3 agent.py

Configuration File Examples
---------------------------

Below are configuration examples for the ocs config file and for running the
Agent in a docker container.

OCS Site Config
`````````````````````

An example site-config-file block::

{'agent-class': 'HWPGripperAgent',
'instance-id': 'hwp-gripper',
'arguments': [ '--mcu_ip', '10.10.10.115',
'--control_port', 8041,
'--supervisor-id', 'hwp-supervisor',
'--no-data-warn-time', 60,
'--no-data-shutdown-time', 300, # 5 minutes
]
},

Docker Compose
`````````````````````

An example docker-compose configuration::

ocs-hwp-gripper:
image: simonsobs/socs:latest
hostname: ocs-docker
network_mode: "host"
volumes:
- ${OCS_CONFIG_DIR}:/config:ro
environment:
- INSTANCE_ID=hwp-gripper

Description
--------------
This agent communicates with the `gripper server in sobonelib <sobonelib_>`_, and has operations
to move actuators, home actuators, check if they are in-position, etc.

.. _sobonelib: https://github.com/simonsobs/sobonelib/tree/main/hwp_gripper/control

This agent has two long-running processes, one to regularly query the gripper
server for the gripper-state, and the other to regularly check the hwp-supervisor for the
overall HWP state.

Shutdown mode
```````````````

If there is something wrong with the HWP, due to power or network outages, or cryogenic issues,
it is no longer safe to operate the gripper, as we may not have an accurate understanding of
whether or not the HWP is spinning. If the hwp-supervisor issues a shutdown signal, or if
a sufficiently long time passes where the agent is unable to connect to the supervisor,
the agent enters a shutdown mode in which potentially dangerous operations are blocked.

Shutdown-mode can be cancelled by manually restarting the agent, or by running
the ``cancel_shutdown`` task, which will allow you to operate the grippers.


Agent API
---------

.. autoclass:: socs.agents.hwp_gripper.agent.HWPGripperAgent
:members:
17 changes: 10 additions & 7 deletions docs/agents/hwp_supervisor_agent.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ Here is an example of a config block you can add to your ocs site-config file::
{'agent-class': 'HWPSupervisor',
'instance-id': 'hwp-supervisor',
'arguments': [
'--sleep-time', 5,
'--hwp-lakeshore-id', 'LS240_test',
'--hwp-temp-field', 'Channel_06',
'--hwp-temp-thresh', 70, # Kelvin
'--hwp-encoder-id', 'HBA0',
'--hwp-rotation-id', 'rotator',
'--hwp-ups-id', 'ups'
'--ybco-lakeshore-id', 'cryo-ls240-lsa2619',
'--ybco-temp-field', 'Channel_7',
'--ybco-temp-thresh', 75,
'--hwp-encoder-id', 'hwp-bbb-e1',
'--hwp-pmx-id', 'hwp-pmx',
'--hwp-pid-id', 'hwp-pid',
'--ups-id', 'power-ups-az',
'--ups-minutes-remaining-thresh', 45,
'--iboot-id', 'power-iboot-hwp-2',
'--iboot-outlets', [1,2]
]}


Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ API Reference Full API documentation for core parts of the SOCS library.
agents/fts_agent
agents/generator
agents/hwp_encoder
agents/hwp_gripper
agents/hwp_picoscope
agents/hwp_pid
agents/hwp_pmx
Expand Down
Empty file.
Loading

0 comments on commit 147149e

Please sign in to comment.