在ROS进行跨文件调用功能包时遇到报错
Resource not found: The following package was not found in <arg name="world_name" value="$(find turtlebot3_gazebo)/worlds/turtlebot3_house.world"/>: turtlebot3_gazebo ROS path [0]=/opt/ros/melodic/share/ros ROS path [1]=/home/ros-melodic/demo01_ws/src……
在网上查资料查得在_setup_util.py文件中需要将对应功能包的路径添加进去
CMAKE_PREFIX_PATH = r'/home/ros-melodic/robot/turtlebot3_ws/devel;/home/ros-melodic/robot/turtlebot3_ws/devel;/opt/ros/melodic'.split(';')
之前为了方便管理,将turtlebot3的相关工作空间放入了robot文件夹下,但是使用echo $ROS_PACKAGE_PATH查看路径时,出现的路径为:
ros-melodic@rosmelodic-VirtualBox:~/robot/turtlebot3_ws$ echo $ROS_PACKAGE_PATH
/home/ros-melodic/turtlebot3_ws/src:/opt/ros/melodic/share
在turtlebot3_ws前没有robot文件夹的显示,在运行此工作空间下的launch文件时也同样报错,最后在网上找到解决办法是将turtlebot3_ws文件中的build文件删除之后再进行catkin_make,然后再source ./devel/setup.bash后再运行echo $ROS_PACKAGE_PATH查看路径,结果为:
ros-melodic@rosmelodic-VirtualBox:~/robot/turtlebot3_ws$ echo $ROS_PACKAGE_PATH
/home/ros-melodic/turtlebot3_ws/src:/home/ros-melodic/robot/turtlebot3_ws/src:/opt/ros/melodic/share
正确的路径出现了,但还是存在之前的路径,最后查看devel文件下的.catkin文件,发现问题出现在这里,修改后再查看路径,结果与预期相符。
如果有经常使用的工作空间,可以将source **_ws/devel/setup.bash写入家目录下的/.bashrc文件中。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)