Skip to content

dummy

plantimager.dummy Link

The dummy module offers CNC, Gimbal & Camera implementation

CNC Link

CNC(homing=False, x_lims=[0.0, 100.0], y_lims=[0.0, 100.0], z_lims=[0.0, 30.0])

Bases: AbstractCNC

A dummy CNC for testing purposes.

TODO: enable workspace origin offset, motor seed configuration,...

Attributes:

Name Type Description
position list

The current pan and tilt positions of the gimbal.

x_lims ((int, int), optional)

The allowed range of X-axis positions.

y_lims ((int, int), optional)

The allowed range of Y-axis positions.

z_lims ((int, int), optional)

The allowed range of Z-axis positions.

Examples:

>>> from plantimager.dummy import CNC
>>> cnc = CNC()
>>> cnc.get_position()
[80.5, 80.79, 15.46]
>>> cnc.home()
>>> cnc.get_position()
[0.0, 0.0, 0.0]
>>> cnc.moveto(20, 20, 5)
>>> cnc.get_position()
[20.0, 20.0, 5.0]

Parameters:

Name Type Description Default
homing bool

If True, axes homing will be performed upon CNC object instantiation.

False
x_lims (float, float)

The allowed range of X-axis positions. Defaults to [0., 100.]

[0.0, 100.0]
y_lims (float, float)

The allowed range of Y-axis positions. Defaults to [0., 100.]

[0.0, 100.0]
z_lims (float, float)

The allowed range of Z-axis positions. Defaults to [0., 30.]

[0.0, 30.0]
Notes

If homing is false, a random initial position will be generated.

Source code in plantimager/dummy.py
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
def __init__(self, homing=False, x_lims=[0., 100.], y_lims=[0., 100.], z_lims=[0., 30.]):
    """
    Parameters
    ----------
    homing : bool, optional
        If ``True``, axes homing will be performed upon CNC object instantiation.
    x_lims : (float, float), optional
        The allowed range of X-axis positions. Defaults to ``[0., 100.]``
    y_lims : (float, float), optional
        The allowed range of Y-axis positions. Defaults to ``[0., 100.]``
    z_lims : (float, float), optional
        The allowed range of Z-axis positions. Defaults to ``[0., 30.]``

    Notes
    -----
    If `homing` is false, a random initial position will be generated.
    """
    super().__init__()
    self.x_lims = x_lims
    self.y_lims = y_lims
    self.z_lims = z_lims
    self.position = self._random_position()
    self.start(homing)

get_position Link

get_position()

Returns the XYZ position of the CNC.

Source code in plantimager/dummy.py
118
119
120
def get_position(self) -> list:
    """Returns the XYZ position of the CNC."""
    return self.position

home Link

home()

Performs axes homing procedure, setting axes position to their origin.

Source code in plantimager/dummy.py
114
115
116
def home(self):
    """Performs axes homing procedure, setting axes position to their origin."""
    self.position = [0., 0., 0.]

moveto Link

moveto(x, y, z)

Move axes to target XYZ position.

Parameters:

Name Type Description Default
x float

The target XYZ position, in millimeters.

required
y float

The target XYZ position, in millimeters.

required
z float

The target XYZ position, in millimeters.

required
Source code in plantimager/dummy.py
125
126
127
128
129
130
131
132
133
134
135
136
def moveto(self, x: float, y: float, z: float):
    """Move axes to target XYZ position.

    Parameters
    ----------
    x, y, z : float
        The target XYZ position, in millimeters.
    """
    self.position[0] = float(x)
    self.position[1] = float(y)
    self.position[2] = float(z)
    self.wait()

moveto_async Link

moveto_async(x, y, z)

Move axes to target XYZ position.

Parameters:

Name Type Description Default
x float

The target XYZ position, in millimeters.

required
y float

The target XYZ position, in millimeters.

required
z float

The target XYZ position, in millimeters.

required
Source code in plantimager/dummy.py
138
139
140
141
142
143
144
145
146
147
148
def moveto_async(self, x: float, y: float, z: float):
    """Move axes to target XYZ position.

    Parameters
    ----------
    x, y, z : float
        The target XYZ position, in millimeters.
    """
    self.position[0] = float(x)
    self.position[1] = float(y)
    self.position[2] = float(z)

