Ros program boot from start _ros

Source: Internet
Author: User
In the PC that controls the robot, when the embedded system starts, the ROS program is often required to boot up. The SAM has tried several methods and is now logged as follows:
1. Ros Official method: Robot_upstart:the Robot_upstart package provides scripts which may be used Toinstall and uninstall Ubuntu Lin UX upstart jobs which launch groupsof roslaunch files.
Therefore, this method may only support Ubuntu Linux. It provides scripte to install and uninstall a randomly activated Ros job. You can use Roslaunch and so on.
1.1: Installation (Indigo-ros): $sudo apt-get Installros-indigo-robot-upstart
1.2: Set up a package launch file to boot. Launch:sam has a package:beacool_bringup, which has a. launch file----beacool_bringup/launch/ Minimal.launch $rosrun Robot_upstartinstall Beacool_bringup/launch/minimal.launch Here are easy to come up with the following questions: A. Launch File not found: A1: Make sure the package_name/launch/directory is correct. A2: Make sure ROSCD package_name can enter. (Note: Source~/catkin_ws/devel/setup.bash has been effective)
Another point to note is the log:preparing to install files to the following paths:/etc/init/beacool.conf/etc/ros/indigo/beacool.d/.instal Led_files
At this point, when Ubuntu starts, this launch will be invoked.
1.3: Other key information: 1.3.1:service Name: Service Name: Package name part, in the above example, Package_name:beacool_bringup. So the service name is: Beacool
1.3.2: Stop boot up: rosrun robot_upstart Uninstall service name Rosrun Robot_upstart Uninstall Beacool
1.3.3:service start and stop: sudo service beacool start sudo service beacool stop
1.3.4: Look at Log:sudo vi/var/log/upstart/beacool.log
There are many places on the web that describe this part of the work: it's not clear where the service name comes from. Bring a lot of misunderstanding. So the service name is marked in red.


2. Use Linux desktop system to boot up program: Different Linux desktop system, boot start is not the same. Ubuntu Practical GNOME Desktop system. It uses the startup application to set up a random boot. can also be entered in the terminal: gnome-session-properties to boot. Other desktop system counterpart software is not necessarily the same: for example kde----Systemsettings->system Administration->startup and Shutdown


As you can see, Sam uses this tool to start the calculator. How can the ROS program start? In fact, the idea is very simple, is to run a terminal program, the terminal program runs a script, this script set up Ros, activate the ROS application.
Sam wants to start. Launch is: Beacool_bringup in the package minimal.launch so create a startup script as follows: #! /bin/bash source/opt/ros/indigo/setup.sh Source/home/exbot/devel/setup.bash roslaunch Beacool_bringup Minimal.launch

Second: In the Launch program's command list, use: Gnome-terminal-x/home/exbot/catkin_ws/beacool_ros/beacool_run.sh



Each time the system starts, it opens a terminal window and executes the launch in the script.
This method is useful under most ubuntu+ros. But it didn't work under the Tk1ubuntu. I don't know what's going on for a while.


3. Linux Classic mode, boot service: First introduction background knowledge: Linux startup, you can start some service. Sam was a long time ahead of Linux set-top boxes, Android set-top boxes. Many programs are started in service form. 3.1: How to create a service: A: In the/etc/init.d/directory, create a script to start. For example, name: Beacool_rfkill This script is used to start Bluetooth. The contents are as follows: Rfkill unblock bluetooth
B: Add the script to the service: $CD/etc/init.d $sudo update-rc.d beacool_rfkill defaults 95 at this point, the script Beacool_rfkill is added to the/etc/rcx.d/directory. X:0-6, respectively, representing different startup levels. 3 is started for the character interface and 5 for the GUI. Other not key. The script name becomes in/etc/rc3.d/: the S95beacool_rfkill command, and the last digit indicates the start order.
C: If you want to remove this service: $ cd/etc/init.d
$ sudo update-rc.d-f beacool_rfkill remove
The 3.2:ros program starts with service: To see if the script is valid, you can view the log. Sam made the following action in the script: Roslaunch beacool_nav amcl_demo.launch >>/home/ubuntu/catkin_ws/src/beacool.log 2>&1 So, The log is sent to the specified directory. Log as follows:/etc/rc2.d/s96dashgo_launch:1:/etc/rc2.d/s96dashgo_launch:roslaunch:not found This indicates that Ros did not join the environment variable. The environment variables need to be set up first. See the following notation:. /opt/ros/indigo/setup.sh. /home/ubuntu/catkin_ws/devel/setup.sh Roslaunch Beacool_bringupminimal.launch
There is a drawback to this approach: if there are multiple Ros projects to join, for example: one of them is S98 and the other is S99. Then the S98 will be executed. And S99 was not executed. Although it can also be performed in the background, it causes the previous exit.
So if you have to take this approach: You can combine multiple launch. (Not recommended)

4. The rc.local of simple violence (a more problematic approach):/etc/rcx.d/contains/etc/init.d/rc.local. It's usually the last moment to join, for example: s99rc.local and it references/etc/rc.local so it's easy to add the call before exit 0 of/etc/rc.local.
For example: Sam wants to join a ROS project: Beacool_bringup's minimal.launch. A: Create a script first:. /opt/ros/indigo/setup.sh. /home/ubuntu/catkin_ws/devel/setup.sh Roslaunch Beacool_bringupminimal.launch Please note: The source/opt/ros/indigo/is not used at this time Setup.bash. Instead, use. /opt/ros/indigo/setup.sh is because bash is not started at this time, and source is bash internal command. Source is not found at this time.
B: Modify its permissions: sudo chmod 777 beacool_launch
C: Join rc.local:/etc/init.d/beacool_launch

This approach has a similar disadvantage to approach 3:1. After joining, if the ROS program does not exit, then the blockage is here. This means that if you want to start multiple launch. The next will not be executed. 2. Of course, a friend will say, you can perform backstage. /etc/init.d/beacool_launch& But if a launch is left behind, the ROS project initiated by the front beacool_launch will exit.
So if you have to take this approach: You can combine multiple launch. (Not recommended)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.