zoukankan      html  css  js  c++  java
  • ROS 小乌龟测试

    教程

    1.维基 http://wiki.ros.org/cn/ROS/Tutorials
    2. 创客智造 http://www.ncnynl.com/category/ros-junior-tutorial/

    1安装环境配置(桌面进入命令行)

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

    2.1创建工作环境并编译 (生成的在home文件夹下)

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

    2.2自己创建的包环境 能看到’build’和’devel’这两个文件夹。
    将当前工作环境设置在ROS工作环境

    source /home/dongdong/catkin_ws/devel/setup.bash

    如果永久性配置

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

    查看是否配置成功

    echo $ROS_PACKAGE_PATH

    5 运行小乌龟测试

    //打开新窗口
    roscore
    //另开新窗口
    rosrun turtlesim turtlesim_node __name:=my_turtle //改变名字 my_turtle
    //发送一条消息给turtlesim,告诉它以2.0大小的线速度和1.8大小的角速度开始移动。
    rostopic pub -1 /turtle1/cmd_vel geometry_msgs/Twist -- '[2.0, 0.0, 0.0]' '[0.0, 0.0, 1.8]'
    //rostopic pub -r 1命令    一个稳定的频率为1Hz的命令
    rostopic pub /turtle1/cmd_vel geometry_msgs/Twist -r 1 -- '[2.0, 0.0, 0.0]' '[0.0, 0.0, 1.8]'
    //通过键盘控制
    

    —————–参数解释————————————-
    -1 发表后就退出
    /turtle1/command_velocity 话题名称
    turtlesim/Velocity 话题类型
    – (双破折号)这会告诉命令选项解析器接下来的参数部分都不是命令选项。
    2.0 1.8 两个浮点型元素:linear和angular。
    这些参数其实是按照YAML语法格式编写的,这在YAML文档中有更多的描述。
    ——————-参数解释结束———————————————–


    6 roslaunch 同时运行多个小乌龟节点

    $ roscd beginner_tutorials
    $ mkdir launch
    $ cd launch
    $ gedit turtlemimic.launch
    $ roslaunch beginner_tutorials turtlemimic.launch
    $ rostopic pub /turtlesim1/turtle1/cmd_vel geometry_msgs/Twist -r 1 -- '[2.0, 0.0, 0.0]' '[0.0, 0.0, -1.8]'

    turtlemimic.launch 文件里面写入

    <launch>
    
         <group ns="turtlesim1">
           <node pkg="turtlesim" name="sim" type="turtlesim_node"/>
         </group>
    
         <group ns="turtlesim2">
            <node pkg="turtlesim" name="sim" type="turtlesim_node"/>
          </group>
    
         <node pkg="turtlesim" name="mimic" type="mimic">
           <remap from="input" to="turtlesim1/turtle1"/>
           <remap from="output" to="turtlesim2/turtle1"/>
         </node>
    
       </launch>
  • 相关阅读:
    Grand Central Dispatch-thread pool pattern
    POSIX Threads
    Event-driven programming-main loop
    Data type-数据类型
    软件的动与静
    对封装好的视图进行动态修改
    编程语言进化
    Type system
    Run-time type information--RTTI
    Type system-Type checking
  • 原文地址:https://www.cnblogs.com/kekeoutlook/p/7396952.html
Copyright © 2011-2022 走看看