使用虚拟机与ros连接的主要原因是:linux下载的软件如rviz和rqt可以启用ros硬件中的图像和雷达等功能。但在启用中会出现如下错误,进行解决。
1.虚拟机如果初次使用,需要安装相对应的包
代码语言:javascript复制首先从git上下载所需要的功能包到你的工作空间,我们还是以catkin_ws工作空间为例
cd ~/catkin_ws/src/
git clone https://gitee.com/bingda-robot/base_control.git
git clone https://gitee.com/bingda-robot/lidar.git
git clone https://gitee.com/bingda-robot/robot_vision.git
git clone https://gitee.com/bingda-robot/robot_navigation.git
git clone https://gitee.com/bingda-robot/robot_simulation.git
拉取完成后编译工作空间
cd ~/catkin_ws/
catkin_make
然后来解决功能包依赖
如果你的rosdep可以正常使用,那么可以通过rosdep来检查依赖的包是否都满足
cd ~/catkin_ws/
rosdep check --from-path src
如果执行结果为“All system dependencies have been satisfied”,则所有依赖项目已经满足,无需安装
否则,再执行下面指令安装依赖包
rosdep install --from-path src -y
如果你的rosdep无法正常工作,那么你可以通过安装我们所提供的依赖清单来手动安装
sudo apt-get update
sudo apt-get install ros-$ROS_DISTRO-teleop-twist-keyboard ros-$ROS_DISTRO-amcl ros-$ROS_DISTRO-move-base ros-$ROS_DISTRO-slam-gmapping ros-$ROS_DISTRO-slam-karto ros-$ROS_DISTRO-cartographer ros-$ROS_DISTRO-cartographer-ros ros-$ROS_DISTRO-dwa-local-planner ros-$ROS_DISTRO-teb-local-planner ros-$ROS_DISTRO-uvc-camera ros-$ROS_DISTRO-map-server ros-$ROS_DISTRO-hector-slam* ros-$ROS_DISTRO-global-planner ros-$ROS_DISTRO-navfn -y
2.对于安装步骤一的内容后,出现如下报错
2.1启动ros中相应的包时报错:
代码语言:javascript复制RLException: ERROR: unable to contact ROS master at [http://192.168.X.XXX:11311/]
The traceback for the exception was written to the log file
解决:
代码语言:javascript复制使用:export ROS_MASTER_URI=http://192.168.X.XXX(ros的ip地址):11311/
使得再次连接小车(前提是要打开master,即roscore)
2.2启用linux图形界面工具rqt_image_view命令,图像不显示:
代码语言:javascript复制ROS_HOSTNAME / ROS_IP is set to only allow local connections,
so a requested connection to '192.168.X.XXX' is being rejected.
解决:
代码语言:javascript复制修改ROS_HOSTNAME 和ROS_IP 为linux的IP
export ROS_HOSTNAME=192.168.X.XXX //linux的IP
export ROS_IP=192.168.X.XXX //linux的IP
(win用的是set ROS_HOSTNAME)
2.3运行软件没有包:
代码语言:javascript复制[slam_rviz.launch] is neither a launch file in package [robot_navigation] nor
is [robot_navigation] a launch file name
解决:
代码语言:javascript复制cd ~/catkin_ws
source devel/setup.bash
再运行包即可
(注意:可能还会出现2.2的问题)