Ask Your Question
1

ubuntu 16.04 boot from launch file

asked 2017-11-06 20:05:27 -0500

owen.yang gravatar image

I have a robot to install Ubuntu 16.04 now, want to boot a launch file, but tried a lot of methods effect is not ideal, used to start in the /etc/rc.local file, Su firefly -c "/etc/init.d/start_ros.sh" after the start, without any operation of the nodes, and the use of robot_upstart, URI and hostname cannot be specified for master, if you can provide effective the method, thank you very much

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2017-11-11 00:12:59 -0500

clyde gravatar image

updated 2017-11-13 12:20:58 -0500

Another option is to use systemd. A simple example:

Contents of /lib/systemd/system/robot.service:

[Unit]
Description=My Robot

[Service]
User=root
ExecStart=/home/me/catkin_ws/src/robot/scripts/start_robot.sh

[Install]
WantedBy=multi-user.target

Contents of /home/myaccount/catkin_ws/src/robot/scripts/start_robot.sh:

bash -c "source /home/me/catkin_ws/devel/setup.bash && roslaunch robot robot.launch"

Then use systemctl to control it:

sudo systemctl start robot.service # start
sudo systemctl stop robot.service # stop
sudo systemctl enable robot.service # start on boot
sudo systemctl disable robot.service # disable start on boot

(Edit to add some debugging notes.)

Note that you can set "User=<any user="">." Debugging will be easier if you can use your typical login. Of course, you should never use root unless you absolutely have to.

Debugging a boot-time launch can be annoying, since you need to rely on logging. I typically use roslaunch --screen from the command line to develop and debug, then move to manual start/stop to do system tests, then only when when I'm ready to do a full end-to-end test do I enable start at boot.

A few tricks for debugging:

Set output="log" on all nodes. (The default is output to log, so you can just remove the output="screen" option as well.) This will send all ROS_INFO messages to log files so that they don't clutter up the systemd logs.

Add stdbuf -oL to your command line invocations:

bash -c "source /home/myaccount/catkin_ws/devel/setup.bash && stdbuf -oL roslaunch robot robot.launch"

This will flush the output buffers after every line so that you see log messages quickly.

To see errors, run systemctl status robot.service. To see ROS_INFO messages, run tail -f ~/.ros/log/latest/mynode-*-stdout.log".

edit flag offensive delete link more

Comments

Thank you for your advice, I follow the tutorial to try, but still failed, my ros system, installed under the non-root user, do not know what effect this.

owen.yang gravatar image owen.yang  ( 2017-11-12 19:53:02 -0500 )edit

I added a few notes on debugging. If you provide more info it'll be easier to diagnose the problem.

clyde gravatar image clyde  ( 2017-11-13 12:21:42 -0500 )edit

sudo systemctl status robot.service,this is output. enter code here● robot.service - My Robot Loaded: loaded (/lib/systemd/system/robot.service; enabled; vendor preset: en Active: failed (Result: exit-code) since 二 2017-11-14 09:30:10 CST; 54s ago Main PID: 828 (code=exited, status=203/EXEC)

owen.yang gravatar image owen.yang  ( 2017-11-13 19:39:00 -0500 )edit

I see ~/.ros/log/latest/mynode-*-stdout.log,there is not log file.So I can not provide more information, if I can, I can send you an email describing my complete operation

owen.yang gravatar image owen.yang  ( 2017-11-13 19:45:33 -0500 )edit
0

answered 2017-11-08 15:00:09 -0500

Wolf gravatar image

updated 2017-11-10 00:58:05 -0500

This is the purpose of robot_upstart package:

http://wiki.ros.org/robot_upstart

I tested it and For me it worked quite nice. It sets Up a service that automatically starts your launch file as the machine is started. The doc can be found here:

http://docs.ros.org/jade/api/robot_up...

Edit in reply to comment:

See the doc of the install script for HowTo set ROS_MASTER and HOST_NAME:

http://docs.ros.org/jade/api/robot_up...

An important NOTE for the use of the --interface option of the install script is that the interface you bind it to (e.g. eth0) has to be up before the service running your roslaunch file is started. This means that you have to configure it using the /etc/network/interfaces file and not using the NetworkManager. If you only configure it using the NetworkManager it will be up to late and the ROS connection won't work.

edit flag offensive delete link more

Comments

Thand you .robot_upstart how to set ROS_MASTER_URI and ROS_HOSTNAME param. I use robot_upstart can't set this param . I use a command of 'rosrun robot_upstart install -- master http:192.168.168.169:11311 command_android/launch/start_command.launch',but this launch file is't sucess

owen.yang gravatar image owen.yang  ( 2017-11-09 19:22:59 -0500 )edit

I use a command of 'rosrun robot_upstart install --interface wlp3s0 -- master http:192.168.168.169:11311 command_android/launch/start_command.launch',and How do I configure this/etc/network/interfaces file,

owen.yang gravatar image owen.yang  ( 2017-11-12 19:46:49 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2017-11-06 20:05:27 -0500

Seen: 1,123 times

Last updated: Nov 13 '17