Skip to content

Actuated Sensor

This module provides a class for the actuated sensor.

ATTRIBUTE DESCRIPTION
MAX_SPEED

Maximum speed

TYPE: float

READ_FORMAT

Format for reading data

TYPE: str

MoveForceData

NamedTuple for move force data

TYPE: NamedTuple

CLASS DESCRIPTION
ActuatedSensor

Actuated sensor class

ForceDisplacement

Stress-Strain program

Documentation last updated: 2025-02-22

ActuatedSensor

ActuatedSensor(
    port: str,
    limits: Iterable[float] = (-30.0, 0),
    force_threshold: float = 10000,
    stabilize_timeout: float = 1,
    force_tolerance: float = 0.01,
    *,
    home_displacement: float = -1.0,
    max_speed: float = MAX_SPEED,
    steps_per_second: int = 6400,
    calibration_factor: float = 1.0,
    correction_parameters: tuple[float] = (1.0, 0.0),
    baudrate: int = 115200,
    verbose: bool = False,
    **kwargs,
)

Bases: LoadCell

Actuated sensor class

ATTRIBUTE DESCRIPTION
force_threshold

Force threshold

TYPE: float

home_displacement

Home position

TYPE: float

limits

Lower and upper limits for the actuator

TYPE: Tuple[float]

max_speed

Maximum speed

TYPE: float

program

program to run

TYPE: Program

displacement

current displacement

TYPE: float

baseline

Baseline value

TYPE: int

buffer

data buffer for the device

TYPE: deque

buffer_df

data buffer as a DataFrame

TYPE: DataFrame

records

records for the device

TYPE: deque

records_df

records as a DataFrame

TYPE: DataFrame

record_event

event for recording data

TYPE: Event

runs

dictionary of runs

TYPE: dict

n_runs

number of runs

TYPE: int

connection_details

connection details for the device

TYPE: dict

device

device object that communicates with physical tool

TYPE: Device

flags

flags for the class

TYPE: SimpleNamespace[str, bool]

is_busy

whether the device is busy

TYPE: bool

is_connected

whether the device is connected

TYPE: bool

verbose

verbosity of class

TYPE: bool

METHOD DESCRIPTION
connect

Connect to the device

getData

Get data from device

getDataframe

Get data as a DataFrame

atDisplacement

Check if the device is at the target displacement

getDisplacement

Get displacement

zero

Set current reading as baseline

home

Move the actuator to the home position

move

Move the actuator to the target displacement and apply the target force

moveBy

Move the actuator by desired distance

moveTo

Move the actuator to desired displacement

touch

Apply the target force

run

Run the program

Initialize the actuated sensor

PARAMETER DESCRIPTION
port

Serial port

TYPE: str

limits

Lower and upper limits for the actuator

TYPE: Iterable[float] DEFAULT: (-30.0, 0)

force_threshold

Force threshold

TYPE: float DEFAULT: 10000

stabilize_timeout

Time to wait for the device to stabilize

TYPE: float DEFAULT: 1

force_tolerance

Tolerance for

TYPE: float DEFAULT: 0.01

home_displacement

Home position

TYPE: float DEFAULT: -1.0

max_speed

Maximum speed

TYPE: float DEFAULT: MAX_SPEED

steps_per_second

Steps per second

TYPE: int DEFAULT: 6400

calibration_factor

Calibration factor

TYPE: float DEFAULT: 1.0

correction_parameters

Polynomial correction parameters

TYPE: tuple[float] DEFAULT: (1.0, 0.0)

baudrate

Baudrate for serial communication

TYPE: int DEFAULT: 115200

verbose

Print verbose output

TYPE: bool DEFAULT: False

atDisplacement

atDisplacement(
    displacement: float,
    current_displacement: float | None = None,
) -> bool

Check if the device is at the target displacement

PARAMETER DESCRIPTION
displacement

Target displacement

TYPE: float

current_displacement

Current displacement. Defaults to None.

TYPE: float | None DEFAULT: None

RETURNS DESCRIPTION
bool

True if the device is at the target displacement

TYPE: bool

getData

getData(*args, **kwargs) -> MoveForceData | None

Get data from device

RETURNS DESCRIPTION
MoveForceData

