ROS虚拟仿真环境安装使用

3 篇文章 2 订阅
2 篇文章 0 订阅

ROS安装

虚拟机环境 Ubuntu18.04

按照官方文档操作:

melodic/Installation/Ubuntu
https://wiki.ros.org/melodic/Installation/Ubuntu

添加国内 USTC 源

sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'

sudo apt-key adv --keyserver hkp://pool.sks-keyservers.net --recv-key 0xB01FA116

sudo apt-get update

安装ROS软件包

sudo apt install ros-melodic-desktop-full

设置环境

cat /opt/ros/melodic/setup.bash 确定位置

echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc

Python rosdep

sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
sudo apt install python-rosdep

sudo rosdep init
rosdep update

启动小海龟

3个命令窗口

roscore

rosrun turtlesim turtlesim_node 

键盘控制:
rosrun turtlesim turtle_teleop_key

键盘放在控制终端上就可以控制海龟了。

image-20200915212327254

WSL Ubuntu18.04 安装ROS

安装报错

sudo apt-get upgrade
Reading package lists… Done
Building dependency tree
Reading state information… Done
You might want to run ‘apt --fix-broken install’ to correct these.
The following packages have unmet dependencies:
python-rosdep-modules : Depends: python-rospkg-modules (>= 1.1.10) but it is not installed
Depends: python-rosdistro-modules (>= 0.7.5) but it is not installed
ros-melodic-rqt-gui : Depends: python-rospkg-modules but it is not installed
E: Unmet dependencies. Try ‘apt --fix-broken install’ with no packages (or specify a solution).

修复 出错

image-20200915195858127

使用的源是阿里云

执行下面命令

sudo dpkg -i --force-overwrite <filename>
sudo apt-get -f install

执行完后即可

执行roscore 错误

Command ‘roscore’ not found, but can be installed with:

sudo apt install python-roslaunch

安装这个包

The following packages have unmet dependencies:
python-roslaunch : Depends: python-roslib but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

没有初始化要先执行:

sudo rosdep init
rosdep update

载入环境到命令行窗口(bashrc):

echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc

初始化错误

执行sudo rosdep init 错误:

ERROR: cannot download default sources list from:
https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list
Website may be down.

网络问题,添加host解决:

Ubuntu18.04安装ROS Melodic(详细,亲测安装完成,有清晰的截图步骤)
https://blog.csdn.net/qq_44830040/article/details/106049992

cd /etc
sudo vim /etc/hosts

添加

151.101.84.133 raw.githubusercontent.com

虚拟机开代理也行

安装ROS编辑器 Roboware

RoboWare/Studio at master · TonyRobotics/RoboWare
https://github.com/TonyRobotics/RoboWare/tree/master/Studio

下载deb文件

RoboWare Studio安装教程
https://blog.csdn.net/zhuiqiuzhuoyue583/article/details/84536406#commentBox

参考安装:

sudo apt-get install python-pip
sudo python -m pip install pylint
换源:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pylint

自动格式化代码整理:

sudo apt-get install clang-format

安装:

将下载的文件新建一个文件夹放,执行:

sudo dpkg -i roboware-studio_1.1.0-1514335284_amd64.deb

安装完成,图形界面打开:

roboware-studio

工作空间

初始化工作空间

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace

编译

cd ~/catkin_ws/
catkin_make

会生成build和devel目录;devel目录下有setup.*sh形式的环境变量设置脚本,使用source devel/setup.bash生效

ROS仿真

官方文档:

gaitech-robotics/RIA-E100
https://github.com/gaitech-robotics/RIA-E100

克隆/下载

mkdir –p ~/catkin_ws/src
cd ~/catkin_ws/src
git clone https://github.com/gaitech-robotics/RIA-E100.git
cd ~/catkin_ws && catkin_make

安装依赖

UBUNTU 16.04 :

sudo apt install ros-kinetic-controller-manager ros-kinetic-gazebo-ros-control ros-kinetic-teleop-twist-keyboard ros-kinetic-teleop-twist-joy ros-kinetic-joy ros-kinetic-slam-gmapping ros-kinetic-hector-mapping ros-kinetic-hector-trajectory-server ros-kinetic-move-base ros-kinetic-map-server ros-kinetic-amcl ros-kinetic-teb-local-planner

