ROS实践(1)-环境搭建

一 介绍

ROS官网:http://www.ros.org/

ROS中文社区:http://www.robotos.net/forum.php

ROS版本:ROS的版本名称是按字母顺序E-F-G-H-I-J排列的,Electric-->Fuerte-->Groovy-->Hydro–>Indigo–>Jade...,我们采用的是Indigo

ROS客户端:节点需要使用roscpp或rospy的ROS客户端编写,我们采用的是roscpp

 

1 文件系统 stack和package

二 安装

  1. 环境:4核 8G内存 1T硬盘 dell主机 ubuntu 14.04.3 (U盘安装,开机按F12选择U盘启动),环境ok后,继续下面步骤;
  2. 设置安装源(确保你的main源是ubuntu的官方源,切换阿里云、163等源可能存在问题)
    sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
  3. 设置key
    sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net --recv-key 0xB01FA116
  4. 安装完整版ros,选择版本indigo
    sudo apt-get update
    sudo apt-get install ros-indigo-desktop-full
    echo "source /opt/ros/indigo/setup.bash" >> ~/.bashrc
    source ~/.bashrc
  5. 初始化ros依赖
    sudo rosdep init
    sudo rosdep update
    sudo apt-get install python-rosinstall python-rosdep

 

三 运行

报错:

yangkai04@yangkai04-Inspiron-3650:~$ roscore

Traceback (most recent call last):

  File "/opt/ros/indigo/lib/python2.7/dist-packages/roslaunch/__init__.py", line 257, in main

    write_pid_file(options.pid_fn, options.core, options.port)

  File "/opt/ros/indigo/lib/python2.7/dist-packages/roslaunch/__init__.py", line 110, in write_pid_file

    with open(pid_fn, "w") as f:

IOError: [Errno 13] Permission denied: '/home/yangkai04/.ros/roscore-11311.pid'



解决:

yangkai04@yangkai04-Inspiron-3650:~/project/baidu/adu/perception$ sudo passwd root
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
yangkai04@yangkai04-Inspiron-3650:~/project/baidu/adu/perception$ ls
autotest    build.log       COMAKE          obstacle       production
BCLOUD      build.sh        error.log       obstacle_mock  README.md
BCLOUD.cov  cmake           lib             onboard        tools
build       CMakeLists.txt  local_build.sh  output         traffic_light
yangkai04@yangkai04-Inspiron-3650:~/project/baidu/adu/perception$ su root
Password:
root@yangkai04-Inspiron-3650:/home/yangkai04/project/baidu/adu/perception# vim ~/.bashrc
添加:source /opt/ros/indigo/setup.bash

root@yangkai04-Inspiron-3650:/home/yangkai04/project/baidu/adu/perception# source ~/.bashrc
root@yangkai04-Inspiron-3650:/home/yangkai04/project/baidu/adu/perception#roscore
... logging to /root/.ros/log/d448ba6c-a498-11e6-bcd2-f48e38af57c0/roslaunch-yangkai04-Inspiron-3650-12974.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://yangkai04-Inspiron-3650:40229/
ros_comm version 1.11.20


SUMMARY
========

PARAMETERS
 * /rosdistro: indigo
 * /rosversion: 1.11.20

NODES

auto-starting new master
process[master]: started with pid [12986]
ROS_MASTER_URI=http://yangkai04-Inspiron-3650:11311/

setting /run_id to d448ba6c-a498-11e6-bcd2-f48e38af57c0
process[rosout-1]: started with pid [12999]
started core service [/rosout]


 

四 ROS文件系统导览

root@yangkai04-Inspiron-3650:/home/yangkai04/project/baidu/adu/perception#rospack find turtlesim
/opt/ros/indigo/share/turtlesim

root@yangkai04-Inspiron-3650:/home/yangkai04/project/baidu/adu/perception#rosls turtlesim
cmake  images  msg  package.xml  srv

root@yangkai04-Inspiron-3650:/home/yangkai04/project/baidu/adu/perception#roscd turtlesim
root@yangkai04-Inspiron-3650:/opt/ros/indigo/share/turtlesim# pwd
/opt/ros/indigo/share/turtlesim

 

五 创建工作空间

