ROS学习(one): create a ros workspace and install the mavros

install the mavros package

https://github.com/mavlink/mavros/blob/master/mavros/README.md#installation

sudo apt-get install ros-melodic-mavros ros-melodic-mavros-extras

wget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh

sudo ./install_geographiclib_datasets.sh

sudo apt-get install python-catkin-tools python-rosinstall-generator -y

# 1. Create the workspace: unneeded if you already has workspace
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws
catkin init
wstool init src

# 2. Install MAVLink
#    we use the Kinetic reference for all ROS distros as it's not distro-specific and up to date
rosinstall_generator --rosdistro melodic mavlink | tee /tmp/mavros.rosinstall

# 3. Install MAVROS: get source (upstream - released)
rosinstall_generator --upstream mavros | tee -a /tmp/mavros.rosinstall
# alternative: latest source
# rosinstall_generator --upstream-development mavros | tee -a /tmp/mavros.rosinstall
# For fetching all the dependencies into your catkin_ws, just add '--deps' to the above scripts
# ex: rosinstall_generator --upstream mavros --deps | tee -a /tmp/mavros.rosinstall

# 4. Create workspace & deps
wstool merge -t src /tmp/mavros.rosinstall
wstool update -t src -j4
rosdep install --from-paths src --ignore-src -y

# 5. Install GeographicLib datasets:
./src/mavros/mavros/scripts/install_geographiclib_datasets.sh

# 6. Build source
catkin build

# 7. Make sure that you use setup.bash or setup.zsh from workspace.
#    Else rosrun can't find nodes from this workspace.
source devel/setup.bash

printenv | grep ROS

检查ros是否设置了相关的环境变量
在这里插入图片描述如果没有这个的话, 你需要 source 一些 setup.*sh 文件

这些*sh文件来自于三个位置

  1. 被包管理者安装的 ros 包
  2. rosbuild worksapces 使用工具来提供的文件
  3. Setup.* sh文件是作为构建或安装catkin软件包的副产品而创建的

组织和构建你的ros代码的两种方式:

  1. rosbuild: 不再使用
  2. catkin: 是构建代码的工具, 使用更多的CMake约定
    source /opt/ros/kinetic/setup.bash: 是为了可以使用(have access to )ros命令; 你可以在使用ros命令之前都先执行前面的语句, 你也可以把这条语句加入到你的 .bashrc 文件

创建一个ros workspace

mkdir -p catkin_ws/src
cd ~/catkin_ws
catkin_make

mkdir -p catkin_ws/src
cd ~/catkin_ws
catkin_make: 第一次运行这个代码, 会在你的src文件夹中产生一个文件 CMakeList.txt .
在这里插入图片描述
运行 catkin_make 之后, 在当前目录下会产生 build 文件夹 和 devel 文件夹
devel文件夹中会存在很多的setup.*sh文件在这里插入图片描述
执行source命令之后, 相对应的路径会添加到你的环境设置的最顶端

ros的文件系统

软件包: package是ros代码中的软件组成单元, 每一个Package能包含一个头文件,可执行文件,脚本或者其他的文件
package.xml: 是一个软件包的描述, 它用于定义软件包之间的依赖关系并捕获有关软件包的元信息,例如版本,维护者,许可证等。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值