Robots in Architecture Forum

KUKA|prc - parametric robot control for Grasshopper => Support => Topic started by: avishek on July 26, 2021, 01:57:15 PM

Title: KUKA_IIWA_Digital_IO_Error
Post by: avishek on July 26, 2021, 01:57:15 PM
Hello Johannes,

I was trying to send out a digital output signal to KUKA IIWA 14 R820 through grasshopper and encountered an error ( DIGOUT Error.PNG).
Can you please tell me how to resolve this error? Do I need to declare the iogroup at some place in the RunXML or RunUDP file ?

I have attached the screenshots from grasshopper and the error from the pendant.

thanks
Avishek
Title: Re: KUKA_IIWA_Digital_IO_Error
Post by: Johannes @ Robots in Architecture on July 26, 2021, 05:11:53 PM
Hello,

Sorry, there is no way to troubleshoot it from the screenshot, it just says that there is an object is null.
Did you reference your IO Group when setting up the communicator in Sunrise? If that is null, it would explain the error.

Best,
Johannes
Title: Re: KUKA_IIWA_Digital_IO_Error
Post by: avishek on July 26, 2021, 05:15:32 PM
Hi,

I did not know that IO Group had to be referenced. Now I have added this line to the communicator setup :
MediaFlangeIOGroup iogrp = new MediaFlangeIOGroup(kuka_Sunrise_Cabinet_1);
that seems to solve the problem for now. Is that all ?

Thanks
Title: Re: KUKA_IIWA_Digital_IO_Error
Post by: Johannes @ Robots in Architecture on July 26, 2021, 05:18:25 PM
I hope so :)

Best,
Johannes
Title: Re: KUKA_IIWA_Digital_IO_Error
Post by: avishek on July 27, 2021, 10:33:43 AM
Hi Johannes,

In the present scope of KUKA|prc, is there any way to read the current state of IOs of iiwas ?

Thanks
Title: Re: KUKA_IIWA_Digital_IO_Error
Post by: Johannes @ Robots in Architecture on July 27, 2021, 05:06:52 PM
Hello,

Not at the moment, though technically it's of course no problem at all.
If you look into the UDPSender.java you see that what it sends is basically...
return (new Integer(CmdQueue.size()).toString()) + "," + posstr + "," + cartstr + "," + forcevector;

The least needed data here is probably the forcevector string, which consists of...
String forcevector = df.format(force.getX()) + "," + df.format(force.getY())+ "," + df.format(force.getZ());

So instead of force.getX() you could get an IO state - just take care to turn it into a number, not "TRUE" or "FALSE" as a string.
In Grasshopper you could then just translate it back.

Best,
Johannes
Title: Re: KUKA_IIWA_Digital_IO_Error
Post by: avishek on July 28, 2021, 12:24:16 PM
Hi Johannes,

I have tried to take in account your suggestion and facing some trouble to get the IO States as force vector outputs. I have put a placeholder boolean and converted to a double and that value can be read in Grasshopper, so that works.
But when I am trying to pass/store the boolean value, read from the media flange, the program does not seem to work. I have followed the code structure in the UDPSender.java to modifiy the CollectPayload() function but the error is coming there. I am attaching a modified UDPSender.java file in the post. Could you please have a look and tell me where is it going wrong?

Thank you
Title: Re: KUKA_IIWA_Digital_IO_Error
Post by: Johannes @ Robots in Architecture on July 28, 2021, 05:42:51 PM
I haven't worked with an iiwa properly in a while, but my guess would be that you are instantiating the IO-Group once when the program starts and once in your thread.
Rather construct it once in the base program and then pass a reference to the thread through its constructor.
Also, maybe IOs just aren't threadsafe. What error message are you getting?

Best,
Johannes
Title: Re: KUKA_IIWA_Digital_IO_Error
Post by: avishek on July 30, 2021, 12:05:25 PM
Hi,

If I am using line 83, then I am getting this. Please see the attached image.

Thanks
Title: Re: KUKA_IIWA_Digital_IO_Error
Post by: Johannes @ Robots in Architecture on July 30, 2021, 12:23:20 PM
I guess that's the same problem as before, right?
Maybe try stepping through the code to see whether the entire IOGroup is null or just that method is causing problems. Also, try to run your code in the main program to see whether it's thread-related.
Best,
Johannes
Title: Re: KUKA_IIWA_Digital_IO_Error
Post by: avishek on July 30, 2021, 12:30:59 PM
In this case, the problem looks the same but last time RunUDP was running and when I was trying to pass a Digital IO then I was facing the problems. But now after enabling the line 83, I am getting the error while running RunUDP itself and the program is shutting down. I will try to run it in the main code and see what happens then.

