zoukankan      html  css  js  c++  java
  • ROS基础-基本概念和简单工具(1)

    1、什么是ROS?

    Robot operating System ,简单说机器人操作系统,弱耦合的分布式进程框架,通过进程间的消息传递和管理。实现硬件抽象和设备控制。

    2、节点(node)

    • node 是ROS的核心实体。
    • 一段ROS程序
    • 使用ROS的中间件进行通信
    • 节点之间可以独立的启动和停止

    3、和节点相关的概念

    • message
    • topic
    • roscore :
    1. 有且只有一个roscore 可以运行
    2. 必须首先启动roscore
    3. 负责调度通信
    4. 发布器节点和roscore通信(如初始化一个topic)
    • publisher、subscriber

    4、工具

      catkin_create_pkg: 创建一个package

      catkin_make: 编译ROS程序

      rosrun: 运行ros程序

      rostopic: 主题有关的命令

          rostopic list  ;   rostopic hz topic1; rostopic bw topic1;  rostopic info topic1;  rostopic echo topic1

      rosnode list :  产看运行的节点列表

      roslaunch : 通过编辑.launch 的文件自动启动多个节点

      rosbag : 对话题数据的记录和回放

          rosbag record topic1

          rosbag play   name1.bag

             rqt_plot: 对结果的可视化

    5、常用工具详细介绍

    catkin_create_pkg:

      catkin_create_pkg   [packageNmae]  [依赖项]

      

      依赖项: roscpp:  使用c++编译器,兼容c++接口;  std_msgs:  ros预定义的数据类型

      

    catkin_make:

      package.xml :  组织ROS程序包,命名程序包名称、依赖项

             <name></name>

             <build_depend></build_depend>

             <run_depend></run_depend>

             

      CMakeLists.txt  : 一个简单示例如下

    cmake_minimum_required(VERSION 2.8.3)
    project(demo-proj1-nodes) # package name
    
    find_package(catkin REQUIRED COMPONENTS
        roscpp
        std_msgs
    )
    
    catkin_package(
    #  INCLUDE_DIRS include
    #  LIBRARIES my_minimal_nodes
    #  CATKIN_DEPENDS roscpp std-msgs
    #  DEPENDS system_lib
    )
    
    include_directories(
     include ${catkin_INCLUDE_DIRS}
    )
    
    add_executable(my_minimal_publisher src/minimal_publisher.cpp)
    add_executable(my_minimal_publisher2 src/sleep_minimal_publisher.cpp)
    
    
    target_link_libraries(my_minimal_publisher
       ${catkin_LIBRARIES}
    )
    target_link_libraries(my_minimal_publisher2
       ${catkin_LIBRARIES}
    )
    View Code

      编译命令:catkin_make

      

       编译后会有,devel 和build 两个文件夹

    rosrun:

      首先使用添加环境变量: source ./devel/setup.bash

             rosrun [package-name] [可运行程序名称]

    rqt_graph:

      图形展示拓扑图。

      

     roslaunch:

      批量启动节点,需要编写 .launch的启动文件, 简单示例如下:

      在package 目录下,创建 launch 目录,并在其中创建 .launch 文件:

    <launch>
        <node name="publisher" pkg="my_minimal_nodes" type="my_minimal_publisher2"/>
        <node name="subscriber" pkg="my_minimal_nodes" type="my_minimal_psubscriber"/>
    </launch>

      运行命令:  roslaunch  [package name] [.launch]

    catkin_simple:

      简化和规范 CMakeLists.txt

            https://github.com/wsnewman/learning_ros_external_packages

      

       打开~/.bashrc 在末尾添加,alias cs_create_pkg='~/path/cs_create_pkg.py'

        之后可以使用命令: cs_create_pkg  [package name] [依赖] 创建ros包

      将catkin_simple 复制到你的程序包同级的目录中,如下,之后可以使用 catkin_make 编译。

      

        catkin_simple 也可以从该地址中获得,一些详细使用方法也在其中https://github.com/catkin/catkin_simple

      

      

      

  • 相关阅读:
    visualSVNYou don't have permission to access on this server
    怎样截取Http请求
    ASP.NET @page 指令详解
    我的XMLHelperC# XML操作基类(修改,删除,新增,创建)
    最新Visual Studio 2010 下载及学习资料
    redis主从哨兵和集群的区别
    uniapp nvue 支持iconfont
    Error (Error Code: 1175) during executing update command on table using MySQL
    org.apache.jasper.JasperException: Unable to compile class for JSP
    java.sql.SQLException: Access denied for user 'root'@'10.10.10.10' (using password: YES)
  • 原文地址:https://www.cnblogs.com/feihu-h/p/11839316.html
Copyright © 2011-2022 走看看