Ask Your Question
0

How to run roscore or roslaunch when i boot

asked 2018-05-07 20:04:52 -0600

jo gravatar image

updated 2018-05-08 04:34:30 -0600

gvdhoorn gravatar image

I'm using ubuntu 16.04 LTS and Ros Kinetic version.

How to run roscore or roslaunch automatically when i boot .

i tried add script /etc/init.d and /etc/rc.local , but they didn't work.

How can i do ?


Edit: Thank you for your answer.

I follow your advise using systemd.

but i have some error with this method like this.

 5월 08 17:56:00 Jo startup.sh[3794]: lcd: cannot connect to X server
 5월 08 17:56:00 Jo startup.sh[3794]: [lcd-2] process has died [pid 3868, exit code 1, cmd /home/jo/catkin_ws/devel/lib/lcd/lcd __name:=lcd __log:=/root/.ros/log/a1512d42-529d-11e8-a4c9-00012957ec7a/lcd-2.log].
 5월 08 17:56:00 Jo startup.sh[3794]: log file: /root/.ros/log/a1512d42-529d-11e8-a4c9-00012957ec7a/lcd-2*.log
 5월 08 18:03:39 Jo systemd[1]: Started start roslaunch.

what can i do ?

edit retag flag offensive close merge delete

3 Answers

Sort by » oldest newest most voted
0

answered 2018-05-29 20:45:18 -0600

jo gravatar image

I solved this problem using robot_upstart_pkg.

But they didn't work UI program. Only normal node.

Thanks for your answer !

Ah. robot_upstart_pkg is create service file automatic as a BhanuKiran.Chaluvadi's answer.

edit flag offensive delete link more
3

answered 2018-05-08 03:30:01 -0600

BhanuKiran.Chaluvadi gravatar image

updated 2018-05-08 03:31:22 -0600

I am using systemd . Here are the few links that helped me

  1. create a systemd service

  2. I am trying to launch lidar on boot, hence i also need some port permission/or available sequence and here is link that might help

Here is how my both service and .sh file look like

Service

[Unit]
Description=start roscore
After=remote-fs.target
After=syslog.target
[Service]
ExecStart=/usr/local/bin/rosCoreService.sh
Restart=on-abort

[Install]
WantedBy=multi-user.target

.sh file

#!/bin/bash
source /home/bc/.bashrc
source /opt/ros/kinetic/setup.bash
source /home/bc/catkin_ws/devel/setup.bash
roslaunch multitower_rplidar rplidar.launch

some of them might not be needed but i don't know which of them are.

edit flag offensive delete link more
1

answered 2018-05-08 00:33:33 -0600

updated 2018-05-08 00:35:55 -0600

Here are the steps:

  1. Make a new script file lets take startup.sh.
  2. Before calling the roscore and roslaunch in startup file, the ros environment should be sourced, so source the environment by addiing source /opt/ros/<distro>/setup.sh or . /opt/ros/<distro>/setup.sh
  3. Now you can add the ros command in the startup file like roscore or roslaunch. if directly roscore or rolaunch does not work launch this command from the ros/<distro>bin by adding the line /opt/ros/<distro>/bin/roscore.
  4. Give executable permission to file sudo chmod 755 /etc/init.d/startup.sh

Note: make sure while creating the new file you add #!/bin/sh in the first line.

edit flag offensive delete link more

Comments

1

Thanks for your answer.

Here add my ~~.sh

#!/bin/bash cd $home

source /opt/ros/kinetic/setup.bash roslaunch ros_tutorials_topic union.launch

exit 0

but it didn't work at boot. It's cannot even do.

my .sh file root is /home/username and my pkg root is /home/username/catkin_ws/src/

jo gravatar imagejo ( 2018-05-08 00:45:35 -0600 )edit

I have written a simple script, you can modify it according to your requirement. #!/bin/sh filename="/home/username/boot_log"_$current_time.txt echo "logging started" >> $filename . /opt/ros/indigo/setup.sh roscore >> $filename sleep 1 #/opt/ros/indigo/bin/roscore 2>&1 >> $filename &

simbha gravatar imagesimbha ( 2018-05-08 06:08:11 -0600 )edit

Thanks. using init.d , It has very many errors in my pc. so i used systemd method. Thanks for your interest and help. :)

jo gravatar imagejo ( 2018-05-08 06:25:32 -0600 )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

1 follower

Stats

Asked: 2018-05-07 20:04:52 -0600

Seen: 2,411 times

Last updated: May 29 '18