Ros Startup Scripting _ Robot

Source: Internet
Author: User

The use of ROS to develop a robot, in the use of the time to first connect the machine to the network and then roslaunch too much trouble, according to the product of the idea is to press the power button on OK. In addition, if there is a host computer connected to the state monitoring, in case the main program hangs, or modify the program to recompile operation, the host computer on this side of the node also want to open again, too much trouble. Therefore, it is best to open a roscore before roslaunch, so modify the lower machine program, the host computer here will not have to reopen also can work. That means that when the machine is on the power, we have to ssh up two times, one open core, one roslaunch. WTF. This repetitive operation should be done by the machine itself. (The content of this blog post only with TXT record the process, time is a bit long, just keep it as it is ~ lazy typesetting ~)

Copyright notice
Original article, reprint please explain source: sheng-blog.cn
Original source Notes

1, the Network Detection Code section:

While True;do
ping-w 1-c 1 192.168.1.132>/dev/null
ret=$?
If [$ret-eq 0]
then printf "$prefix is up" break
;
else printf "$prefix are down \ n" 
fi done

2, in the dash search "start the application" in the script set to power-on, the script will run in the background after the boot, the command plus gnome-terminal-x can be implemented in the terminal operation, but it is recommended in the script in the end of the execution of the place to add this directive.

3, this mode of power-on from the system to open the graphics interface, such as the raspberry pie in the Ubuntu mate system to ensure that the graphical enable, but the specific presence of the display is not important. Also note that if the installation of XRDP this Remote Desktop, in the same IP open multiple Windows telnet to see the same piece of desktop, and different IP is to see a different desktop, we set up the boot program in each desktop startup will be executed. VNC has and only one desktop, consistent with the HDMI output.

4, in the same script can only carry out a return instruction, such as in the same script first Roscore again roslaunch is not possible, the actual effect is only to Roscore, unless CTRL + C to end the core, the script will continue to execute. Therefore, to start a core and a roslaunch you need to add two boot scripts.

5, powerful screen instructions: the previous reference to the script in the terminal execution, but after we ssh but can not control the terminal, at this time the screen directive can solve this problem. Create a new screen in the inside operation can facilitate follow-up attach back, the script gnome-terminal-x screen-s Windowname/the/path/of/the/shell can be divided into two write { Gnome-terminal-x screen-s Windowname/the/path/of/the/shell} is not a good answer.

6, use the above open screen on the way to run the script has a problem, such as roslaunch in a certain link error, screen session will be directly terminated, we do not know the cause of the program error. Therefore, you cannot write with the above command, but you should separate the new screen session from the execution script, in the correct way: gnome-terminal-x screen-s windowname connect gnome-terminal-x screen-s windowname-x Screen/the/path/of/the/shell. where screen's-x parameter means specifying which screen to run a directive.

7, although we added gnome-terminal-x specified the following command to be executed in a terminal, but screen The timing of the following instruction execution is before the terminal executes the. bashrc file, so we need to source some of the ROS profiles in the script, and don't forget export ros_master_uri=http://pi:11311
Export ros_ip=10.42.0.64 These two environment variables, otherwise the other computers will not be able to communicate with them properly. It is this feature that makes it necessary to use four scripts to start a core and a roslaunch.

8, must be guaranteed to open the core first, so you can launch in the script Riga delay, delay can not be too short, otherwise the core has not been opened roslaunch the same will die very ugly, I see the phenomenon is in the two windows are repeated restart. Currently using 25s delay, almost. 20s is a bit of a risk. Scripts currently in use

Newscreen_core

#!/bin/bash while 
true;do
ping-w 1-c 1 10.42.0.1>/dev/null ret=$
?
If [$ret-eq 0]
then printf "$prefix is up" break
;
else printf "$prefix is down \ \" 
fi done
mate-terminal-x screen-s core ~/auto_runing/core_ros
# Mate-terminal-x screen-s core-x Screen ~/auto_runing/core_ros

Core_ros

#!/bin/bash 
source/opt/ros/kinetic/setup.bash  
SOURCE/HOME/PI/.BASHRC   
source/home/pi/catkin_ws/ Devel/setup.bash  
cd/home/pi/catkin_ws
export ros_master_uri=http://10.42.0.1:11311
export ros_ip= 10.42.0.1
Roscore

Newscreen_quad

#!/bin/bash while 
true;do
ping-w 1-c 1 10.42.0.1>/dev/null ret=$
?
If [$ret-eq 0]
then printf "$prefix is up" break
;
else printf "$prefix is down \ \" fi done sleep
25s
mate-terminal-x screen-s Quad
mate-terminal-x Screen-s quad-x Screen ~/auto_runing/quadrotor

Quadrotor

#!/bin/bash 
source/opt/ros/kinetic/setup.bash  
SOURCE/HOME/PI/.BASHRC   
source/home/pi/catkin_ws/ Devel/setup.bash  
cd/home/pi/catkin_ws
export ros_master_uri=http://10.42.0.1:11311
export ros_ip= 10.42.0.1
roslaunch Planning Start_test.launch

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.