Universal Robots Forum

How do I write to log_history.txt file?

Hello,

I am working on a program where I want to log suggested acceleration speed by writing to log_history.txt everytime the play button is pressed.

Any suggestions?

Hi Luan,

You can use the “textmsg(s1, s2=’ ')” function:
image

To add to the log file.

If you insert it into the preamble it will add every time you start the program pushing the play button.

Thank you!

It now writes the suggested acceleration in log_history.txt, but now I have a different problem.

It writes the acceleration multiple times. Everytime the program goes over the ProgramNodeContribution where I wrote the script in, it writes the acceleration in the log file. Is there a way to only make it write once?

I have tried inserting the script in InstallationNodeContribution, but I don’t know how to gain the specific data/datamodel the ProgramNodeContribution and Contribution has.

You don’t have access to ProgramNodes data model. You could program some logic so every program node only logs it the first time it is executed in that program executed.
I am not sure the overall target is completely clear to me yet.

Is there a way to gain access to ProgramNodes data model from InstallationNode? Or is there a way to make an EventListener on ursim/urcap playbutton?