Accessing IIWA media flange using a thread in Sunrise workbench

Started by UofM FABLab, April 12, 2021, 10:52:07 PM

Previous topic - Next topic

UofM FABLab

Hello,

I am currently working on a project where a thread is used outside of the main application class in sunrise workbench to constantly cycle a stepper motor, while the main class goes about its functions.

I've run into a wall trying to access the media flange via the stepper thread in sunrise workbench. I am able to inject the media flange into the thread, but it throws an error when trying to set a pin.

Any advice/help would be greatly appreciated.

Jon

Johannes @ Robots in Architecture

Hello Jon,
Attached is a thread example, the following snippet passes a reference of the BlockingQueue to the thread:
public UDPReceiver(BlockingQueue<PRC_CommandData> UDPInput) throws SocketException {
        socket = new DatagramSocket(30000);
        UDPQueue = UDPInput;
    }

I would pass a reference to the IO group containing the media flange the same way and then see what happens!
Best,
Johannes

UofM FABLab

Thank you for your reply Johannes.

I've fidled around with the code you sent and I am still unsure on how to establish a relationship between the thread and the ioGroup/mediaFlange.

Would it look something like this?

public UDPReceiver(MediaFlangeIOGroup mediaFlangeIO) throws SocketException {
       socket = new DatagramSocket(30000);
        mediaFlange = mediaFlangeIO;
    }

I've essentially just changed the variable from your code to MediaFlangeIOGroup. How would I got about changing a pin status in this setup?

Thank you for your help.

Take care,
Jon

Johannes @ Robots in Architecture

Hello Jon,

I would also get rid of the "throws SocketException" part and the socket object - unless you need socket communication. Don't forget to define your mediaFlange object where previously the socket was defined.
The naming of the IOs is not really standardized, but you should be able to do something like mediaFlange.SetOutput1(true)

public void run() {
        running = true;
        while (running) {
            mediaFlange.SetOutput1(true)
        }
    }

I haven't worked with Sunrise in quite a while, but Sunrise Workbench should suggest the possible options anyway.
The code above would constantly set your output 1 to true, which is not terribly exciting.
Best,
Johannes

UofM FABLab

Hello Johannes,

This worked. To establish the connection, I had to include the MediaFlangeIOGroup in the constructor of the the thread and inject it.

Thank you very much for your help.

Jon

Johannes @ Robots in Architecture