Question

I have a .m file (script) that is controlling a real-time robot.

What i do within this file is:

1- find a trajectory

2-infinite loop:

    read from robot
    update robot
    plot some stuff (basically I'm drawing a new point in each iteration that represents the position of the robot in a previously opened map, it's updating the map)

end of loop

What I want to do is to create a GUI that allows me to make the plots and see some values that the robot returns at the same time, in real time.

From what I read, MATLAB can't run both a script and a GUI at the same time.. I can make it plot in real time in the GUI but I can't seem to be able to update the values returned by the robot in text boxes in GUI..

Do I have to put it all in the same file or is there a way for the GUI and the script to work in separate files? Thank you in advance!

Was it helpful?

Solution

MATLAB has not trouble running both. I don't know where you read that but it's not true; MATLAB is not the best tool to solve this problem, but it can do it.

First, I'm going to frame your problem in code, to make it easier to solve. Your question is vague and general, so my response has to be be general as well. I'm making some assumption about your function structure, but it really should look a lot like this:

endflag = 0;
while ~endflag
    robotData = getRobotData(robotHandel);
    derivedData = doStuffWithData(robotData);
    updateRobot(derivedData);

    showData(robotData, derivedData)      

    endflag = checkEndFlag(robotData, derivedData)
end 

So, your problem is the showData functionality. What it should do, is determine which values need to be displayed from it's inputs, and pass those to your GUI. Like so:

function showData(robotData, derivedData)
    guiInputData = dataParser(robotData, derivedData)
    YourGUIFunctionName(guiInputData)
end

The GUI function should then build itself using those inputs. Any GUI function working that way, will do what you want it to. If you want a more specific solution, you need to give me more specific information about your problem. Good luck, I hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top