Ubuntu18.04:

sudo apt install ros-melodic-controller-manager ros-melodic-gazebo-ros-control ros-melodic-teleop-twist-keyboard ros-melodic-teleop-twist-joy ros-melodic-joy ros-melodic-slam-gmapping ros-melodic-hector-mapping ros-melodic-hector-trajectory-server ros-melodic-move-base ros-melodic-map-server ros-melodic-amcl ros-melodic-teb-local-planner
sudo apt install ros-melodic-gazebo-ros-pkgs  ros-melodic-gazebo-msgs  ros-melodic-gazebo-plugins  ros-melodic-gazebo-ros-control

添加环境变量

sudo echo "export USE_EKF='true'" >> ~/.bashrc

sudo echo "source /home/nick/catkin_ws/devel/setup.bash" >> ~/.bashrc

source ~/.bashrc

启动

roslaunch是一个启动ROS节点并插入机器人模型的标准方法.要建立一个空的world模型,我们只需要运行

roslaunch gazebo_ros empty_world.launch
项目:
roslaunch e100_sim gazebo.launch 

失败1 Process has died

roslaunch gazebo_ros empty_world.launch 启动失败

失败1

gazebo启动没反应

解决1

重装gazebo

问题解决——Gazebo 7升级到7.1.3([gazebo-2] process has died;[gazebo_gui-3] process has died)
https://blog.csdn.net/wangguchao/article/details/88776785

解决2

Gazebo闪退

在虚拟机中的linux上运行gazebo的时候,gazebo窗口闪退,或者提示问题:

VMware: vmw_ ioctl_command error Invalid argument.

关闭硬件加速:

echo " export SVGA_VGPU10=0" >> ~/.bashrc

source ~/.bashrc

关闭虚拟机的显示器-3D图形加速

失败2 roslaunch失败

确定编译成功 devel目录下有文件
失败2

确定导入了环境

cd catkin_ws
source devel/setup.bash

失败3 启动后黑屏

启动roslaunch gazebo_ros empty_world.launch 是没问题的,启动roslaunch e100_sim gazebo.launch黑屏:

启动后黑屏

Note The first run of gazebo might take considerably long, as it will download some models from an online database.

第一次启动可能需要时间下载模型。

看模型目录是不是全的:

在这里插入图片描述

或者再把上面的依赖重新安装一遍

成功:

成功启动gazebo界面,场景在一个房间里。
在这里插入图片描述

开启控制

cd catkin_ws
source devel/setup.bash
roslaunch e100_sim keyboard.launch 

在这里插入图片描述
需要在命令窗口操作移动:

Reading from the keyboard  and Publishing to Twist!
---------------------------
Moving around:
   u    i    o
   j    k    l
   m    ,    .

For Holonomic mode (strafing), hold down the shift key:
---------------------------
   U    I    O
   J    K    L
   M    <    >

t : up (+z)
b : down (-z)

anything else : stop

q/z : increase/decrease max speeds by 10%
w/x : increase/decrease only linear speed by 10%
e/c : increase/decrease only angular speed by 10%

Navigation

启动gazebo 启动控制 再启动:

Further, we need to launch the gmapping slam by:
roslaunch e100_navigation slam_gmapping.launch

启动rviz
roslaunch e100_description view.launch

控制小车移动,可以在rviz看到扫描到的地图。
扫描地图
保存地图:

The last step you have to save the map using the following:
rosrun map_server map_saver -f office_map
It is recommended to save the map in the path:
~/catkin_ws/src/ria_e100/e100_navigation/maps

导航移动:

The last step is to launch the navigation file by:
roslaunch e100_navigation navigation.launch

进阶

修改模型 增加摄像头……

参考
https://github.com/huchunxu/ros_exploring
https://github.com/DroidAITech/ROS-Academy-for-Beginners
《ROS机器人开发实践》

  • 4
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

nickdlk

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值