Failed to contact master at [localhost:11311]. Retrying...

ROS报错

报错1

[ERROR] [1685197203.713679712]: [registerPublisher] Failed to contact master at [localhost:11311].  Retrying...

执行ROS命令出错,因为忘记执行roscore

报错2

RLException: [irataus.launch] is neither a launch file in package [ratslam_ros] nor is [ratslam_ros] a launch file name
The traceback for the exception was written to the log file

执行ROS命令出错,因为没有source devel/setup.bash

报错3

p@p:~/ROS/tranfrom$ sudo apt install ros-noetic-tf2-tools
[sudo] password for p: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package ros-noetic-tf2-tools

  1. 盲目的复制了下载命令,没有更改命令中的ROS版本。更换位对应的ROS版本即可。如果不是,换源尝试。
  2. 如果是非ROS的安装包错误,比如无法定位软件包 libmrpt-vision-dev 这种情况一般也是安装包名字错了,我们可以在当前环境下搜索下关于mrpt的包
apt search mrpt			# mrpt 改为lib后面的包名 
# 下面给出了部分的搜索结果
libmrpt-opengl1.5/bionic 1:1.5.5-1 amd64
  Mobile Robot Programming Toolkit - opengl library

libmrpt-slam1.5/bionic 1:1.5.5-1 amd64
  Mobile Robot Programming Toolkit - slam library

libmrpt-vision1.5/bionic 1:1.5.5-1 amd64		# 很明显libmrpt-vision1.5就是我们要找的包
  Mobile Robot Programming Toolkit - vision library

报错4

p@p:~$ rosbag record -a -o bag/haa.bag
[ INFO] [1690294610.801329505]: Subscribing to /turtle1/color_sensor
[ERROR] [1690294610.802878010]: Error writing: Error opening file: bag/haa_2023-07-25-20-16-50.bag.active

使用录制命令报错如下,原因

  1. 文件写错了
  2. 当前文件下没有bag文件,要么写绝对路径,要么在有bag文件的文件夹打开终端。

报错5

rospack found package "ORB_SLAM2" at "", but the currentdirectory is "/home/xxx/ORB_SLAM2-master/Examples/ROS/ORB_SLAM2
  • 报错原因

rospack found package指出这个报错的本质是rospack find ROS功能包 失败,找不到这个功能包,解决办法就是把功能包的路径加入到功能包路径${ROS_PACKAGE_PATH},然后再次编译即可成功(如果还是报同样的错,那就是路径不对,比如我这里一直报错因为home前面/忘打了)。

  • 解决方法:
# 第一步 打开bashrc文件
1 gedit ~/.bashrc 
# 第二步 然后在最后加上下面这句(相应功能包的位置,最好是pwd然后复制过来)
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/xxx/ORB_SLAM2/Examples/ROS
# 第三步 刷新
source ~/.bashrc	
# 第四步 验证修改
echo ${ROS_PACKAGE_PATH}   # 查看ROS包当前路径
# 第五步 也可以直接搜索
p@p: rospack list | grep ORB_SLAM2 # 直接查找ROS包ORB_SLAM2  这里直接填要找的包名
ORB_SLAM2 /home/p/ORB_SLAM2-master/Examples/ROS/ORB_SLAM2

报错6

Failed to invoke rospack to get compile flags for package 'ORB_SLAM2'. Look above for errors from rospack itself. Aborting. Please fix the broken dependency!

  • 解决办法
$ sudo rosdep fix-permissions
$ rosdep update

报错7:roscore失败

RLException: Unable to contact my own server at [http://192.168.0.136:44343/].
This usually means that the network is not configured properly.

A common cause is that the machine cannot connect to itself.  Please check
for errors by running:

	ping 192.168.0.136

For more tips, please see

	http://wiki.ros.org/ROS/NetworkSetup

The traceback for the exception was written to the log file

这里是使用了别人提供的虚拟机环境,这个虚拟机被设置为从机(bashrc中查看),把下面两行注释即可

export ROS_MASTER_URI = “xxx”
export ROS_HOSTNAME=192.168.0.136

你可能感兴趣的:(ROS,bash,c++)