aind_manipulator

pydantic model aind_behavior_services.calibration.aind_manipulator.AindManipulatorCalibration[source]

Bases: Calibration

Aind manipulator calibration class

Fields:
field description: Literal['Calibration of the load cells system'] = 'Calibration of the load cells system'[source]
field device_name: str = 'AindManipulator'[source]

Must match a device name in rig/instrument

field input: AindManipulatorCalibrationInput [Required][source]
field output: AindManipulatorCalibrationOutput [Required][source]
pydantic model aind_behavior_services.calibration.aind_manipulator.AindManipulatorCalibrationInput[source]

Bases: BaseModel

Fields:
field axis_configuration: List[AxisConfiguration] = [AxisConfiguration(axis=<Axis.Y1: 2>, step_acceleration_interval=100, step_interval=100, microstep_resolution=<MicrostepResolution.MICROSTEP8: 0>, maximum_step_interval=2000, motor_operation_mode=<MotorOperationMode.QUIET: 0>, max_limit=25, min_limit=-0.01), AxisConfiguration(axis=<Axis.Y2: 3>, step_acceleration_interval=100, step_interval=100, microstep_resolution=<MicrostepResolution.MICROSTEP8: 0>, maximum_step_interval=2000, motor_operation_mode=<MotorOperationMode.QUIET: 0>, max_limit=25, min_limit=-0.01), AxisConfiguration(axis=<Axis.X: 1>, step_acceleration_interval=100, step_interval=100, microstep_resolution=<MicrostepResolution.MICROSTEP8: 0>, maximum_step_interval=2000, motor_operation_mode=<MotorOperationMode.QUIET: 0>, max_limit=25, min_limit=-0.01), AxisConfiguration(axis=<Axis.Z: 4>, step_acceleration_interval=100, step_interval=100, microstep_resolution=<MicrostepResolution.MICROSTEP8: 0>, maximum_step_interval=2000, motor_operation_mode=<MotorOperationMode.QUIET: 0>, max_limit=25, min_limit=-0.01)][source]
field full_step_to_mm: ManipulatorPosition = ManipulatorPosition(x=0.01, y1=0.01, y2=0.01, z=0.01)[source]
field homing_order: List[Axis] = [Axis.Y1, Axis.Y2, Axis.X, Axis.Z][source]
field initial_position: ManipulatorPosition = ManipulatorPosition(x=0.0, y1=0.0, y2=0.0, z=0.0)[source]
pydantic model aind_behavior_services.calibration.aind_manipulator.AindManipulatorCalibrationOutput[source]

Bases: BaseModel

pydantic model aind_behavior_services.calibration.aind_manipulator.AindManipulatorDevice[source]

Bases: HarpStepperDriver

