ROS安装最后输入roscore无效部分解决方案

ROS安装

在输入roscore检验安装过程前步骤(即安装ROS过程):
可参照:

https://blog.csdn.net/qq_44339029/article/details/108919545

问题描述

问题:Command ‘roscore’ not found, but can be installed with:sudo apt install python3-roslaunch
如图所示
在这里插入图片描述
首先sudo apt install python3-roslaunch
操作完成后再次roscore
此时仍然发现无法成功,可能如图
在这里插入图片描述
或者RLException: Unable to contact my own server如图所示
在这里插入图片描述

如果问题如上,解决方案

修改bashrc文件
通过gedit打开bashrc文件

gedit ~/.bashrc

在文件中插入如下语句

source /opt/ros/noetic/setup.bash   
export ROS_MASTER_URI=http://localhost:11311
export ROS_HOSTNAME=localhost

注意使用Ubuntu22.04时是source /opt/ros/noetic/setup.bash,其他版本需要将noetic改为对应版本ROS,例如18.04为melodic

然后必须再次输入如下语句:

source ~./bashrc

之后再次输入roscore,此时一般就OK了,如图
在这里插入图片描述

检验使用

敲击ctrl+alt+t另起一个终端,输入

rosrun turtlesim turtlesim_node

出现一只小海龟
在这里插入图片描述
然后再次敲击ctrl+alt+t另起一个终端,输入

 rosrun turtlesim turtle_teleop_key

此时可以使用键盘上上下左右键进行操作,作图如下:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_45108668/article/details/129912946
今日推荐