root@yangkai04-Inspiron-3650:/home/yangkai04/dev/rosbook/chapter2_tutorials# echo $ROS_PACKAGE_PATH
/opt/ros/indigo/share:/opt/ros/indigo/stacks
root@yangkai04-Inspiron-3650:/home/yangkai04/dev/rosbook/chapter2_tutorials# cd ~
root@yangkai04-Inspiron-3650:~# mkdir -p dev/rosbook
root@yangkai04-Inspiron-3650:~# echo "export ROS_PACKAGE_PATH=~/dev/rosbook:${ROS_PACKAGE_PATH}" >> ~/.bashrc
root@yangkai04-Inspiron-3650:~# tail -n 2 ~/.bashrc


export ROS_PACKAGE_PATH=~/dev/rosbook:/opt/ros/indigo/share:/opt/ros/indigo/stacks
root@yangkai04-Inspiron-3650:~# source ~/.bashrc

 

六 创建ROS功能包

root@yangkai04-Inspiron-3650:~# cd ~/dev/rosbook/

root@yangkai04-Inspiron-3650:~/dev/rosbook# ls

root@yangkai04-Inspiron-3650:~/dev/rosbook# roscreate-pkg chapter2_tutorialsstd_msgs rospy roscpp

Created package directory /root/dev/rosbook/chapter2_tutorials

Created include directory /root/dev/rosbook/chapter2_tutorials/include/chapter2_tutorials

Created cpp source directory /root/dev/rosbook/chapter2_tutorials/src

Created package file /root/dev/rosbook/chapter2_tutorials/Makefile

Created package file /root/dev/rosbook/chapter2_tutorials/manifest.xml

Created package file /root/dev/rosbook/chapter2_tutorials/CMakeLists.txt

Created package file /root/dev/rosbook/chapter2_tutorials/mainpage.dox

Please edit chapter2_tutorials/manifest.xml and mainpage.dox to finish creating your package

root@yangkai04-Inspiron-3650:~/dev/rosbook# rospack find chapter2_tutorials
/root/dev/rosbook/chapter2_tutorials
root@yangkai04-Inspiron-3650:~/dev/rosbook# rospack depends chapter2_tutorials
[rospack] Error: the rosdep view is empty: call 'sudo rosdep init' and 'rosdep update'

root@yangkai04-Inspiron-3650:~/dev/rosbook# sudo rosdep init
ERROR: default sources list file already exists:
    /etc/ros/rosdep/sources.list.d/20-default.list
Please delete if you wish to re-initialize

root@yangkai04-Inspiron-3650:~/dev/rosbook# rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
Warning: running 'rosdep update' as root is not recommended.
  You should run 'sudo rosdep fix-permissions' and invoke 'rosdep update' again without sudo.
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index.yaml
Add distro "groovy"
Add distro "hydro"
Add distro "indigo"
Add distro "jade"
Add distro "kinetic"
updated cache in /root/.ros/rosdep/sources.cache

root@yangkai04-Inspiron-3650:~/dev/rosbook# rospack depends chapter2_tutorials
cpp_common
rostime
roscpp_traits
roscpp_serialization
catkin
genmsg
genpy
message_runtime
std_msgs
gencpp
genlisp
message_generation
rosbuild
rosconsole
rosgraph_msgs
xmlrpcpp
roscpp
rosgraph
rospack
roslib
rospy

root@yangkai04-Inspiron-3650:~/dev/rosbook#rosls chapter2_tutorials

CMakeLists.txt  include  mainpage.dox  Makefile  manifest.xml  src

root@yangkai04-Inspiron-3650:~/dev/rosbook#roscd chapter2_tutorials

root@yangkai04-Inspiron-3650:~/dev/rosbook/chapter2_tutorials# pwd

/root/dev/rosbook/chapter2_tutorials

root@yangkai04-Inspiron-3650:~/dev/rosbook/chapter2_tutorials#


 

七 编译ROS功能包

root@yangkai04-Inspiron-3650:~/dev/rosbook/chapter2_tutorials#rosmake chapter2_tutorials

........................

[ rosmake ] Results:                                                            

[ rosmake ] Built 25 packages with 0 failures.                                  

[ rosmake ] Summary output to directory                                         

[ rosmake ] /root/.ros/rosmake/rosmake_output-20161108-154400

 

八 启动ROS

root@yangkai04-Inspiron-3650:~/dev/rosbook/chapter2_tutorials# roscore
... logging to /root/.ros/log/abddcc94-a587-11e6-bcd2-f48e38af57c0/roslaunch-yangkai04-Inspiron-3650-20120.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://yangkai04-Inspiron-3650:40461/
ros_comm version 1.11.20