Avishek
Title: Re: KUKA_IIWA_Digital_IO_Error
Post by: avishek on August 13, 2021, 10:52:57 AM
Hi Johannes,

With limited knowledge of Java and threading we have tried whatever we could to get the state of IO in the vector list. But with all the modifications we have done so far, we could not make it work and runUDP always gives an erros.
If you get some time, would you be kind enough to have a look at the issue?

Thank you
Avishek
Title: Re: KUKA_IIWA_Digital_IO_Error
Post by: Johannes @ Robots in Architecture on August 13, 2021, 12:43:54 PM
Hello,

Have you asked KUKA whether you can read/write outputs from a separate thread? If it's a fundamental limitation, then we cannot do anything anyway and need to move the logic into the main thread.
If you post your current code (both the main .java file where you initialize everything as well as the RunUDP.java file) I can of course also take a look at the code.

Best,
Johannes
Title: Re: KUKA_IIWA_Digital_IO_Error
Post by: avishek on August 16, 2021, 01:37:59 PM
Hi Johannes,

I am attaching the two files here the UDPSender and the RunUDP. In the RunUDP @ line 74 I have declared the default MediaFlange IO and in UDPSender @ line 83 I have tried to read one of the pin. In this state if I run the RunUDP, it fails and gives the error I had posted last time.
It will be great if you have a look and help us to find a way to read the IOs in Grasshopper. Meanwhile we will try to talk to KUKA.
Thank you

Avishek
Title: Re: KUKA_IIWA_Digital_IO_Error
Post by: Johannes @ Robots in Architecture on August 17, 2021, 08:12:02 AM
Hello,

Did you try passing the IO group via the constructor? So that UDPSender looks a bit like that:


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;
}


Currently you always recreate the IO group in the while loop:
flangeIO = new MediaFlangeIOGroup(cabinet);

Best,
Johannes
Title: Re: KUKA_IIWA_Digital_IO_Error
Post by: avishek on August 17, 2021, 09:20:49 AM
Hi,

I have not tried this bit. Let me try and get back to you.

Thanks
Avishek
Title: Re: KUKA_IIWA_Digital_IO_Error
Post by: avishek on August 17, 2021, 10:37:43 AM
Hi Johannes

I have done the changes you had suggested and subsequently had to change the PRC_UDP.java. So the present changes alongwith your suggestions look like this
public void CORE_UDP(LBR robot, Controller kuka_Sunrise_Cabinet_1, SpatialObject tool, String tcpname, ObjectFrame baseFrame, boolean enablelogging, ITaskLogger logger, IApplicationData AppData, MediaFlangeIOGroup ioGroup, String ip, int port) throws SocketException, UnknownHostException {

//movement parameters
double ptpacc = 1.0;
double ptpint = 4.0;
double linacc = 1000;
double linint = 4.0;

UDPInput = new LinkedBlockingQueue<PRC_CommandData>();


if (ioGroup != null){
digiogroup = new PRC_IOGroupExtended(ioGroup, kuka_Sunrise_Cabinet_1, PRC_Enums.DIGOUT);
aniogroup = new PRC_IOGroupExtended(ioGroup, kuka_Sunrise_Cabinet_1, PRC_Enums.ANOUT);
}

tool.attachTo(robot.getFlange());
actTCP = tool.getFrame(tcpname);

udprec = new UDPReceiver(UDPInput);
                // modified line
udpsend = new UDPSender(InetAddress.getByName(ip), port, UDPInput, ioGroup);


So far the code runs flawlessly and does not give any error. I can move, change digiIOs and read data back into GH. Now I need to pass the IO states through CollectPayload in order to read in GH.

Can you suggest what to do next here ?

Thanks

Avishek
Title: Re: KUKA_IIWA_Digital_IO_Error
Post by: avishek on August 17, 2021, 11:57:15 AM
Hey

Done!

Thanks a lot. We should send a box of chocolate to Linz actually

Avishek
Title: Re: KUKA_IIWA_Digital_IO_Error
Post by: Johannes @ Robots in Architecture on August 17, 2021, 10:15:46 PM
Sorry for the delay, today was a busy day!
Great to hear that it worked out, no chocolates necessary :)

Best,
Johannes