Fields:
field calibration: AindManipulatorCalibration | None = None[source]
class aind_behavior_services.calibration.aind_manipulator.Axis(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

Motor axis available

NONE = 0[source]
X = 1[source]
Y1 = 2[source]
Y2 = 3[source]
Z = 4[source]
pydantic model aind_behavior_services.calibration.aind_manipulator.AxisConfiguration[source]

Bases: BaseModel

Axis configuration

Fields:
field axis: Axis [Required][source]
field max_limit: float = 25[source]
field maximum_step_interval: int = 2000[source]
Constraints:
  • ge = 100

  • le = 20000

field microstep_resolution: MicrostepResolution = MicrostepResolution.MICROSTEP8[source]
field min_limit: float = -0.01[source]
field motor_operation_mode: MotorOperationMode = MotorOperationMode.QUIET[source]
field step_acceleration_interval: int = 100[source]

Acceleration of the step interval in microseconds

Constraints:
  • ge = 2

  • le = 2000

field step_interval: int = 100[source]

Step interval in microseconds.

Constraints:
  • ge = 100

  • le = 20000

pydantic model aind_behavior_services.calibration.aind_manipulator.CalibrationLogic[source]

Bases: AindBehaviorTaskLogicModel

Config:
  • extra: str = forbid

  • validate_assignment: bool = True

  • validate_defaults: bool = True

  • strict: bool = True

  • str_strip_whitespace: bool = True

Fields:
Validators:
field name: str = 'AindManipulatorCalibrationLogic'[source]
field task_parameters: CalibrationParameters [Required][source]
field version: Literal['0.2.0'] = '0.2.0'[source]
Validated by:
  • coerce_version

pydantic model aind_behavior_services.calibration.aind_manipulator.CalibrationParameters[source]

Bases: TaskParameters

Config:
  • extra: str = allow

  • validate_assignment: bool = True

  • validate_defaults: bool = True

  • strict: bool = True

  • str_strip_whitespace: bool = True

Fields:

Validators:

pydantic model aind_behavior_services.calibration.aind_manipulator.CalibrationRig[source]

Bases: AindBehaviorRigModel

Fields:
Validators:
field manipulator: AindManipulatorDevice = None[source]
field version: Literal['0.1.0'] = '0.1.0'[source]
Validated by:
pydantic model aind_behavior_services.calibration.aind_manipulator.ManipulatorPosition[source]

Bases: BaseModel

Fields:
field x: float [Required][source]
field y1: float [Required][source]
field y2: float [Required][source]
field z: float [Required][source]
class aind_behavior_services.calibration.aind_manipulator.MicrostepResolution(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

MICROSTEP16 = 1[source]
MICROSTEP32 = 2[source]
MICROSTEP64 = 3[source]
MICROSTEP8 = 0[source]
class aind_behavior_services.calibration.aind_manipulator.MotorOperationMode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

DYNAMIC = 1[source]
QUIET = 0[source]

Example

import os

from aind_behavior_services.base import get_commit_hash
from aind_behavior_services.calibration import aind_manipulator as m
from aind_behavior_services.session import AindBehaviorSessionModel
from aind_behavior_services.utils import utcnow

calibration_data = m.AindManipulatorCalibration(
    device_name="AindManipulatorCalibration",
    input=m.AindManipulatorCalibrationInput(
        full_step_to_mm=m.ManipulatorPosition(x=0.01, y1=0.01, y2=0.01, z=0.01),
        axis_configuration=[
            m.AxisConfiguration(axis=m.Axis.X),
            m.AxisConfiguration(axis=m.Axis.Y1),
            m.AxisConfiguration(axis=m.Axis.Y2),
            m.AxisConfiguration(axis=m.Axis.Z),
        ],
        homing_order=[m.Axis.Y2, m.Axis.Y1, m.Axis.X, m.Axis.Z],
        initial_position=m.ManipulatorPosition(y1=0, y2=0, x=0, z=10000),
    ),
    output=m.AindManipulatorCalibrationOutput(),
    date=utcnow(),
)

calibration_logic = m.CalibrationLogic(task_parameters=m.CalibrationParameters())


calibration_session = AindBehaviorSessionModel(
    root_path="C:\\Data",
    allow_dirty_repo=False,
    experiment="AindManipulatorCalibration",
    date=utcnow(),
    subject="AindManipulator",
    experiment_version="manipulator_control",
    commit_hash=get_commit_hash(),
)

rig = m.CalibrationRig(
    manipulator=m.AindManipulatorDevice(port_name="COM4", calibration=calibration_data),
    rig_name="AindManipulatorRig",
)

seed_path = "local/aind_manipulator_{suffix}.json"
os.makedirs(os.path.dirname(seed_path), exist_ok=True)
with open(seed_path.format(suffix="calibration_logic"), "w") as f:
    f.write(calibration_logic.model_dump_json(indent=3))
with open(seed_path.format(suffix="session"), "w") as f:
    f.write(calibration_session.model_dump_json(indent=3))
with open(seed_path.format(suffix="rig"), "w") as f:
    f.write(rig.model_dump_json(indent=3))