SUMMARY
========

PARAMETERS
 * /rosdistro: indigo
 * /rosversion: 1.11.20

NODES

auto-starting new master
process[master]: started with pid [20132]
ROS_MASTER_URI=http://yangkai04-Inspiron-3650:11311/

setting /run_id to abddcc94-a587-11e6-bcd2-f48e38af57c0
process[rosout-1]: started with pid [20145]
started core service [/rosout]

九 停止ROS

^C[rosout-1] killing on exit

[master] killing on exit

shutting down processing monitor...

... shutting down processing monitor complete

done


root@yangkai04-Inspiron-3650:/home/yangkai04#rosnode list
ERROR: Unable to communicate with master!
root@yangkai04-Inspiron-3650:/home/yangkai04#rosnode list
ERROR: Unable to communicate with master!

### 回答1: 虚拟机checking是指在使用虚拟机时进行检查和验证,以确保虚拟机的正常运行和安全性。这些检查包括虚拟机的配置、网络设置、安全设置等方面,以及虚拟机内部的操作系统、应用程序等的运行状态。通过虚拟机checking,可以及时发现和解决虚拟机中的问题,保障虚拟机的稳定性和安全性。 ### 回答2: 虚拟机checking是指对虚拟机进行检查和验证的过程。虚拟机是一种软件模拟的计算机系统,它可以在物理计算机上创建一个虚拟的操作环境。在虚拟机checking过程中,我们会对虚拟机的各项配置和设置进行检查,以确保其能够正常运行和使用。 首先,我们会检查虚拟机的硬件配置,包括处理器、内存、存储等。这些硬件要足够强大和稳定,才能支持虚拟机的正常运行。我们需要确保硬件资源充足,并与虚拟机的需求相匹配。 其次,我们需要检查虚拟机的操作系统和软件环境。虚拟机通常会运行一个操作系统,如Linux或Windows,我们需要确保操作系统安装正确,并更新至最新版本。此外,还需要对虚拟机中的各项软件组件进行检查,如虚拟化软件、网络驱动程序等。 在虚拟机checking过程中,我们还需要检查网络设置。虚拟机通常是通过网络与其他计算机进行通信,因此需要确保虚拟机能够正常连接到网络,并具备良好的网络性能。我们需要检查网络适配器的设置、IP地址分配等。 另外,我们还会进行安全检查。虚拟机作为一个计算机系统,同样需要保护其安全。我们会检查虚拟机中的防火墙和安全策略设置,确保虚拟机不易受到攻击。同时,我们还会检查虚拟机的备份和恢复功能,确保数据的安全性和可靠性。 综上所述,虚拟机checking是一个全面检查和验证虚拟机配置和设置的过程。通过进行这些检查,我们可以确保虚拟机能够正常运行,并提供稳定的计算环境。 ### 回答3: 虚拟机checking是指在使用虚拟机软件时进行系统检查的过程。虚拟机是一种将物理计算机分割成多个虚拟计算机的技术,每个虚拟计算机都可以独立运行操作系统和应用程序。在使用虚拟机之前,我们需要进行一系列的检查,以确保虚拟机的正常运行和安全性。 首先,我们需要检查主机计算机的硬件配置。虚拟机需要一定的硬件资源支持,如内存、处理器和存储空间等。检查主机的硬件配置可以确定是否满足虚拟机的需求。 其次,我们需要检查虚拟机软件的版本和兼容性。不同的虚拟机软件有不同的版本,我们需要确保使用最新的版本,以获得更好的性能和安全性。同时,还要检查虚拟机软件与主机操作系统以及要运行的虚拟机操作系统之间的兼容性。 接下来,我们需要检查虚拟机的网络设置。虚拟机需要网络连接才能与外部环境通信。我们需要检查虚拟机的网络配置,包括网络适配器类型、IP地址分配和网络连接方式等,以确保虚拟机可以正常访问网络资源。 最后,我们还需要检查虚拟机操作系统的安装和配置。在虚拟机上安装操作系统后,我们需要进行一系列的配置,如更新操作系统、安装必要的驱动程序和软件等。这些步骤可以保证虚拟机操作系统的正常运行和安全性。 综上所述,虚拟机checking是一个必要的过程,通过对主机硬件配置、虚拟机软件版本和兼容性、网络设置以及虚拟机操作系统的安装和配置进行检查,可以确保虚拟机的正常运行和安全性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值