Brief description of the interface¶
The core functions of Mikado can be called up via the fieldbus interface. A distinction is made between general functions and functions for controlling a loaded Mikado program.
General functions
Carry out the hand-eye calibration.
Functions for controlling a Mikado program
Start and stop the Mikado program or an individual sequence within the Mikado program.
The synchronization of Mikado variables with the PLC.
General communication process¶
Communication is realized by means of commands (see Commands) that are sent from the PLC to Mikado. The status of the communication is described using status bits (see Communication status). The following process description applies to all commands. The condition for communication is OutReadyBit = 1 from Mikado, which is set when Mikado and camera are ready.
Time |
SPS |
Mikado |
|---|---|---|
\(<t_1\) |
Wait for Wait for Set parameters |
Waiting on command |
\(t_1\) |
Set Wait for |
|
\(t_2\) |
|
|
\(t_3\) |
Reset Wait for |
|
\(t_4\) |
Write
|
|
\(t_5\) |
Reading Wait for |
|
\(t_6\) |
Reading Read variables if necessary |
|
If a command is set (
InCmd\(\neq\)0), Mikado responds withOutBusyBit = 1and first resets theOutErrorCode. The PLC responds toOutBusyBit = 1withInCmd = 0and then waits forOutBusyBit = 0.The PLC evaluates the
OutErrorCode. If this has the value 0, the command has been executed successfully.Depending on the command, the
OutRunningBit = 1and signals that Mikado has been started and is processing the current program. If theOutRunningBit = 0, theOutErrorCodeand the corresponding output variables can be read out.
Communication status¶
LifeBit¶
A LifeBit is used to check the status of communication between Mikado and the PLC. The PLC reads the value of OutLifeBit and writes it unchanged to InLifeBit. The fieldbus adapter reads the value of InLifeBit and writes the negated value to OutLifeBit. If the value of OutLifeBit does not change regularly, communication is considered interrupted and a corresponding error is displayed in the Mikado status.
Mikado status¶
The status of Mikado is transmitted to the PLC using three different bits. The following table summarizes the meaning of the individual bits.
Name |
Explanation |
Value |
|---|---|---|
|
Status of the fieldbus adapter. |
True = Command is processed. False = Adapter is ready to accept new command |
|
System status of Mikado. |
True = Mikado ready for operation False = Mikado not ready |
|
Program status of Mikado |
True = Mikado program is running (corresponds to green or yellow in Mikado) False = program is not running (corresponds in Mikado: orange, red or grey) |
Note
New commands are only accepted if OutBusyBit = False
Synchronizing PLC variables and Mikado variables¶
PLC variables can be mapped to Mikado variables and vice versa. The mapping between PLC variables and Mikado variables can be adapted and extended in the Mikado Assistant under “Interfaces”. Corresponding setup pages are available for the various supported communication protocols (ADS, Profinet). The standard fieldbus configuration of newly created cells contains all the necessary entries for executing the commands.
Assistant for adapting the word assignment and synchronized Mikado variables via fieldbus¶
The fieldbus configuration is saved in the configuration file config/profinet.yaml or config/ads.yaml. The file is structured as follows:
inputs: # list of synchronized variables PLC -> Mikado
- name: <VariableID> # internal unique ID
type: <VariableType> # type of variable, e.g. Bool, Double, Pose, ...
# Mikado address:
mikadoVarName: <VariableNameMikadoSide> # variable name in Mikado as stated on Edit>Variables page
# Fieldbus address:
word: <AddressProfinetSide> # only applicable for profinet variables
bit: <AddressProfinetSide> # only applicable for profinet variables of type 'Bool'
remoteName: <VariableNameAdsSide> # only applicable for ads variables
- ...
outputs: # list of synchronized variables Mikado -> PLC
- ...
All names of synchronized variables mentioned in this documentation refer to <VariableID>. If, for example, the variable InSequenceID is mentioned, it is assumed that the configuration file used contains an entry name: InSequenceID.
Rotation convention¶
The rotation convention defines how the orientation of poses is transferred to the interface or read from the interface. The orientation is always specified in the form of Euler angles, which can be interpreted in different ways depending on the convention (see below).
The rotation convention is specified as a combination of four letters: r (relative, intrinsic, rotated coordinate system) or s (static ,extrinsic, fixed coordinate system) followed by the order of the three rotation axes x/y/z. This theoretically results in 24 different combinations in which the orientation of poses can be represented in Euler angles.
The following table lists the rotation conventions for some robot manufacturers. The convention must be set to match the robot used in the Mikado Assistant under the “Interfaces” tab so that the alignment of poses can be interpreted correctly.
Mikado uses the convention rxyz (roll-nick-yaw / RPY) as standard. If this convention is selected, the Mikado poses are passed on to the interface unchanged. If a different setting is selected, the rotation part of a pose is converted by the interface into the corresponding format.
ID |
Convention |
Robot manufacturer |
R1 |
R2 |
R3 |
|---|---|---|---|---|---|
0 |
rxyz |
(Standard) Stäubli |
X (Roll) |
Y’ (Nick/Pitch) |
Z’’ (Gier/Yaw) |
1 |
sxyz |
Fanuc Yaskawa Motoman Universal Robots Fruitcore Mitsubishi Techman |
X (A) |
Y (B) |
Z (C) |
2 |
rzyx |
Kuka ABB Nachi |
Z (A) |
Y’ (B) |
X’’ (C) |
3 |
rzyz |
Doosan Kawasaki Omron |
Z |
Y’ |
Z’’ |
Error codes¶
The output word OutErrorCode encodes error messages. The following table summarizes all possible error codes and explains their meaning.
Code |
Error name |
Description |
|---|---|---|
0 |
|
Command successful |
>0 |
Error in the Mikado program |
Error in the Mikado program. For details see Mikado program |
-100 |
|
Unexpected error occurred |
-1 |
|
Call failed |
-2 |
|
Incorrect data type |
-3 |
|
Requested index not available |
-4 |
|
No return value received |
-5 |
|
Number of return values higher than expected |
-6 |
|
Called Mikado program has caused an error or left the sequence in an invalid state. |
-7 |
|
Specified (result) index outside the value range |
-8 |
|
unknown command received |
-9 |
|
Lifebit of the client was not recognized. Outputs are not updated in this state. |
-11 |
|
Execution of a Mikado sequence failed |
-12 |
|
Mikado variable could not be read (does the variable exist in the currently loaded Mikado program?) |
-13 |
|
Mikado variable could not be written (does the variable exist in the currently loaded Mikado program?) |
-15 |
|
Aborting an already started calibration failed |
-16 |
|
Recording for ongoing calibration not successful |
-17 |
|
Calculate and save calibration was not successful |
-18 |
|
Calibration could not be started |
-19 |
|
Requested sequence does not exist |
-20 |
|
Fieldbus configuration does not contain a required entry |
Commands¶
All commands have at least OutErrorCode as a return value. Some commands have additional input and return values. The additional input and return values are listed in the detailed description of the commands, if they exist.
Note
The input values must be present on the fieldbus before the command is set so that they can be taken into account. The return values are present on the fieldbus as soon as OutBusyBit == 0 and the configuration file contains the corresponding entries (see Synchronizing PLC variables and Mikado variables).
The following table lists all available commands:
|
Command name |
Description |
|---|---|---|
0 |
|
Waiting |
Program specific commands |
||
1 |
Start/continue Mikado program |
|
2 |
Start a sequence. SequenceID must first be set for this |
|
3 |
Stop process after execution of the current task |
|
4 |
Stop the Mikado program |
|
5 |
Stop Mikado program and reset all variables and states in the Mikado |
|
General commands |
||
8 |
Start hand-eye calibration |
|
9 |
Triggers image acquisition and measurement of the calibration pattern |
|
10 |
Calculate and save hand-eye calibration |
|
11 |
Sets the pose of the robot flange in Mikado |
|
Program specific commands¶
Program-specific commands refer to the current Mikado program and can only be executed if a program is loaded. These commands have no additional return values. The desired results depend on the implementation in the Mikado program and are communicated individually via the synchronized variables (see Synchronizing PLC variables and Mikado variables).
Conversely, the behaviour of the Mikado program can be influenced via the fieldbus by using synchronized variables as inputs for tasks in the Mikado program. It should be noted that a synchronized variable used as task input in the Mikado program sequence is read out at the time of task execution. Therefore, synchronized variables on the PLC side should only be changed if no Mikado program is running.
Note
To avoid errors in the program sequence, synchronized variables on the PLC side should only be changed if no Mikado program is running (OutRunningBit = 0).
RunMikadoProg¶
This command is used to start or continue the current Mikado program. After successful execution of the command, the RunningBit = True changes and signals the running Mikado program. As soon as this is reset by Mikado, the synchronized variables can be evaluated.
StartSequence¶
This command executes the Mikado sequence with the ID stored in the word SequenceID. From program version 3, the ID of a sequence can be set in the text field to the right of the sequence name. In earlier program versions, the sequence name must be the same as the ID sent, for example the integer “42”.
After successful execution of the command, the RunningBit = 1 changes and signals the running Mikado program. As soon as this is reset by Mikado, the synchronized variables can be evaluated.
Input value |
Return value |
||
|---|---|---|---|
|
ID of the sequence to be started |
none |
|
PauseMikadoProg¶
This command pauses the execution of the current program.
StopMikadoProg¶
This command stops the execution of the current program.
ResetMikadoProg¶
This command stops the execution of the current program and resets the status of the program and all variables.
General Commands¶
General commands can be executed independently of the Mikado program. The return values are at the address defined in the configuration file as soon as OutBusyBit == 0.
StartCalib¶
This command starts the hand-eye calibration.
Input value |
Return value |
||
|---|---|---|---|
|
ID of the camera to be used |
none |
|
|
Switch on the light during calibration? |
||
CaptureCalib¶
This command is used to collect poses for hand-eye calibration. The calibration process must have been started beforehand using the StartCalib command. Between 10 and 20 poses should be collected. This command must therefore be executed frequently.
Input value |
Return value |
||
|---|---|---|---|
|
Current pose of tool0 |
none |
|
Example procedure:
Robot strikes a pose
PLC writes the current flange pose (tool0) to
InPoseThe command
CaptureCalibis triggeredMikado reads the current robot pose from
InPoseand takes a picture
FinishCalib¶
This command is used to calculate the hand-eye calibration. This is the last step in the hand-eye calibration process. This takes place after a sufficient number of collected pattern poses with the help of CaptureCalib.
Input value |
Return value |
||
|---|---|---|---|
none |
|
Maximum pose error distance |
|
|
Mean pose error distance |
||
|
Mean pose error x |
||
|
Mean pose error y |
||
|
Mean pose error z |
||
|
Mean pose error angle |
||
readPoseAndPublishTool0¶
Note
This command is generally only used for select cells.
This command reads in a pose transmitted by the PLC and sets it in Mikado as the current pose of the robot flange (tool0). The position of the robot during image acquisition must be known for the Mikado program sequence, whereby Mikado Select itself has no information about the robot status. It is not necessary to use this command for hand-eye calibration, as the CaptureCalib command already performs the same functions in the background.
Input value |
Return value |
||
|---|---|---|---|
|
Current pose of tool0 |
none |
|
Example sequence for select cells¶
The example program select_findObjects.program is used below to show how a Mikado program can be controlled via the fieldbus. The sample program can be found in the program library from Mikado version 2.1.
- Prerequisites:
A product list must be loaded that contains a product with the name
P_0.A scene must be loaded that contains an ROI with the name
ROI_0.
# |
SPS |
Mikado |
|---|---|---|
Only for mobile camera: Set robot pose (for static camera continue directly with #3) |
||
1 |
Set Set |
|
2 |
Adopts the values in |
|
Find objects |
||
3 |
Set Set Set Set |
|
4 |
Start sequence with ID = 1 (Find objects) Set End of the sequence: |
|
Communicate results |
||
5 |
Lese Set Set Set |
|
6 |
Start sequence with ID = 2 (get Result) Set End of the sequence: |
|
7 |
Lese Set Set Set |
|
8 |
repeat step 6 |
|
9 |
repeat step 5 with |
|
10 |
Lese Set Set Set |
|
11 |
repeat step 6 |
|
12 |
Lese |
|
Updates¶
Version 3.1.0¶
(mikado-profinet v3.1.0, mikado_io_beckhoff v3.1.0)
Note
If PLC-side value changes are made at program runtime, unexpected behavior may occur with this version.
The new fieldbus adapter version brings the significant innovation that synchronized variables are constantly updated. In previous versions, variables had to be updated with the syncAll command. This change has the following consequences:
The user-defined live property of variables no longer applies because all variables are now “live”.
The
syncAllcommand is superfluous and is therefore no longer listed in this documentation. The command can still be sent. TheOutErrorCodereturned in this case isNoError.If PLC-side value changes are made at program runtime, unexpected behavior may occur.
The following table shows an example of how PLC-side changes can lead to unexpected behavior at an inopportune time. Assume a program is loaded in Mikado that calls the task Find Sceneobject, among others. The synchronized variable InBoxID is used as task input.
Time |
SPS |
Mikado |
Comment |
|---|---|---|---|
\(t_1\) |
Set
InBoxID = 42Set
InCmd = 1 (start program) |
PLC sets the variable |
|
\(t_2\) |
OutBusyBit = 1OutRunningBit = 1OutBusyBit = 0 |
Adapter executes command
Mikado starts program
Command execution completed
|
|
\(t_3\) |
InBoxID = 0 (false)InCmd = 0 |
This is an unfavorable time. Variables used in the program sequence should not be changed at runtime. |
|
\(t_4\) |
Program calls |
Mikado has now arrived at the task call. The current |
|
\(t_5\) |
|
End of program reached |
|
\(t_6\) |
|
The right time to reset variables. |