Universal Robots Forum

[SOLVED] `DaemonContribution::start()` always ends in `ERROR`

Hi all,

I have a problem when starting MyDaemon example.
It turns out that when I click on the start button, the daemon ends in the ERROR state. Always. On the other hand, the stop() method works as expected.
The following is the only documentation that I found about the start():

Start the daemon. Will be ignored if daemon is in ERROR state. When issuing multiple start and/or stop commands within a short time frame only the latest will be effectuated. If called when the daemon is in the INITIALIZING state it will be invoked when the daemon is ready (unless it enters the ERROR state).

I would like to understand what could cause the ERROR state and why.

I am going to add some details in the following days.
Thank you for your time.

Alessandro Tondo @qbrobotics

I am sorry for the delay, but it was holiday in Italy.

I have tried to go into the deep and inspect the Java stack trace using Thread.currentThread().getStackTrace() from MyDaemonDaemonService.getExecutable(), which appears to be the one involved in the ERROR state setting.
Here is what I get when clicking on the start button:

com.ur.urcap.cpp.impl.MyDaemonDaemonService.getExecutable(MyDaemonDaemonService.java:31)
com.ur.urcap.view.impl.DaemonImpl.getExecutable(DaemonImpl.java:41)
com.ur.urcap.servicedaemon.impl.RUNITService.getExecutableHashCode(RUNITService.java:217)
com.ur.urcap.servicedaemon.impl.RUNITService.getDaemonIdentifier(RUNITService.java:213)
com.ur.urcap.servicedaemon.impl.RUNITService.getSymLinkPath(RUNITService.java:209)
com.ur.urcap.servicedaemon.impl.RUNITService.isRunning(RUNITService.java:173)
com.ur.urcap.view.impl.DaemonImpl.getState(DaemonImpl.java:81)
com.ur.urcap.cpp.impl.MyDaemonDaemonService.getDaemon(MyDaemonDaemonService.java:59)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.awaitDaemonRunning(MyDaemonInstallationNodeContribution.java:189)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.applyDesiredDaemonStatus(MyDaemonInstallationNodeContribution.java:176)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.onStartClick(MyDaemonInstallationNodeContribution.java:68)

The first DaemonImpl.getState() returns correctly in the STOPPED state.
Then, MyDaemonDaemonService.getExecutable() is called three times consecutively by DaemonImpl.start(), where it seems to retrieve and check the executable path and hash code:

com.ur.urcap.cpp.impl.MyDaemonDaemonService.getExecutable(MyDaemonDaemonService.java:31)
com.ur.urcap.view.impl.DaemonImpl.getExecutable(DaemonImpl.java:41)
com.ur.urcap.servicedaemon.impl.RUNITService.getExecutableHashCode(RUNITService.java:217)
com.ur.urcap.servicedaemon.impl.RUNITService.getDaemonIdentifier(RUNITService.java:213)
com.ur.urcap.servicedaemon.impl.RUNITService.getSymLinkPath(RUNITService.java:209)
com.ur.urcap.servicedaemon.impl.RUNITService.start(RUNITService.java:142)
com.ur.urcap.view.impl.DaemonImpl.start(DaemonImpl.java:70)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.awaitDaemonRunning(MyDaemonInstallationNodeContribution.java:189)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.applyDesiredDaemonStatus(MyDaemonInstallationNodeContribution.java:176)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.onStartClick(MyDaemonInstallationNodeContribution.java:68)


com.ur.urcap.cpp.impl.MyDaemonDaemonService.getExecutable(MyDaemonDaemonService.java:31)
com.ur.urcap.servicedaemon.impl.RUNITService.getExecutablePath(RUNITService.java:203)
com.ur.urcap.servicedaemon.impl.RUNITService.start(RUNITService.java:148)
com.ur.urcap.view.impl.DaemonImpl.start(DaemonImpl.java:70)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.awaitDaemonRunning(MyDaemonInstallationNodeContribution.java:189)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.applyDesiredDaemonStatus(MyDaemonInstallationNodeContribution.java:176)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.onStartClick(MyDaemonInstallationNodeContribution.java:68)


com.ur.urcap.cpp.impl.MyDaemonDaemonService.getExecutable(MyDaemonDaemonService.java:31)
com.ur.urcap.view.impl.DaemonImpl.getExecutable(DaemonImpl.java:41)
com.ur.urcap.servicedaemon.impl.RUNITService.getExecutableHashCode(RUNITService.java:217)
com.ur.urcap.servicedaemon.impl.RUNITService.start(RUNITService.java:148)
com.ur.urcap.view.impl.DaemonImpl.start(DaemonImpl.java:70)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.awaitDaemonRunning(MyDaemonInstallationNodeContribution.java:189)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.applyDesiredDaemonStatus(MyDaemonInstallationNodeContribution.java:176)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.onStartClick(MyDaemonInstallationNodeContribution.java:68)

Lastly, the following DaemonImpl.getState() returns in the infamous ERROR state (which persists until the stop button is clicked):

