上电开机+开机程序自运行的相关配置

智能轮椅项目NUC配置和路由配置

文档说明:

本记录文件包含:设置NUC上电自动开机、开机后导航程序自运行配置、接受命令关闭所有ros节点并关机、配置路由器使得外部PC和NUC可以互相通信。

设置NUC上电自动开机:

  • 给NUC上电开机,按F2进入BIOS设置界面。
  • 右上角找到高级(Advanced),选择电源(Power),在After Power Failure项选择Power On即可上电开机
    注意:如果想关闭该功能,改成last State就好。
    改成Power off的话,理论上是上电就关机哦,所以也可以实现上电但是不开机的要求。

开机后导航程序自运行配置:

  • 文件/etc/rc.local是ubuntu系统启动时会自动运行的文件,开机就想自启动的命令写在这个文件里
    -注释部分不要改变,在exit 0前按顺序添加。记录运行该文件的日志:
exec 2> /tmp/rc.local.log  # send stderr from rc.local to a log file
exec 1>&2                  # send stdout to the same log file
set -x

-因为系统刚启动时还没有配置初始环境,添加:

source /home/a/.bashrc
# 问题:在 /home/a/.bashrc就包含以下的执行语句,以下语句还需要吗?
# 是否替换成以下更具有普遍性:source ~/.bashrc
source /opt/ros/kinetic/setup.bash
source /home/a/catkin_ws/devel/setup.bash
source /home/a/wheelchair/020_Dev/catkin_google_ws/devel/setup.bash

-添加环境变量,设置语言,设置图形化显示文件配置路径,设置显示权限

export TURTLEBOT3_MODEL=burger
#export IM_CONFIG_PHASE=1
#设置语言:避免终端的汉子乱码
export LANG=en_US.UTF-8
#给rviz显示权限
export XAUTHORITY=/home/a/.Xauthority
export DISPLAY=:0
xhost +  # 所有客户都可访问

-运行ros命令:

cd /home/a/
chmod +x poweron.sh
./poweron.sh
#!/bin/bash -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
exec 2> /tmp/rc.local.log  # send stderr from rc.local to a log file
exec 1>&2                  # send stdout to the same log file
set -x
source /home/pingan/.bashrc
source /opt/ros/kinetic/setup.bash
source /home/pingan/ws_ros/devel/setup.bash
#source /home/pingan/wheelchair/020_Dev/catkin_google_ws/devel/setup.bash
export TURTLEBOT3_MODEL=burger
#export IM_CONFIG_PHASE=1
export LANG=en_US.UTF-8
export XAUTHORITY=/home/pingan/.Xauthority
export DISPLAY=:0
xhost +
chmod +777 /dev/ttyUSB*
rosclean purge -y
cd /home/pingan/
chmod +x poweron.sh
./poweron.sh
# gnome-terminal -x roslaunch wheel_chair cartographer_navigation.launch
cd WheelChair/
./Server-Wheel.sh start


exit 0

-附power.sh文件

#!/bin/bash
### BEGIN INIT INFO
# Provides:          land.sh
# Required-start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the svnd.sh daemon
# Description:       starts svnd.sh using start-stop-daemon
### END INIT INFO

gnome-terminal -x roscore
#运行轮椅驱动
gnome-terminal -x rosrun wheel_chair wheel_driver
#运行激光雷达驱动
gnome-terminal -x roslaunch urg_node urg_lidar.launch
## 导航
gnome-terminal -x roslaunch wheel_chair cartographer_navigation.launch

exit 0

#!/bin/bash
### BEGIN INIT INFO
# Provides:          land.sh
# Required-start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the svnd.sh daemon
# Description:       starts svnd.sh using start-stop-daemon
### END INIT INFO
#gnome-terminal -x roscore
# 导航
sleep 10
gnome-terminal -x roslaunch wheel_chair cartographer_navigation.launch

exit 0

接受命令关闭所有ros节点并关机:

-包的位置:
kill_all 包放在/home/a/wheelchair/020_Dev/catkin_google_ws/src/kill_all
-应用:(如果是刚复制下来这个包要重新编译)

rosrun kill_all kill_all_node

配置路由器使得外部PC和NUC可以互相通信

-PC网线连接路由器,NUC用wifi连接
-打开设置,网络,对应连接方式点击选项
-在ipv4选项卡中修改ip地址的前三位为192.168.5(因为雷达也在这段),最后三位各个设备不重复就好

你可能感兴趣的:(工具技巧,ubuntu,linux)