Difference between revisions of "Remote Variable Access"
(Created page with "Variables are usually read and changed within a robot program. In case variables need to be set by a remote control either the CRI interface or the camera interface can be use...")
Revision as of 12:16, 1 July 2020
Variables are usually read and changed within a robot program. In case variables need to be set by a remote control either the CRI interface or the camera interface can be used, depending on the version of CPRog/iRC and TinyCtrl.
CRI Ethernet Interface
Main article and documentation: CRI_Ethernet_Interface Variables must be declared and defined in the running robot program in order to be accessed. That means the store command must have been called in the robot program before the variable value can be read or set using the CRI.
The CRI commands to read variables are supported in CPRog/iRC V902-11-007 and TinyCtrl V980-11-085 and newer:
The CRI commands to change variables are supported in CPRog/iRC V902-11-011 and TinyCtrl V980-11-088 and newer:
Please refer to the CRI documentation on how to use these commands.
If your version of CPRog/iRC or TinyCtrl does not support the SetVariable CRI commands the camera interface may be used to change variables. This is supported in CPRog/iRC V902-11-007 and TinyCtrl V980-11-085 and newer.
In order to use the camera interface you will need to program a TCP socket that simulates a IFM O2D camera by regularly sending values in the format specified below. CPRog/iRC or TinyCtrl then needs to be set up to connect to that socket and query the camera interface in the robot program.
Create a TCP socket at a port of your choice (eg. 50010) that regularly sends messages in the following format: 0000start<status>#<ignored>#<ignored>#<model class>#<x coord>#<y coord>#<rotation>#<ignored>stop
|<status>||PASS / FAIL, if FAIL the model class will be -1 and the coordinates will be ignored|
|<x coord>||x value (integer) + 320|
|<y coord>||y value (integer) + 240|
|<rotation>||A value (float)|
Open the camera configuration (File -> Configure Interfaces -> Cameras), select IFM O2D and click Add Camera.
- Check the enabled box
- Set the IP address and port of your TCP socket
- Set ScaleX and ScaleY to 1 or lower if you need more precision
- Set Origin to (0, 0, 0)
- Set Look to (0, 0, 1)
- Set Up to (1, 0, 0)
Then save your project with the button below. TinyCtrl must be connected to update its configuration.
Query values in robot program
In order to read the values in the robot program the Camera command must be used. The x, y and A values will be written into the target position variable and the model class will be written to the model class number variable. If you need x, y, z coordinates you may use the Math-Set command to copy the A value to the z element.