A KUKA iiwa 14 R820 application can shut down when UDP communication code reads a media-flange I/O point through a null I/O-group object. The evidence-supported correction is to construct the MediaFlangeIOGroup during communicator setup and pass that same reference into UDPSender. Treat thread access as a separate, unconfirmed issue only if the failure remains.
Identify the null I/O-group failure
The pendant message establishes only that an object is null; it does not identify the object or prove that the requested I/O method is invalid. Check whether the complete I/O-group reference is null before investigating the individual pin-reading method. The reported application failed as soon as the I/O-reading line was enabled, making the I/O-group reference the first dependency to inspect.
Initialize and pass one MediaFlangeIOGroup reference
Create the media-flange I/O group in the main communicator setup, where the Sunrise cabinet reference is available:
MediaFlangeIOGroup iogrp = new MediaFlangeIOGroup(kuka_Sunrise_Cabinet_1);
Then accept that initialized object in the UDP sender constructor and assign it to the sender field:
public UDPSender(
InetAddress externaladdress,
int externalport,
BlockingQueue<PRC_CommandData> UDPQueue,
MediaFlangeIOGroup iogrp) throws SocketException {
socket = new DatagramSocket(30001);
address = externaladdress;
port = externalport;
CmdQueue = UDPQueue;
flangeIO = iogrp;
}
Do not repeatedly recreate the group inside the sender loop with new MediaFlangeIOGroup(cabinet). The reported communicator began working after the I/O group was referenced during setup.
Transfer the I/O state in the UDP payload
The existing payload is a comma-separated string containing queue size, position, Cartesian data, and a force vector. If an I/O state replaces one of the force-vector values, serialize it as a numeric value rather than the strings TRUE or FALSE, then translate the received number back to a Boolean state in Grasshopper.
return new Integer(CmdQueue.size()).toString()
+ "," + posstr
+ "," + cartstr
+ "," + forcevector;
Verify the correction and isolate threading
- Confirm that the communicator setup constructs the I/O group before creating
UDPSender. - Step through the program and verify that
iogrpat construction andflangeIOat the read operation are not null. - Run the UDP application and confirm that enabling the I/O-reading line no longer shuts it down.
- Verify that Grasshopper receives the numeric state and converts it to the expected Boolean value.
- If the reference is valid but the read still fails, move the same I/O operation into the main program. Success there but failure in the UDP thread indicates a possible thread-access limitation; the evidence does not confirm whether KUKA Sunrise I/O is thread-safe, so verify that behavior through official KUKA support.
FAQ
Why does KUKA RunUDP stop when I read a digital I/O?
The pendant error indicates that an object is null. Verify that MediaFlangeIOGroup is created during communicator setup and that its reference reaches UDPSender before the I/O read executes.
Where should I declare MediaFlangeIOGroup for UDPSender?
Construct it once in the main communicator setup with new MediaFlangeIOGroup(kuka_Sunrise_Cabinet_1), then pass the resulting object through the UDPSender constructor. Avoid constructing another group repeatedly inside the sender loop.
How do I send a KUKA iiwa Boolean I/O state to Grasshopper?
Convert the Boolean state to a numeric payload value instead of sending TRUE or FALSE as text. Parse that numeric value back into a Boolean state after Grasshopper receives the comma-separated UDP payload.