com.ur.urcap.cpp.impl.MyDaemonDaemonService.getExecutable(MyDaemonDaemonService.java:31)
com.ur.urcap.view.impl.DaemonImpl.getExecutable(DaemonImpl.java:41)
com.ur.urcap.servicedaemon.impl.RUNITService.getExecutableHashCode(RUNITService.java:217)
com.ur.urcap.servicedaemon.impl.RUNITService.getDaemonIdentifier(RUNITService.java:213)
com.ur.urcap.servicedaemon.impl.RUNITService.getSymLinkPath(RUNITService.java:209)
com.ur.urcap.servicedaemon.impl.RUNITService.isRunning(RUNITService.java:173)
com.ur.urcap.view.impl.DaemonImpl.getState(DaemonImpl.java:81)
com.ur.urcap.cpp.impl.MyDaemonDaemonService.getDaemon(MyDaemonDaemonService.java:59)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.awaitDaemonRunning(MyDaemonInstallationNodeContribution.java:191)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.applyDesiredDaemonStatus(MyDaemonInstallationNodeContribution.java:176)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.onStartClick(MyDaemonInstallationNodeContribution.java:68)

I know that this is a bit hard to read, but I cannot figure out how to get rid of this problem and I have almost tried everything I know.

For the sake of completeness, I am using sdk-1.0.0-23 and ursim-3.3.3 on Ubuntu 16.04 (but we have tried also with Ubuntu 14.04) and the urtool3 is properly installed (checked with dpkg -s urtool3).

The HelloWorld example obviously works as expected, like the Screwing URCap does. The problem is with the MyDaemon and with a simplified version of it where I tried to remove all the unnecessary elements.

Have you got any hints?

Thank you very much for your time,
Alessandro Tondo @qbrobtoics


Further Investigation:
The communication through RPC works like a charm if the executable is opened in a separate termianl. Nonetheless the initialization of the daemon seems not to be able to start the executable: I even modified the file permissions manually to make it executable by every user in the PC (chmod a+x file.py), but it is still not working it and continues to end in the ERROR state.

I have searched a bit more and I have found the urcap_tutorial.pdf in the sdk documentation, which says:

The /etc/service directory contains links to the URCap daemon executables currently running. If a daemon executable has a link present but is in fact not running, the ERROR state will be returned upon querying the daemon’s state. […] Log information with respect to the process handling of the daemon executable are saved together with the daemon executable (follow the symbolic link of the daemon executable in /etc/serice to locate the log directory).

I was hopeful to find the solution there, but as you could imagine the directory /etc/service stays empty before, during and after the execution of the URCap in the simulator. Nonetheless, it could not be otherwise since start-ursim.sh requires no root privileges.

I have also tried with sudo ./start-ursim.sh, but the simulator stuck on startup while searching something that it cannot find as root.

Could be a problem of privileges?
Does anyone has the same problem?

Alessandro Tondo @qbrobotics

Is runit correctly installed? Should be done by the install.sh, but sometimes the the installer quits before executing installDaemonManager() (e.g. when the java version check fails). If your /etc/service directory ist empty I would check this (there should exist a symlink pointing to /etc/runit/runsvdir-ursim-3.3.3)

Thank you very much @hch!

As you pointed out runit was not installed at all, probably because when I installed the simulator, the script crashed without advertise the failure.

I don’t know exactly what was wrong the first time but I’m going to describe here all the modifications that I have done to properly install the simulator and the SDK on Ubuntu 16.04.

Thank you again and hope this helps,
Alessandro Tondo @qbrobotics


Install URsim PolyScope 3.3.3.292 on Ubuntu 16.04

  1. open the install.sh in the ursim-3.3.3 directory;

  2. openjdk-6-jre is no more supported on Ubuntu 16.04; switch to openjdk-8-jre by renaming the proper field of commonDependencies (I cannot say that this has no drawbacks, it seems to work well though):

     commonDependencies='libcurl3 openjdk-8-jre ...'
    
  3. change the java version control accordingly (note the 1.8.0 instead of the 1.6.0):

     versionString=`java -version 2>&1 | head -n1 | grep 1\.8\.0`
     if [[ -z $versionString ]]
     then
             echo "Please select Java version 1.8 using update-alternatives"
             return
     fi
    
  4. [optional] if you have installed a non-english Ubuntu, probably your desktop directory is not called ~/Desktop. In such a case use something like this when creating the executable shortcuts or simply rename the path with your desktop directory name:

     # source the user directories for every language (then use $XDG_DESKTOP_DIR)
     source ~/.config/user-dirs.dirs
     # create launch files
     echo "Create shortcuts on the desktop"
     for TYPE in UR3 UR5 UR10
     do
     	FILE=$XDG_DESKTOP_DIR/ursim-$VERSION.$TYPE.desktop
     	...
    
  5. you are almost done, just open a terminal and type ./install.sh;

  6. [optional] if you have previously installed the URCaps SDK, you might force the dependencies installation with something like apt-get install -f;

  7. [optional] if you get stuck like me while installing runit, please follow this topic. In brief, you have to comment out the final part of /var/lib/dpkg/info/runit.postinst because it tries to call upstart which is no longer used in the newer Ubuntu releases, and than simply force the installation process (i.e. sudo apt-get install -f);

  8. [optional] if you get stuck on point 7, simply rerun ./install.sh again;

  9. if everything goes as expected you will find three executable shortcuts on your desktop.

