Installation DataModel don't restore its values

Hello.

I’m trying to save some parameters in the DataModel on an installation urcap, and I noticed that (at least on the sim), when I shutdown it and restart it, I can’t get my values back.
Of course, I know that I have to save my installation via the “Load/Save” menu before restarting.

I tested it on easy sample, like model.set("FILES","coucou") and get back the value by model.get("FILES","")
Every thing is right working if I don’t shutdown the sim. (My program check in openView if I have something in the model, and it display it). But when I restart the getter return me the empty string.

Even weirder, by uncompressing the default.installation, I notice that the values are here.

(In case it’s not possible, I can get these infos by myself by parsing the .installation file, but in that case, I don’t know how to know which installation is loaded (if it’s not the default.installation). Anyone know how to retrieve that info ?)

Thank you for you help

1 Like

I doubt that there is a general issue in the SDK, because it works in our URCaps.
Without seeing your code it is hard to guess what’s wrong.
Have a look at the supplied HelloWorld sample and compare, what you do differently.

2 Likes

Thank you for confirming it is normally working.
I tried with the helloworld sample and it wasn’t working neither.
So I figured it is not working only when ursim was launch in sudo, but that everything is fine with a normal launch.
(I lanched it in sudo only because I need it to be able to start a daemon).

Thank you again for your help.

1 Like

URSim should be run as non-sudo.
Basically PolyScope checks if it is running in sudo, and if it does, it believes that it is on a real robot.
If running non-sudo, it will expect to be a simulator.

Differing from this might cause you performance issues, including e.g. wrong programs folder.

Indeed I noticed the wrong program folder but I only needed to create the /programs folder to solve the problem, and everything I tested ( except installation model restoring ) was working the right way.

But now I wonder if it’s possible to run a daemon without sudo?
Because even on the starter pack, the mydaemon sample always say “My Daemon failed”, and the only way I achieved to to make it work was to run Ursim as sudo.

1 Like

Just tryed on the newest version version of the starter-pack:
mydaemon sample Daemon won’t launch if not sudo. Also, still have to comment some part of the pom.xml to build it.

The building issue is related to the fact, that is requires the Cross Compiler tool chain to build the C++ daemon, and this can only run in native 64-bit Linux with Intel core - not in the starter package VM.

1 Like

I have basically the same issue: I can’t test saving the installation values when launching the sim with sudo, but the daemon won’t start if I don’t run the simulator with sudo.

Is there a workaround for that? Am I doing something wrong to start the daemon?
Thanks!

Hi,
You won’t be able to launch the deamon without sudo, but what you can do is “not lauching” the demon from the urcap ( just disable it ), and run it from own terminal, with the python command. I never tested it, but I read someone who did this. Also, as communications in urcaps are often made through xmlRPC, I’m confident that it would work.

Other advice I can give you is to isolate parts of your code that have to restore the model, so you can test it without the need to execute the daemon. When you are sure it’s working, test the all thing on the robot, and it should be ok. Always did like this, and as it’s generaly not the huge part of the dev job, it should be good enough.

:slight_smile:

Thanks for your reply! Yes, that should work too. For the record, to do so you should not register the service in the Activator, and avoid starting the daemon in the InstallationNodeContribution. Then, you can execute it as a normal python program, and everything works fine.
This should do for testing purposes, I was just curious about if something else could be done to save installation values when a program is not saved/ loaded.

I have the some problem when, after reboot, I try to retrieve parameters previously set in the DataModel (same behavior both in simulation and with the real robot).

I always retrieve them correctly if I save the current program before shutdown the robot (or the simulator). However, if I use somewhere in the code model_.set(...) and I do not save the program, I’m not able to retrieve the updated parameter after reboot (or just after reload the same program).

I don’t know if it is supposed to be like this, but if I do not interact with the GUI and my code update some parameters automagically, I’m not even able to save the program (only save as is available in that case). Moreover I’d like to store few parameters even if the user won’t save the program for any reason.

Is it possible to save automatically when rebooting?

Alessandro Tondo @qbrobotics

I think you can’t by normals ways.
When the user save his program, or his installation, it’s write in a file (xxx.urp, and xxx.installation).
I think the only way is by writing in there, but I doubt that it’s not recommended, in fact, I’m almost sure that we can’t know which installation/program we’re using, only to protect about these non-wanted modification. IMHO ( I’ll like to have a confirmations if someone know more about that :slight_smile: )

In general, the datamodel should be used for the settings given by the user in the URCap.
E.g. go to this waypoint, use this speed, do this many iterations. Hence settings given to generate the script code executed.
In this respect, it would not be assumed, that the datamodel is changed during regular program execution, and that is why the datamodel does not automatically save values stored, unless this is explicitly saved by the user.
Hence the user could e.g. make changes, but exit without saving is desired to revert.

1 Like

Thank you @mdi, and I see. I’m a bit disappointed though, but I believe I can store something with some nasty (i.e. unreliable) “write-to-file” workaround.
If I come up with something useful I’ll share with you.

edit: @jbm sorry, but I haven’t seen your answer before (just 3 mins before mine :wink:). Anyway I got the point and thank you for the clarification.

For e.g. usage data logging, or last state of something, this can definitely be stored to a file on disk.
E.g. in /home/ur/.urcapname
However do try to limit the number of writes to disk, e.g. only saving state every X minutes. Or if something changes very infrequently.

One more thing: the logs that I added to the URCap indicate that the InstallationNodeContribution is created twice. The first one always retrieves default values from the DataModel, and the second one is the one that is connected to the installation screen, so all the values you modify there are retrieved properly (if not using sudo). Does that happen to you too?

@jubeira See this thread: http://forum.universal-robots.com/t/polyscope-3-4-0-createinstallationnode-called-twice/623

Btw.: I do not need superuser-rights (sudo) in my simu to launch the daemons from my URCaps. It is a Linux Mint 17.3 64bit (running as a virtual machine) with SDK and URSim properly installed.

1 Like

Hi,

If you’re working with an installation file and want to know which installation is loaded or running at the moment, look at some indicators or configurations in your environment such as: Configuration Files, Environment Variables, Command Line Tools, Version Control Systems, Filesystem Inspection, Logging or Debugging Output, Documentation or Support Resources.

You ought to be able to figure out which installation is loaded or active right now in your environment by combining these methods. I hope you will get some clarification from this info.

You can also check this: Redirecting Minitab Training