ROS systemd service terminating itself

Hello,

I am trying to automatically start MAVROS on boot according to the tutorial (https://docs.emlid.com/navio2/common/dev/ros/).

Running roslaunch mavros apm.launch manages to launch without any issue. I created a systemd service using the exact same configuration as given, and enabled it on boot.

When powering on the drone it connects successfully but I realized that it is disconnecting / reconnecting continously after about 1.5 minutes. By removing the restart-on=failure I can see that it fails with the following log output:

â—Ź ros.service - ros
   Loaded: loaded (/etc/systemd/system/ros.service; enabled; vendor preset: enabled)
   Active: deactivating (final-sigterm) (Result: timeout)
Cntrl PID: 399 (bash)
   CGroup: /system.slice/ros.service
           └─499 /usr/bin/python /opt/ros/kinetic/bin/roslaunch mavros apm.launch

Oct 16 06:20:28 navio bash[399]: [ERROR] [1539670828.329754664]: FCU: PreArm: Throttle below Failsafe
Oct 16 06:20:58 navio bash[399]: [ERROR] [1539670858.324944037]: FCU: PreArm: RC Roll not configured
Oct 16 06:20:58 navio bash[399]: [ERROR] [1539670858.326239893]: FCU: PreArm: Compass not calibrated
Oct 16 06:20:58 navio bash[399]: [ERROR] [1539670858.327425704]: FCU: PreArm: Compass not calibrated
Oct 16 06:20:58 navio bash[399]: [ERROR] [1539670858.328863895]: FCU: PreArm: check firmware or FRAME_CLASS
Oct 16 06:20:58 navio bash[399]: [ERROR] [1539670858.330039811]: FCU: PreArm: Throttle below Failsafe
Oct 16 06:21:07 navio systemd[1]: ros.service: Start operation timed out. Terminating.
Oct 16 06:21:07 navio systemd[1]: Failed to start ros.
Oct 16 06:21:07 navio systemd[1]: ros.service: Unit entered failed state.
Oct 16 06:21:07 navio systemd[1]: ros.service: Failed with result 'timeout'.
Oct 16 06:21:07 navio bash[399]: process[mavros-2]: started with pid [549]
Oct 16 06:21:07 navio bash[399]: [mavros-2] killing on exit
Oct 16 06:21:07 navio bash[399]: [rosout-1] killing on exit
Oct 16 06:21:07 navio bash[399]: [master] killing on exit
Oct 16 06:21:07 navio bash[399]: shutting down processing monitor...
Oct 16 06:21:07 navio bash[399]: ... shutting down processing monitor complete
Oct 16 06:21:07 navio bash[399]: done
Oct 16 06:21:07 navio bash[399]: Unhandled exception in thread started by
Oct 16 06:21:07 navio bash[399]: sys.excepthook is missing
Oct 16 06:21:07 navio bash[399]: lost sys.stderr

Image and ardupilot version (from emlidtool):
Info

Vendor: Emlid Limited
Product: Navio 2
Issue: Emlid 2018-06-05 831f3b08594f2da17dccae980a2e3659115ef71f
Kernel: 4.14.34-emlid-v7+
RCIO firmware: 0xb09979ae

Ardupilot Info

On boot enabled: ['arducopter']
Arducopter - active (running)
Version: arducopter-3.5
Frame: arducopter

/etc/systemd/system/ros.service

[Unit]
Description=ros

[Service]
Type=forking
ExecStart=/bin/bash -c "source /opt/ros/kinetic/setup.bash; /usr/bin/python /opt/ros/kinetic/bin/roslaunch mavros apm.launch"

[Install]
WantedBy=multi-user.target

Any help greatly appreciated!

Hi @tobiasfriden,

Try to add TimeoutSec=infinity string in [Service].

@tatiana.andreeva thank you, this seems to have resolved the crashing.

However the service seems to never reach active state, after clearly starting everything it is still reporting Active: activating (start) since Wed 2018-10-17 06:38:59 UTC; 5min ago.

Is this expected?

@tobiasfriden,

Seems like forking type isn’t the right choice for this kind of service. Change it to simple and service will keep active (running).

This works fine, thanks! Maybe it should be changed in the documentation?

1 Like

@tobiasfriden,

Glad to hear it helps!

We’ll fix it in our docs in the nearest time. Thanks for noticing!

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.