【ROS2】Error:bash: ros2: command not found
项目场景:在用bash编写开机快速启动的文件时候,双击图标运行过程中,出现找不到该命令的问题。
何如新建所有程序一键图标快捷启动的问题,还请看这篇文章
https://blog.csdn.net/jianlai_/article/details/134209537
问题描述
在用bash编写开机快速启动的文件时候,双击图标运行过程中,出现找不到该命令的问题。
final.sh文件
#!/bin/bash
gnome-terminal -- bash -c "cd quick_copy;source nav2.sh"
# 使用read命令达到类似bat中的pause命令效果
echo 按任意键继续
read -n 1
echo 继续运行
原因分析:
ros2的源使用的是humble
解决方案:
source /opt/ros/humble/setup.sh
将上面的代码加入你的.sh文件中,同时补充好路径
nav2.sh
#!/bin/bash
gnome-terminal -- bash -c "cd /home/ros/;source /opt/ros/humble/setup.bash;ros2 node list;sleep 50" & sleep 1
wait
exit 0
接下来保存后,再次双击图标,就会发现运行成功。