start Link

start(homing=False)

Start the CNC.

Parameters:

Name Type Description Default
homing bool

If True, performs homing procedure.

False
Source code in plantimager/dummy.py
 98
 99
100
101
102
103
104
105
106
107
108
109
def start(self, homing=False):
    """Start the CNC.

    Parameters
    ----------
    homing : bool
        If ``True``, performs homing procedure.
    """
    if homing:
        self.home()
    else:
        pass

Gimbal Link

Gimbal(homing=False, pan_lims=[0.0, 360.0], tilt_lims=[-90.0, 90.0])

Bases: AbstractGimbal

A dummy Gimbal for testing purposes.

Attributes:

Name Type Description
position list

The current pan and tilt positions of the gimbal.

pan_lims ((float, float), optional)

The allowed range of pan-axis positions. Defaults to [0., 360.]

tilt_lims ((float, float), optional)

The allowed range of tilt-axis positions. Defaults to [-90., 90.]

Examples:

>>> from plantimager.dummy import Gimbal
>>> gimbal = Gimbal()
>>> gimbal.get_position()
[289.8, 55.43]
>>> gimbal.moveto(90, 10)
>>> gimbal.get_position()
[90.0, 10.0]
>>> gimbal.home()
>>> gimbal.get_position()
[0.0, 0.0]

Parameters:

Name Type Description Default
homing bool

If True, axes homing will be performed upon CNC object instantiation.

False
pan_lims (float, float)

The allowed range of pan-axis positions. Defaults to [0., 360.]

[0.0, 360.0]
tilt_lims (float, float)

The allowed range of tilt-axis positions. Defaults to [-90., 90.]

[-90.0, 90.0]
Notes

If homing is false, a random initial position will be generated.

Source code in plantimager/dummy.py
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
def __init__(self, homing=False, pan_lims=[0., 360.], tilt_lims=[-90., 90.]):
    """
    Parameters
    ----------
    homing : bool, optional
        If ``True``, axes homing will be performed upon CNC object instantiation.
    pan_lims : (float, float), optional
        The allowed range of pan-axis positions. Defaults to ``[0., 360.]``
    tilt_lims : (float, float), optional
        The allowed range of tilt-axis positions. Defaults to ``[-90., 90.]``

    Notes
    -----
    If `homing` is false, a random initial position will be generated.
    """
    super().__init__()
    self.pan_lims = pan_lims
    self.tilt_lims = tilt_lims
    self.position = self._random_position()
    self.start(homing)

get_position Link

get_position()

Returns the pan & tilt position of the Gimbal.

Source code in plantimager/dummy.py
232
233
234
def get_position(self) -> list:
    """Returns the pan & tilt position of the Gimbal."""
    return self.position

home Link

home()

Performs axes homing procedure, setting axes position to their origin.

Source code in plantimager/dummy.py
224
225
226
227
def home(self):
    """Performs axes homing procedure, setting axes position to their origin."""
    self.position = [0., 0.]
    return

moveto Link

moveto(pan, tilt)

Move the pan & tilt axes to given position.

Source code in plantimager/dummy.py
236
237
238
239
240
def moveto(self, pan: deg, tilt: deg):
    """Move the pan & tilt axes to given position."""
    self.position[0] = float(pan)
    self.position[1] = float(tilt)
    self.wait()

moveto_async Link

moveto_async(pan, tilt)

Move the pan & tilt axes to given position.

Source code in plantimager/dummy.py
245
246
247
248
249
def moveto_async(self, pan: deg, tilt: deg):
    """Move the pan & tilt axes to given position."""
    self.position[0] = float(pan)
    self.position[1] = float(tilt)
    return

start Link

start(homing=False)

Start the Gimbal.

Parameters:

Name Type Description Default
homing bool

If True, performs homing procedure.

False
Source code in plantimager/dummy.py
206
207
208
209
210
211
212
213
214
215
216
217
218
def start(self, homing=False):
    """Start the Gimbal.

    Parameters
    ----------
    homing : bool
        If ``True``, performs homing procedure.
    """
    if homing:
        self.home()
    else:
        pass
    return

stop Link

stop()

Stop the Gimbal.

Source code in plantimager/dummy.py
220
221
222
def stop(self):
    """Stop the Gimbal."""
    pass