10.2. actuator#
This section contains the script reference to the class actuator, used to access any actuator or motor hardware in itom. Read the overview document for more details about the Python interface of the class actuator.
- class itom.actuator(name, *args, **kwds)#
Creates a new instance of the actuator plugin
name
.This is the constructor for an
actuator
plugin. It initialises an new instance of the plugin with the givenname
. The initialisation parameters are parsed and unnamed parameters are used in their incoming order to fill first mandatory parameters and afterwards optional parameters. Parameters may be passed with their name as keyword, too. However, as usual, no positional parameters are allowed after a keyword-based one.See
pluginHelp()
for detailed information about the specific initialisation parameters.- Parameters:
- name
str
is the fullname (case sensitive) of an
actuator
-plugin.- *args
Any
Every
actuator
plugin defines a list of mandatory and optional initialization parameters. Pass these arguments either as positional (*args
) or keyword based (**kwds
) arguments, where the mandatory parameters must be given first, followed by the optional ones. Not every optional initialization argument must be given, else its default value is used.- **kwds
Any
Further keyword based parameters. See also
*args
.
- name
- Returns:
actuator
new instance of the desired actuator plugin.
- calib(axisIndex1, *args)#
Starts a calibration or homing routine of one or multiple axes.
Most actuators have the possibility to calibrate or home certain axes. Use this command to start the calibration.
- Parameters:
- Raises:
NotImplemented
if calibration routine not available in this plugin.
- connect(signalSignature, callableMethod, minRepeatInterval=0)#
Connects a signal of this actuator with the given callable Python method.
Every
actuator
object can emit different signals whenever a certain event occurs. Use the methodinfo()
to get a print-out of a list of possible signals of the actuator. This method is used to connect a certain callable Python callback method or function to a specific signal. The callable function can be bounded as well as unbounded.The connection is described by the string signature of the signal (hence the source of the connection). Such a signature is the name of the signal, followed by the types of its arguments (the original C++ types). An example is
targetChanged(QVector<double>)
, emitted whenever the target position of one or multiple axes changed. This signal can be connected to a callback function, that accepts one argument (in case of a bounded method, theself
argument must be an additional first parameter.The C++ datatype
QVector<double>
will be transformed totuple of float
, for more type conversions see the table in section Supported data types. In general, acallableMethod
must be a method or function with the same number of parameters than the signal has (besides theself
argument). The types are converted based on the itom C++ <-> Python conversion table (Supported data types).If a signal is emitted very often, it can be necessary to limit the call of the callback function to a certain minimum time interval. This can be given by the
minRepeatInterval
parameter.- Parameters:
- signalSignature
str
This must be the valid signature, known from the Qt-method connect (e.g.
targetChanged(QVector<double>)
)- callableMethod
callable()
valid method or function that is called if the signal is emitted.
- minRepeatInterval
int
,optional
If > 0, the same signal only invokes a slot once within the given interval (in ms). Default: 0 (all signals will invoke the callable python method.
- signalSignature
See also
- disconnect(signalSignature, callableMethod)#
Disconnects a connection which must have been established before with exactly the same parameters.
- Parameters:
- signalSignature
str
This must be the valid signature, known from the Qt-method connect (e.g.
clicked(bool)
)- callableMethod
callable()
valid method or function, that should not be called any more if the given signal is emitted.
- signalSignature
- exec(funcName, *args, **kwds) Any | Tuple[Any] #
Calls the additional function
funcName
of this plugin.Every plugin can define special, additional functions (denoted as
exec functions
) that can for instance be used in order to call specific calibration routines of cameras or actuators. This generic method is used to call one of these specific functions, that has to be registered in the plugin under the namefuncName
.Every function can define a set of mandatory and / or optional parameters. See
getExecFuncsInfo()
or the plugin help viewer of itom for more information. Pass the mandatory and optional parameters as argumentsparam1
,param2
… to this method.Additionally, every function can return one or multiple values. Either the single value or a tuple of all returned values is returned by this method.
- Parameters:
- funcName
str
The name of the additional function.
- *args
Any
Further positional arguments, that are assigned first to all mandatory parameters, followed by the optional ones. The mandatory or optional parameters of the called function can also given as keyword arguments (see
**kwds
).- **kwds
Any
,optional
Keyword-based arguments, see
*args
above.
- funcName
- Returns:
See also
- getExecFuncsInfo(funcName='', detailLevel=0) dict | None #
Lists all available additional functions of this plugin or gives a detailed description of one specific
funcName
.Every plugin can define further functions, that are called by the method
exec()
. This can for instance be used in order to call specific calibration routines of cameras or actuators.This method either prints requested information in a readable form to the command line or returns this information as nested dictionary.
- Parameters:
- funcName
str
,optional
is the fullname or a part of any name of such an additional plugin function. If
funcName
is an empty string or does not match any plugin function (case sensitive), a list of all suitable additional plugin function names is given. Else, detailed information about the desiredfuncName
is given, like its description or (optional) arguments that are needed to execute this function.- detailLevel
dict
,optional
if
detailLevel == 1
, this returns a nested dictionary with detailed information, else it is printed to the command line in a readable form (default).
- funcName
- Returns:
See also
- getExecFuncsList() List[str] #
Gets a list of the names of additional callable functions of this plugin.
Each plugin may define a set of functions, extending the standard interface. These functions are not common to plugins of the same type. They are executed using:
instance.exec("funcname", arg1, arg2, ...)
To get more information about one specific function, call
getExecFuncsInfo()
.
- getParam(name) int | float | str | Tuple[int] | Tuple[float] | dataObject | polygonMesh | pointCloud | dataIO | actuator #
Returns the current value of the plugin parameter
name
.The type of the returned value depends on the real type of the internal plugin, which can be:
String ->
str
Char, Integer ->
int
Double ->
float
DataObject ->
dataObject
PolygonMesh ->
polygonMesh
PointCloud ->
pointCloud
The
name
of the parameter must have the following form:name
name:additionalTag (
additionalTag
can be a special feature of some plugins)name[index] (only possible if parameter is an array type and you only want to get one single value, specified by the integer index
[0, len(array) - 1]
)name[index]:additionalTag (a combination of the two possibilities above)
- Parameters:
- name
str
Name of the requested parameter.
- name
- Returns:
int
orfloat
orstr
ortuple
of
int
ortuple
of
float
ordataObject
orpolygonMesh
orpointCloud
ordataIO
oractuator
Current value of the parameter
name
.
- Raises:
ValueError
if parameter does not exist
See also
- getParamInfo(name) dict #
Returns a nested dictionary with meta information of the desired parameter.
Plugin parameters in itom not only hold a value, but they can also be equipped with further meta information, like the minimum or maximum value range, a certain step size, allowed string values etc.
These values are returned as nested dictionary (if available, else the dict is more or less empty).
- getParamList() List[str] #
Returns a list of the names of all available parameters of this plugin object.
Each plugin defines a set of parameters. Each of these parameters maps its
name
to a certainvalue
. The value is represented by the C++ classito::ParamBase
and can have one of the following types (Python equivalent in brackets):String (str)
Char (int, [-127, 128])
Integer, (int)
Double (float)
CharArray (sequence of int)
IntegerArray (sequence of int)
DoubleArray (sequence of float)
DataObject (
dataObject
)PolygonMesh (
polygonMesh
)PointCloud (
pointCloud
)
Using one of the parameter names, its current value can be obtained by
getParam("name")
and can be set bysetParam("name", newValue)
(if not read-only).Usually, every plugin object can define its own set of parameters. However, there are conventions about certain parameters, that must be available and have a specific meaning for a type of plugin object.
See also
- getParamListInfo(detailLevel=1) dict | None #
Prints or returns detailed information about all parameters of this plugin object.
Each plugin defines a set of parameters. Each of these parameters maps its
name
to a certainvalue
. The value is represented by the C++ classito::ParamBase
and can have one of the following types (Python equivalent in brackets):String (str)
Char (int, [-127, 128])
Integer, (int)
Double (float)
CharArray (sequence of int)
IntegerArray (sequence of int)
DoubleArray (sequence of float)
DataObject (
dataObject
)PolygonMesh (
polygonMesh
)PointCloud (
pointCloud
)
Using one of the parameter names, its current value can be obtained by
getParam("name")
and can be set bysetParam("name", newValue)
(if not read-only).This method prints a detailed listing with the
name
, current value, description string and further meta information of every plugin parameter. Additionally, the columnR/W
indicates if this parameter is writable or read-only.Dependin`g on
detailLevel
, this method will not print the listing to the command line but returns it using a nesteddict
.- Parameters:
- detailLevel
dict
,optional
if
detailLevel
is set to1
, this method returns a nested dictionary with all information about all parameters of this plugin. OtherwiseNone
is returned and the listing is printed in a readable form to the command line (default).
- detailLevel
- Returns:
See also
- getPos(axisIndex1, *args) float | Tuple[float] #
Returns the current position(s) of the given axis or axes (in mm or degree).
This method requests the current position(s) of the given axes and returns it or them.
- Parameters:
- Returns:
- getStatus(axis=-1) int | List[int] #
Returns the status for one single axis or all axes of the actuator object.
Each axis of an actuator plugin has got a status value that is used for informing about the current status of the axis.
The status value is a bitmask (flag), that might contain a combination of the following values:
Moving flags:
actuatorUnknown = 0x0001 : unknown current moving status
actuatorInterrupted = 0x0002 : movement has been interrupted by the user or another error during the movement occurred
actuatorMoving = 0x0004 : axis is currently moving
actuatorAtTarget = 0x0008 : axis reached the target position
actuatorTimeout = 0x0010 : timeout during movement. Unknown status of the movement
Switches flags:
actuatorEndSwitch = 0x0100 : axis reached any end switch (e.g. if only one end switch is available)
actuatorEndSwitch1 = 0x0200 : axis reached the specified left end switch (if set, also set actuatorEndSwitch)
actuatorEndSwitch2 = 0x0400 : axis reached the specified left end switch (if set, also set actuatorEndSwitch)
actuatorRefSwitch = 0x0800 : axis reached any reference switch (e.g. for calibration…)
actuatorRefSwitch1 = 0x1000 : axis reached the specified right reference switch (if set, also set actuatorRefSwitch)
actuatorRefSwitch2 = 0x2000 : axis reached the specified right reference switch (if set, also set actuatorRefSwitch)
Status flags:
actuatorAvailable = 0x4000 : the axis is available
actuatorEnabled = 0x8000 : the axis is currently enabled and can be moved
actuatorError = 0x10000 : axis has encountered error/reports error
- getType() int #
Returns the type value of this actuator plugin (always: 0x2).
- Returns:
int
actuator type value (
0x2
).
- hideToolbox()#
Hides the visible toolbox of this plugin object.
- Raises:
RuntimeError
if this plugin does not provide a toolbox.
See also
- info(verbose=0)#
Prints out information about signal and callable slots of this actuator.
- Parameters:
- verbose
int
0: only slots and signals from the plugin class are printed (default) 1: all slots and signals from all inherited classes are printed
- verbose
See also
- name() str #
Returns the name of this plugin object.
- Returns:
- name
str
name of the plugin, which corresponds to
getParam("name")
- name
See also
- setInterrupt()#
Request the interruption of the movement of this actuator.
Sets the interrupt flag of the
actuator
. The actuator interrupts the movement of all running axes as soon as this flag is checked and handled again.
- setOrigin(axisIndex1, *args)#
Defines the current position of the given axes to have the value
0
.The current positions of all indicated axes (
axisIndex1
,*args
) are considered to be0
such that future positioning commands are relative with respect to this current position.- Parameters:
- Raises:
NotImplemented
if actuator does not support this feature
- setParam(name, value)#
Sets a writeable parameter
name
of this plugin object tovalue
.Sets the internal plugin parameter with ‘name’ to a new value. The plugin itself can decide whether the given value is accepted as new value. This may depend on the type of the given value, but also on the allowed value range indicated by further meta information of the internal parameter. Parameters that are (currently) set to read-only cannot be set.
The
name
of the parameter must have the following form:name
name:additionalTag (additionalTag can be a special feature of some plugins)
name[index] (only possible if parameter is an array type and you only want to get one single value, specified by the integer index [0,nrOfArrayItems-1])
name[index]:additionalTag (a combination of the two possibilities above)
- Parameters:
- name
str
Name of the parameter.
- value
int
orfloat
orstr
ortuple
of
int
ortuple
of
float
ordataObject
orpolygonMesh
orpointCloud
ordataIO
oractuator
The
value
that will be set. The plugin will check if thisvalue
fits to possible constraints, given by the parameters’s meta information or further limitations.
- name
- Raises:
RuntimeError
if the new
value
is (currently) not accepted.
See also
- setPosAbs(axisIndex1, pos1, *args)#
Moves the given axis or axes to the indicated absolute position(s) (in mm or degree).
The parameters of this function are always alternating between the index of one axis and its new absolute target position as following parameter. As an example, moving the first three axes would look like:
myMotor.setPosAbs(0, 10.0, 1, -5.2, 2, 0.7) # axes 0, 1 and 2 are absolutely moved
This method starts the absolute positioning of all given axes. If the
async
parameter (seegetParam()
andsetParam()
) of the plugin is0
(usually default), a synchronous positioning is started, hence, this method returns after that all axes reached their target positions or a timeout occurred. Else, (async = 1
) this method immediately returns and the actuator continuous its movement.
- setPosRel(axisIndex1, offset1, *args)#
Moves the given axis or axes to the indicated relative position(s) (in mm or degree).
The parameters of this function are always alternating between the index of one axis and its new absolute target position as following parameter. As an example, moving the first three axes would look like:
myMotor.setPosAbs(0, 10.0, 1, -5.2, 2, 0.7) # axes 0, 1 and 2 are absolutely moved
This method starts the relative positioning of all given axes. If the
async
parameter (seegetParam()
andsetParam()
) of the plugin is0
(usually default), a synchronous positioning is started, hence, this method returns after that all axes reached their target positions or a timeout occurred. Else, (async = 1
) this method immediately returns and the actuator continuous its movement.- Parameters:
- showConfiguration()#
Shows the (optional) configuration dialog of this plugin as modal dialog.
- Raises:
RuntimeError
if this plugin does not provide a configuration dialog.
- showToolbox()#
Opens the (optional) toolbox of this plugin object in the itom main window.
- Raises:
RuntimeError
if this plugin does not provide a toolbox.
See also
- userMutexTryLock()#
tryLock(timeout = 3000) -> bool
Tries to lock the user mutex of this plugin.
Every plugin contains a user mutex, that can be used for arbitrary purposes. It is not used for any official purposes. You can for instance use this mutex both from Python and other C++ threads to protect a series of calls to this plugin to not to be interrupted by other participants. However, it is the full responsibility of the programmer to carefully use this mutex.
Please be careful, that this method can lead to a deadlock if
timeout
is set to a negative value (infinite wait) and if the mutex is not released by any other thread. Hint: A Python thread is no real thread, it must be a real C++ thread. If you want to use the mutex within two or more Python threads, it is recommended, to call this method with a definedtimeout
within a loop and wait for this method to returnTrue
. This allows unlocking the mutex by another thread.This method is new for plugins that implement the AddInInterface >= 4.2.
- Parameters:
- timeout
int
This method will wait for at most
timeout
milliseconds for the mutex to become available. If this value is negative, it will wait forever until the mutex become available.
- timeout
- Returns:
- bool
True
if the user defined mutex could be locked, elseFalse
.
See also
unlock
- userMutexUnlock()#
Tries to unlock the user mutex of this plugin.
Every plugin contains a user mutex, that can be used for arbitrary purposes. It is not used for any official purposes. You can for instance use this mutex both from Python and other C++ threads to protect a series of calls to this plugin to not to be interrupted by other participants. However, it is the full responsibility of the programmer to carefully use this mutex. fu This method is new for plugins that implement the AddInInterface >= 4.2.
See also
lock
- actuatorAtTarget = 8#
- actuatorAvailable = 16384#
- actuatorEnabled = 32768#
- actuatorEndSwitch = 256#
- actuatorEndSwitch1 = 512#
- actuatorEndSwitch2 = 1024#
- actuatorError = 65536#
- actuatorInterrupted = 2#
- actuatorMoving = 4#
- actuatorRefSwitch = 2048#
- actuatorRefSwitch1 = 4096#
- actuatorRefSwitch2 = 8192#
- actuatorTimeout = 16#
- actuatorUnknown = 1#
- currentPositions#
tuple of
float
: Gets the current positions (in mm or degree) of all axes.This property returns a tuple whose size corresponds to the number of axes of this actuator. The returned tuple contains the current positions of all axes (in mm or degree). This property is always updated if the plugin signals a change of any current position via the signal
actuatorStatusChanged
. Instead of reading this property, you can also connect to this signal in order to get instantly informed about new current positions.This property always returns immediately, however it only contains the last reported values which can slightly differ from the real current positions (if the plugin rarely emits its current states for instance due to performance reasons).
- currentStatus#
tuple of
int
: Gets the current status (flag mask, seegetStatus()
) of all axesThis property returns a tuple whose size corresponds to the number of axes of this actuator. The returned tuple contains the current positions of all axes (in mm or degree). This property is always updated if the plugin signals a change of any current position via the signal ‘actuatorStatusChanged’. Instead of reading this property, you can also connect to this signal in order to get instantly informed about new current positions.
The difference between this property and the method
getStatus()
is thatgetStatus
will only return if the actuator plugin is currently idle. This property always returns immediately, however it only contains the last reported values which can slightly differ from the real current positions (if the plugin rarely emits its current states for instance due to performance reasons).
- targetPositions#
tuple of
float
: Gets the target positions (in mm or degree) of all axes.This property returns a tuple whose size corresponds to the number of axes of this actuator. The returned tuple contains the current target positions of all axes (in mm or degree). This property is always updated if the plugin signals a change of any target position via the signal
targetChanged
. Instead of reading this property, you can also connect to this signal in order to get instantly informed about new target positions.This property always returns immediately, however it only contains the last reported values which can slightly differ from the real target positions (if the plugin rarely emits its current states for instance due to performance reasons).