无人机用shell远程登录机载电脑,每次需要环境配置原因
原因:
终端分为“登录 shell”和“非登录 shell”:
- 登录 shell(如开机登录、远程 SSH 连接)会加载 .profile 或 .bash_profile 。
- 非登录 shell(如打开新终端窗口)会加载 .bashrc 。
- 如果环境变量仅配置在 .bashrc ,而系统开机时以登录 shell 方式启动,就不会自动加载。
解决方法:
三个环境全部配置环境,如下:
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
echo "source /opt/ros/noetic/setup.bash" >> ~/.profile
source ~/.profile
echo "source /opt/ros/noetic/setup.bash" >> ~/.bash_profile
source ~/.bash_profile