Be Engineer.

エンジニア成り立て管理人の日々の記録とメモブログです。

ROSのlaunch fileを解析する

hector_slamを導入したUAVのためのlaunchファイルを作成するために

uavのslamシュミレーションとpr2を用いたslamのlaunchファイルを

解析していこうと思う。

 

[pr2os.launch]

hector_slam/pr2os.launch at catkin · tu-darmstadt-ros-pkg/hector_slam · GitHub

 

<?xml version="1.0"?>

<launch>

//ジョブの始まりを示す。終了は</launch>。

<node pkg="hector_mapping" type="hector_mapping" name="hector_mapping" output="screen">

//node(hector_mapping)を起動。

//pkg : ノードを持つパッケージ名。

//type : ノードの実行形式ファイル。

//name : ノードに付ける名前。

//output : ノードの標準出力と標準エラー出力をlogかscreenに出力する。

 

<!-- Topic names -->

<param name="scan_topic" value="scan" />

//パラメータサーバに保持するパラメータを定義する。

//name : パラメータ名を指定する。

//value : パラメータ値を定義する。

 

<!-- Frame names -->
<param name="base_frame" value="base_link" />
<param name="odom_frame" value="odom"/>
<param name="output_timing" value="false"/>

<!-- Tf use -->
<param name="use_tf_scan_transformation" value="true"/>
<param name="use_tf_pose_start_estimate" value="false"/>
<param name="pub_map_odom_transform" value="true"/>
<param name="advertise_map_service" value="true"/>

<!-- Map size / start point -->
<param name="map_resolution" value="0.050"/>
<param name="map_size" value="2048"/>
<param name="map_start_x" value="0.5"/>
<param name="map_start_y" value="0.5" />
<param name="map_multi_res_levels" value="2" />

<!-- Map update parameters -->
<param name="update_factor_free" value="0.4"/>
<param name="update_factor_occupied" value="0.9" />
<param name="map_update_distance_thresh" value="0.4"/>
<param name="map_update_angle_thresh" value="0.06" />

<!-- Debug parameters -->
<!--
<param name="pub_drawings" value="true"/>
<param name="pub_debug_output" value="true"/>
-->
</node>

 

<node pkg="hector_trajectory_server" type="hector_trajectory_server" name="hector_trajectory_server" output="screen">
<param name="target_frame_name" type="string" value="/map" />
<param name="source_frame_name" type="string" value="/base_link" />
<param name="trajectory_update_rate" type="double" value="4" />
<param name="trajectory_publish_rate" type="double" value="0.25" />
</node>

<node pkg="hector_geotiff" type="geotiff_node" name="hector_geotiff_node" output="screen" launch-prefix="nice -n 15">

//ノードを引数として実行する命令などを指定する。

//nice : タスクの優先度を変更する。'-n 15'で優先度を15上昇。

<remap from="map" to="/dynamic_map" />
<param name="map_file_path" type="string" value="$(find hector_geotiff)/maps" />
<param name="map_file_base_name" type="string" value="hector_slam_map" />
<param name="geotiff_save_period" type="double" value="10" />
<param name="draw_background_checkerboard" type="bool" value="true" />
<param name="draw_free_space_grid" type="bool" value="true" />
</node>

</launch>

 

[indoor_slam_gazebo.launch]

hector_quadrotor/indoor_slam_gazebo.launch at indigo-devel · tu-darmstadt-ros-pkg/hector_quadrotor · GitHub

 

<?xml version="1.0"?>

<launch>

<!-- Start Gazebo with wg world running in (max) realtime -->
<include file="$(find hector_gazebo_worlds)/launch/willow_garage.launch"/>

//他のランチファイルを取り込む

//file="$(find pkg-name)/path/filename.xml" : launchファイルのパスを指定

<!-- Spawn simulated quadrotor uav -->
<include file="$(find hector_quadrotor_gazebo)/launch/spawn_quadrotor.launch" >
<arg name="model" value="$(find hector_quadrotor_description)/urdf/quadrotor_hokuyo_utm30lx.gazebo.xacro"/>

//シュミレーションのモデルの指定
</include>

<!-- Start SLAM system -->
<include file="$(find hector_mapping)/launch/mapping_default.launch">
<arg name="odom_frame" value="world"/>
</include>

<!-- Start GeoTIFF mapper -->
<include file="$(find hector_geotiff)/launch/geotiff_mapper.launch">
<arg name="trajectory_publish_rate" value="4"/>
</include>
//hector_geotiffはロボット動作の軌跡や地図データを保存するためのもの


<!-- Start rviz visualization with preset config -->
<node pkg="rviz" type="rviz" name="rviz" args="-d $(find hector_quadrotor_demo)/rviz_cfg/indoor_slam.rviz"/>

</launch>

 

 

[mapping_default.launch]

<?xml version="1.0"?>

<launch>
<arg name="tf_map_scanmatch_transform_frame_name" default="scanmatcher_frame"/>
<arg name="base_frame" default="base_footprint"/>
<arg name="odom_frame" default="nav"/>
<arg name="pub_map_odom_transform" default="true"/>
<arg name="scan_subscriber_queue_size" default="5"/>
<arg name="scan_topic" default="scan"/>
<arg name="map_size" default="2048"/>