Install URCaps SDK 1.0.0.23 on Ubuntu 16.04

  1. open the install.sh in the sdk-1.0.0-23 directory;

  2. [optional] if you have previously installed the simulator, you might force the debian installation at the end of the installer (i.e. use --force-all):

     sudo dpkg -i --force-all urtool/*.deb
    
  3. [important] check if the debian package has been installed correctly through dpkg -s urtool3. It should prompt something like this (be sure that the status is Status: install ok installed):

     Package: urtool3
     Status: install ok installed
     Priority: extra
     Section: non-free/misc
     Installed-Size: 196280
     Maintainer: Universal Robots A/S <rd@universal-robots.com>
     Architecture: amd64
     Version: 0.3
     Depends: lib32gcc1, libc6, libc6-i386, libncurses5, ant, libstdc++6, python (>= 2.6)
     Conffiles:
      /etc/ld.so.conf.d/urlib.conf 20bf058b0d358d20e8861ab1808f2189
      /etc/profile.d/urpath.sh 123b1ea1f7dca6f3ed144554caeb2d5b
     Description: Universal Robots A/S CB3.X cross-compiler toolchain.
      Universal Robots A/S Control Box generation 3.X cross-compiler toolchain,
      including among others: GCC, scons, boost, curl and libxmlrpc-c for robot
      software development purposes.
     Homepage: http://www.universal-robots.com
    

Disclaimer: THESE MODIFICATIONS ARE PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

6 Likes

@federico.baiamonte your work and your summary post was more than useful and great for me. Thank you

Matteo Timossi @recognitionrobotics

1 Like

hi, I hava a problem when starting start-ursim3.6

Use ‘apt autoremove’ to remove them.
0 upgraded, 0 newly installed, 0 to remove and 106 not upgraded.
(Reading database … 297655 files and directories currently installed.)
Preparing to unpack …/curl-dev-ur_7.18.2-1_amd64.deb …
Unpacking curl-dev-ur (7.18.2-1) …
dpkg: error processing archive /home/ur/ursim/ursim-3.6.0.30512/ursim-dependencies/curl-dev-ur_7.18.2-1_amd64.deb (–install):
trying to overwrite ‘/opt/urtool-3.0/share/man/man3/curl_multi_info_read.3’, which is also in package urtool3 0.3
dpkg-deb (subprocess): decompressing archive member: internal gzip write error: Broken pipe
dpkg-deb (subprocess): cannot copy archive member from ‘/home/ur/ursim/ursim-3.6.0.30512/ursim-dependencies/curl-dev-ur_7.18.2-1_amd64.deb’ to decompressor pipe: failed to write (Broken pipe)
dpkg-deb: error: subprocess returned error exit status 2
Preparing to unpack …/libxmlrpc-c-dev-ur_1.33.14_amd64.deb …
Unpacking libxmlrpc-c-dev-ur (1.33.14) …
dpkg: error processing archive /home/ur/ursim/ursim-3.6.0.30512/ursim-dependencies/libxmlrpc-c-dev-ur_1.33.14_amd64.deb (–install):
trying to overwrite ‘/opt/urtool-3.0/include/xmlrpc-c/abyss.h’, which is also in package urtool3 0.3
dpkg-deb (subprocess): decompressing archive member: internal gzip write error: Broken pipe
dpkg-deb (subprocess): cannot copy archive member from ‘/home/ur/ursim/ursim-3.6.0.30512/ursim-dependencies/libxmlrpc-c-dev-ur_1.33.14_amd64.deb’ to decompressor pipe: failed to write (Broken pipe)
dpkg-deb: error: subprocess returned error exit status 2
Preparing to unpack …/libxmlrpc-c-ur_1.33.14_amd64.deb …
Unpacking libxmlrpc-c-ur (1.33.14) …
dpkg: error processing archive /home/ur/ursim/ursim-3.6.0.30512/ursim-dependencies/libxmlrpc-c-ur_1.33.14_amd64.deb (–install):
trying to overwrite ‘/opt/urtool-3.0/lib/libxmlrpc_server.so.3.33’, which is also in package urtool3 0.3
dpkg-deb (subprocess): decompressing archive member: internal gzip write error: Broken pipe
dpkg-deb (subprocess): cannot copy archive member from ‘/home/ur/ursim/ursim-3.6.0.30512/ursim-dependencies/libxmlrpc-c-ur_1.33.14_amd64.deb’ to decompressor pipe: failed to write (Broken pipe)
dpkg-deb: error: subprocess returned error exit status 2
Errors were encountered while processing:
/home/ur/ursim/ursim-3.6.0.30512/ursim-dependencies/curl-dev-ur_7.18.2-1_amd64.deb
/home/ur/ursim/ursim-3.6.0.30512/ursim-dependencies/libxmlrpc-c-dev-ur_1.33.14_amd64.deb
/home/ur/ursim/ursim-3.6.0.30512/ursim-dependencies/libxmlrpc-c-ur_1.33.14_amd64.deb