ROS 小烏龜測試

2021-08-04 19:00:45 字數 2236 閱讀 9428

教程

1.維基

2. 創客智造

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 檔案裡面寫入

ns="turtlesim1">

pkg="turtlesim"

name="sim"

type="turtlesim_node"/>

group>

ns="turtlesim2">

pkg="turtlesim"

name="sim"

type="turtlesim_node"/>

group>

pkg="turtlesim"

name="mimic"

type="mimic">

from="input"

to="turtlesim1/turtle1"/>

from="output"

to="turtlesim2/turtle1"/>

node>

launch>

ROS小烏龜測試

echo export display 0.0 bashrc source bashrc5 啟動ros master roscore6 另外開啟bash或cmder,輸入 rosrun turtlesim turtlesim node即可開啟乙個圖形視窗,並看到乙隻小烏龜。提示qstandardpa...

ROS上手測試小烏龜程式

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,optio...

ROS小烏龜建立

ros啟動小烏龜 雖然過程還有很多failed沒完全看懂解決,但是還是記錄下來好好修正。以下逐條 實驗 建立ros工作環境 catkin 執行 mkdir p catkin ws src cd catkin ws src catkin init workspace cd catkin ws catk...