displacement, value, end_stop

TYPE: MoveForceData | None

getDisplacement

getDisplacement() -> float | None

Get displacement

RETURNS DESCRIPTION
float

Displacement in mm

TYPE: float | None

home

home() -> bool

Move the actuator to the home position

RETURNS DESCRIPTION
bool

whether movement is successful

TYPE: bool

move

move(by: float, speed: float | None = None) -> bool

Move the actuator to the target displacement and apply the target force

PARAMETER DESCRIPTION
by

distance in mm

TYPE: float

speed

movement speed. Defaults to 0.375.

TYPE: float DEFAULT: None

RETURNS DESCRIPTION
bool

whether movement is successful

TYPE: bool

moveBy

moveBy(by: float, speed: float | None = None) -> bool

Move the actuator by desired distance

PARAMETER DESCRIPTION
by

distance in mm

TYPE: float

speed

movement speed. Defaults to 0.375.

TYPE: float DEFAULT: None

RETURNS DESCRIPTION
bool

whether movement is successful

TYPE: bool

moveTo

moveTo(to: float, speed: float | None = None) -> bool

Move the actuator to desired displacement

PARAMETER DESCRIPTION
to

displacement in mm

TYPE: float

speed

movement speed. Defaults to 0.375.

TYPE: float DEFAULT: None

RETURNS DESCRIPTION
bool

whether movement is successful

TYPE: bool

record

record(
    on: bool,
    show: bool = False,
    clear_cache: bool = False,
    *,
    callback: Callable | None = None,
    **kwargs,
)

Record data from the device

PARAMETER DESCRIPTION
on

whether to record data

TYPE: bool

show

whether to show data. Defaults to False.

TYPE: bool DEFAULT: False

clear_cache

whether to clear the cache. Defaults to False.

TYPE: bool DEFAULT: False

callback

callback function to process data. Defaults to None.

TYPE: Callable | None DEFAULT: None

stream

stream(
    on: bool,
    show: bool = False,
    *,
    callback: Callable | None = None,
    **kwargs,
)

Stream data from the device

PARAMETER DESCRIPTION
on

whether to stream data

TYPE: bool

show

whether to show data. Defaults to False.

TYPE: bool DEFAULT: False

callback

callback function to process data. Defaults to None.

TYPE: Callable | None DEFAULT: None

touch

touch(
    force_threshold: float = 0.1,
    displacement_threshold: float | None = None,
    speed: float | None = None,
    from_top: bool = True,
) -> bool

Apply the target force

PARAMETER DESCRIPTION
force_threshold

target force

TYPE: float DEFAULT: 0.1

displacement_threshold

target displacement

TYPE: float DEFAULT: None

speed

movement speed

TYPE: float DEFAULT: None

from_top

whether to move from the top or bottom

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
bool

whether movement is successful (i.e. force threshold is not reached)

TYPE: bool

zero

zero(wait: float = 5.0)

Set current reading as baseline

PARAMETER DESCRIPTION
wait

Time to wait for the device to stabilize. Defaults to 5.0.

TYPE: float DEFAULT: 5.0

ForceDisplacement

ForceDisplacement(
    instrument: ActuatedSensor | None = None,
    parameters: dict | None = None,
    verbose: bool = False,
)

Bases: Program

Stress-Strain program

run

run(
    force_threshold: float = 10,
    displacement_threshold: float = -20,
    speed: float | None = None,
    stepped: bool = False,
    *,
    step_size: float = 0.1,
    step_interval: float = -5,
    pullback: float = 0,
    clear_cache: bool = True,
) -> DataFrame

Run the program

PARAMETER DESCRIPTION
force_threshold

Force threshold

TYPE: float DEFAULT: 10

displacement_threshold

Displacement threshold

TYPE: float DEFAULT: -20

speed

Movement speed

TYPE: float DEFAULT: None

stepped

Stepped movement

TYPE: bool DEFAULT: False

step_size

Step size

TYPE: float DEFAULT: 0.1

step_interval

Step interval

TYPE: float DEFAULT: -5

pullback

Pullback distance

TYPE: float DEFAULT: 0

clear_cache

Clear data cache

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
DataFrame

pd.DataFrame: Data as a DataFrame