Hello,
I've uploaded some code on GitHub that you can run on the Windows side of your KUKA robot, it can access KUKA variables through two DLLs that you need to get in the right version from your robot:
KukaRoboter.Common.XmlResources.dll
KukaRoboter.LegacyKrcServiceLib.dll
Make sure those DLLs are next to the EXE after building it. You could modify to also e.g. send the status of a digital input as well, so that you only save data when the button is pressed. If you are querying the Cartesian position (e.g. $POS_ACT.X, see commented out parts) note that a tool and base need to be set.
I did that a couple years ago and don't quite remember if you need to open ports in the KUKA's NAT settings for it. Could be.
In any case, do NOT change any network settings (firewall, IP etc.) on the Windows side of the robot, you've got a good chance of breaking things.
In Grasshopper, the plugin Firefly contains a UDP listener (note that it needs an attached Timer component to check for new data), though any other socket implementation will work as well. You could also use PacketSender to check if any data is arriving.
KUKAVarProxy does something very similar, it's just a bit more effort to get to the data:
https://github.com/ImtsSrl/KUKAVARPROXYJust note that this is beyond the standard scope of Grasshopper and you will see that it can be challenging dealing with real-time data in Grasshopper. We had to do quite a few workarounds for mxAutomation in how it handles incoming, cyclical data.
https://github.com/jbraumann/KUKA-UDP-SenderBest,
Johannes