Skip to content

Commit e1b5d07

Browse files
authored
Jackhammer mode docs (#483)
* Jackhammer test script * Multi iteration * Added comments * Upgraded dependencies and started jackhammer mode documentation. * Added jackhammer mode docs.
1 parent 4455630 commit e1b5d07

File tree

7 files changed

+89
-15
lines changed

7 files changed

+89
-15
lines changed

.idea/copilot.data.migration.agent.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/copilot.data.migration.edit.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/assets/libum.dll

41 KB
Binary file not shown.

docs/development/index.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ on [GitHub](https://github.com/VirtualBrainLab/ephys-link), and we welcome contr
55

66
This section describes:
77

8-
- [The Socket.IO server's API](socketio_api.md) and how to communicate with Ephys Link from a client application
9-
- How to [add a new manipulator](adding_a_manipulator.md) to Ephys Link
10-
- General [code organization](code_organization.md) for Ephys Link
11-
- Auto-generated [source code reference](../reference/SUMMARY.md) intended for developers who are maintaining Ephys Link
8+
- [The Socket.IO server's API](socketio_api.md) and how to communicate with Ephys Link from a client application.
9+
- How to [add a new manipulator](adding_a_manipulator.md) to Ephys Link.
10+
- General [code organization](code_organization.md) for Ephys Link.
11+
- Auto-generated [source code reference](../reference/SUMMARY.md) intended for developers who are maintaining Ephys Link.
12+
- Testing [Jackhammer Mode](jackhammer_mode.md).
1213

1314
## Installing for Development
1415

1516
1. Clone the repository.
16-
2. Install [UV](https://docs.astral.sh/uv/#installation)
17-
3. Install [Hatch](https://hatch.pypa.io/latest/install/)
18-
4. In a terminal, navigate to the repository's root directory and run
17+
2. Install [UV](https://docs.astral.sh/uv/#installation).
18+
3. Install [Hatch](https://hatch.pypa.io/latest/install/).
19+
4. In a terminal, navigate to the repository's root directory and run.
1920

2021
```bash
2122
hatch shell
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Jackhammer Mode
2+
3+
This is an internal feature for rapidly oscillating the manipulator along an axis.
4+
5+
Jackhammer mode is not exposed in Ephys Link yet so this guide is to demonstrate how to test it in Python.
6+
7+
## 1. Get Ephys Link
8+
9+
Follow the instructions for [Installing for Development](index.md#installing-for-development). Or, just use a basic Python virtual environment (Python 3.13+ is required):
10+
11+
```powershell
12+
python -m venv venv
13+
.\venv\Scripts\Activate.ps1
14+
pip install .
15+
```
16+
17+
## 2. Change the Sensapex SDK to support Jackhammer Mode
18+
19+
You need to replace the `libum.dll` file in the Sensapex library folder. This is located at `<virtual env>\Lib\site-packages\sensapex`. If you made a virtual environment named `venv` in the previous step, it would be `.\venv\Lib\site-packages\sensapex`.
20+
21+
1. Download the custom SDK [here](../assets/libum.dll).
22+
2. (Optional) Make a backup of the old `libum.dll` in the Sensapex library folder by renaming it to `libum.dll.bck` or something like that.
23+
3. Copy the downloaded `libum.dll` to the Sensapex library folder.
24+
4. Modify `sensapex.py` in the Sensapex library folder to enable using this custom DLL. Set the `max_version` variable at line `398` to `(1, 510)`.
25+
26+
You can (optionally) test if everything is still working by [running Ephys Link](../usage/starting_ephys_link.md) and checking to see if it can still see and control Sensapex manipulators.
27+
28+
## 3. Use the test script
29+
30+
There's a test script in `scripts/jackhammer.py` that makes a call to Jackhammer mode.
31+
32+
In short, jackhammer mode enables open-loop control of the manipulators by letting you turn on and off the motors in a sequence. You can define a "first" and "second" stage to cycle between. When the "thrust length" argument is positive, the manipulator will move in the forward direction and when it is negative it will move backwards. Thrust length is not a real unit but is some percentage representing the amount of movement a step should take.

pyproject.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ exclude = ["/.github", "/.idea", "/docs"]
5959
installer = "uv"
6060
python = "3.13"
6161
dependencies = [
62-
"pyinstaller==6.14.2",
63-
"basedpyright==1.29.5",
64-
"pytest==8.4.1",
65-
"pytest-cov==6.2.1",
66-
"pytest-mock==3.14.1",
67-
"pytest-asyncio==1.0.0"
62+
"pyinstaller==6.15.0",
63+
"basedpyright==1.31.4",
64+
"pytest==8.4.2",
65+
"pytest-cov==6.3.0",
66+
"pytest-mock==3.15.0",
67+
"pytest-asyncio==1.1.0"
6868
]
6969
[tool.hatch.envs.default.scripts]
7070
exe = "pyinstaller.exe ephys_link.spec -y -- -d && pyinstaller.exe ephys_link.spec -y"
@@ -79,8 +79,8 @@ installer = "uv"
7979
python = "3.13"
8080
skip-install = true
8181
dependencies = [
82-
"mkdocs-material==9.6.11",
83-
"mkdocstrings-python==1.16.10",
82+
"mkdocs-material==9.6.19",
83+
"mkdocstrings-python==1.18.2",
8484
"mkdocs-gen-files==0.5.0",
8585
"mkdocs-literate-nav==0.6.2",
8686
"mkdocs-section-index==0.3.10"

scripts/jackhammer.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from ctypes import c_char, c_int
2+
3+
from sensapex import UMP
4+
5+
# Edit these parameters:
6+
DEVICE_ID = 3 # Manipulator ID.
7+
AXIS = 3 # Axis (0=X, 1=Y, 2=Z, 3=D).
8+
9+
NUMBER_OF_CYCLES = 20 # Number of time the first and second stage are repeated.
10+
11+
NUMBER_OF_STEP_IN_FIRST_STAGE = 10
12+
FIRST_STAGE_THRUST_LENGTH = 15 # +/- 0 - 100
13+
14+
NUMBER_OF_STEP_IN_SECOND_STAGE = 5
15+
SECOND_STAGE_THRUST_LENGTH = -15 # +/- 0 - 100
16+
17+
# Do not edit below this line.
18+
um = UMP.get_ump()
19+
20+
um.call(
21+
"um_take_jackhammer_step",
22+
c_int(DEVICE_ID),
23+
c_char(AXIS),
24+
c_int(NUMBER_OF_CYCLES),
25+
c_int(NUMBER_OF_STEP_IN_FIRST_STAGE),
26+
c_int(FIRST_STAGE_THRUST_LENGTH),
27+
c_int(NUMBER_OF_STEP_IN_SECOND_STAGE),
28+
c_int(SECOND_STAGE_THRUST_LENGTH),
29+
)

0 commit comments

Comments
 (0)