ubuntu18.04系统中运行./build_ros.sh的时候遇到报错

我的ros系统是用的小鱼的一键安装链接,参考:

ubuntu-18.04一键安装ros_ros18.04yijian-CSDN博客

我编译./build_ros.sh的时候遇到的问题,查遍csdn都没找到解决方法
 

问题一:

CMake Error at /opt/ros/melodic/share/ros/core/rosbuild/public.cmake:129 (message):

  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!

Call Stack (most recent call first):
  /opt/ros/melodic/share/ros/core/rosbuild/public.cmake:207 (rosbuild_invoke_rospack)
  CMakeLists.txt:4 (rosbuild_init)


-- Configuring incomplete, errors occurred!
See also "/home/chenhaining/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/build/CMakeFiles/CMakeOutput.log".
make: *** 没有指明目标并且找不到 makefile。 停止。

CMake Error at /opt/ros/melodic/share/ros/core/rosbuild/public.cmake:129 (message):

  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!

Call Stack (most recent call first):
  /opt/ros/melodic/share/ros/core/rosbuild/public.cmake:207 (rosbuild_invoke_rospack)
  CMakeLists.txt:4 (rosbuild_init)


-- Configuring incomplete, errors occurred!
See also "/home/chenhaining/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/build/CMakeFiles/CMakeOutput.log".
make: *** 没有指明目标并且找不到 makefile。 停止。

解决方法:

sudo rosdep init
rosdep update

即可,运行rosdep update的时候可能遇到rosdep update错误失败一直timeout的问题,如:The read operation timed out(包括ERROR: unable to process source,ERROR: error loading sources list

可参考解决方法:rosdep update错误失败一直timeout解决方法_rosdep update出错-CSDN博客(本人实测方法二有效)

问题二:

/home/chenhaining/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/AR/ViewerAR.cc: In member function ‘void ORB_SLAM2::ViewerAR::Run()’:
/home/chenhaining/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/AR/ViewerAR.cc:233:9: error: ‘usleep’ was not declared in this scope
  233 |         usleep(mT*1000);
      |         ^~~~~~
CMakeFiles/MonoAR.dir/build.make:190: recipe for target 'CMakeFiles/MonoAR.dir/src/AR/ViewerAR.cc.o' failed
make[2]: *** [CMakeFiles/MonoAR.dir/src/AR/ViewerAR.cc.o] Error 1
CMakeFiles/Makefile2:543: recipe for target 'CMakeFiles/MonoAR.dir/all' failed
make[1]: *** [CMakeFiles/MonoAR.dir/all] Error 2
Makefile:132: recipe for target 'all' failed
make: *** [all] Error 2

/home/chenhaining/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/AR/ViewerAR.cc: In member function ‘void ORB_SLAM2::ViewerAR::Run()’:
/home/chenhaining/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/AR/ViewerAR.cc:233:9: error: ‘usleep’ was not declared in this scope
  233 |         usleep(mT*1000);
      |         ^~~~~~
CMakeFiles/MonoAR.dir/build.make:190: recipe for target 'CMakeFiles/MonoAR.dir/src/AR/ViewerAR.cc.o' failed
make[2]: *** [CMakeFiles/MonoAR.dir/src/AR/ViewerAR.cc.o] Error 1
CMakeFiles/Makefile2:543: recipe for target 'CMakeFiles/MonoAR.dir/all' failed
make[1]: *** [CMakeFiles/MonoAR.dir/all] Error 2
Makefile:132: recipe for target 'all' failed
make: *** [all] Error 2

解决方法:

在orb_slam2文件夹中搜索:ViewerAR.cc,打开

引入头文件:

#include<unistd.h>

即可解决问题

### 安装 PX4 + ROS + Gazebo 的完整教程 #### 准备工作 确保系统已更新至最新状态并安装必要的依赖包。 ```bash sudo apt update && sudo apt upgrade -y sudo apt install git wget curl build-essential cmake python3-pip -y ``` #### 设置源和密钥 为了顺利安装软件,需配置合适的APT仓库并导入相应的GPG密钥[^1]。 对于Gazebo而言: ```bash echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable bionic main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list wget https://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add - ``` 针对ROS Melodic: ```bash sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add - ``` 再次刷新apt缓存以应用更改后的列表文件设置。 ```bash sudo apt update ``` #### 安装 ROS 和 Gazebo 根据官方推荐的方式进行安装[^2]。 ```bash # 安装桌面完全版的ROS Melodic sudo apt install ros-melodic-desktop-full -y # 初始化rosdep工具 sudo rosdep init rosdep update # 添加环境变量到.bashrc中以便每次启动终端都能自动加载ROS环境 echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc source ~/.bashrc # 安装gazebo9及其插件库 sudo apt-get install gazebo9 libgazebo9-dev -y ``` #### 配置 MAVROS 节点 MAVLink通讯协议是连接地面站与飞行器的关键组件之一,在此之前先完成mavlink编译过程[^3]。 ```bash pip3 install empy pyyaml pandas numpy --user mkdir -p ~/catkin_ws/src; cd ~/catkin_ws; wstool init src git clone https://github.com/PX4/MissionPlanner.git src/px4_mission_planner cd src/ git clone https://github.com/mavlink/mavros.git mavros cd mavros git submodule update --init --recursive cd .. cd .. catkin_make source devel/setup.bash ``` #### 下载并构建PX4固件 通过DevGuide提供的自动化脚本来简化整个流程[^4]。 ```bash # 获取安装脚本 wget https://raw.githubusercontent.com/PX4/Devguide/master/build_scripts/ubuntu_sim_ros_melodic.sh # 给予执行权限给下载下来的shell script chmod +x ubuntu_sim_ros_melodic.sh # 执行该脚本开始安装所需的一切东西 ./ubuntu_sim_ros_melodic.sh ``` 以上就是完整的Ubuntu 18.04 LTS上搭建支持无人机仿真的开发环境的方法。希望这些信息能够帮到正在寻找解决方案的人们。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值