<node pkg="hector_mapping" type="hector_mapping" name="hector_mapping" output="screen">

<!-- Frame names -->
<param name="map_frame" value="map" />
<param name="base_frame" value="$(arg base_frame)" />
<param name="odom_frame" value="$(arg odom_frame)" />

<!-- Tf use -->
<param name="use_tf_scan_transformation" value="true"/>
<param name="use_tf_pose_start_estimate" value="false"/>
<param name="pub_map_odom_transform" value="$(arg pub_map_odom_transform)"/>

<!-- Map size / start point -->
<param name="map_resolution" value="0.050"/>
<param name="map_size" value="$(arg map_size)"/>
<param name="map_start_x" value="0.5"/>
<param name="map_start_y" value="0.5" />
<param name="map_multi_res_levels" value="2" />

<!-- Map update parameters -->
<param name="update_factor_free" value="0.4"/>
<param name="update_factor_occupied" value="0.9" />
<param name="map_update_distance_thresh" value="0.4"/>
<param name="map_update_angle_thresh" value="0.06" />
<param name="laser_z_min_value" value = "-1.0" />
<param name="laser_z_max_value" value = "1.0" />

<!-- Advertising config -->
<param name="advertise_map_service" value="true"/>

<param name="scan_subscriber_queue_size" value="$(arg scan_subscriber_queue_size)"/>
<param name="scan_topic" value="$(arg scan_topic)"/>

<!-- Debug parameters -->
<!--
<param name="output_timing" value="false"/>
<param name="pub_drawings" value="true"/>
<param name="pub_debug_output" value="true"/>
-->
<param name="tf_map_scanmatch_transform_frame_name" value="$(arg tf_map_scanmatch_transform_frame_name)" />
</node>

<!--<node pkg="tf" type="static_transform_publisher" name="map_nav_broadcaster" args="0 0 0 0 0 0 map nav 100"/>-->
</launch>

hector slamのtutorialまとめ

[参照]

REP 105 -- Coordinate Frames for Mobile Platforms (ROS.org)

hector_slam/Tutorials/SettingUpForYourRobot - ROS Wiki

 

[概要]

マッピングのために名前などのステータスの設定が必要。

~.launchでおこなう?

 

参照リンクの図にある座標軸の内、map、odom、base_linkは一般的なもの。

各種説明すると

map : 固定座標?

odom : オドメトリ情報をもとにロボットを追う座標? 高さ成分は0。

base_link : 任意の点と方向を持つ、ロボットを中心にした座標。

 

他は図の通り。

 

 

raspberry pi とノートpcをROSを用いて通信させる

raspberry piとノートpc上の仮想マシンとして起動しているubuntuをROSを用いて通信させる。

 

[参考]

ja/ROS/Tutorials/MultipleMachines - ROS Wiki

ja/ROS/NetworkSetup - ROS Wiki

 

[log]

hostとなるubuntuでroscore(master)を起動後

clientとなるraspberry piからhokuyo_nodeを起動させる。

このとき

Couldn't find an AF_INET address for [ubuntu]

というエラーが発生した。

これをhostとclientとの通信がうまくいってないためだと

予測し、pingで通信を確認した。

結果、hostからclientのpingは通ったが

clientからhostへのpingは通らなかった。

他のマシンではこのようなエラーは出なかったため

仮想マシンの設定が原因だと考えた。

仮想マシンのネットワーク設定をNATからブリッジに

変更したところ、これを解決することができた。

 

しかし、依然、最初に出たエラーは変わらず

Couldn't find an AF_INET address for [ubuntu]

と出てくる。

 

このエラーについて検索したところ

ROS_IPの設定をすれば解決すると出てきた。

answers.ros.org

 

[host]

$ export ROS_IP=`hostname -I`

$ export ROS_MASTER_IP=http://`hostname -I`:11311

$ export ROS_MASTER_URI=http://`hostname -I`:11311

$ roscore

 

[client]

$ export ROS_IP=`hostname -I`

$ export ROS_MASTER_IP=http://(hostのhostname -Iに表示された数字、文字を入れる):11311

$ export ROS_MASTER_URI=http://(hostのhostname -Iに表示された数字、文字を入れる):11311

& rosrun hokuyo_node hokuyo_node

 

これで解決。

hostnameをわかりやすい名前に設定したほうがいいかも。

 

[追記]

後日この記事の手順で詰まった。

IPとURIを間違えた。

 

(参考)

ROS/Troubleshooting - ROS Wiki

http://www.umiacs.umd.edu/~cteo/umd-erratic-ros-data/README-rvis-remote

やることリスト

  • raspberry piとノートPCの通信(ROSを用いて)
  • launchの作成

   -master

           -実機デバッグ

  • hector_slamのテスト
  • flight controllerの調節
  • hector_slamを用いながら、flight controllerのテスト
  • local control nodeの作成、テスト

           -フローを作る

           -pid nodeを理解する

           -mavlink msgから使う変数を見つける

           -システムの作成、launchファイルの作成