2013年6月23日日曜日

マッピングできない

http://www.ist.tugraz.at/robotics/bin/view/Main/Poineer_mapping

マッピングするためには以下の変換が必要

1./base_linkと/laser
2./base_footprintと/base_link
3./odomと/base_footprint

上記の変換をするためには以下のようにして変換しなければならない

/odom --> /base_footprint --> /base_link --> /laser


●実際は以下のように変換する

//○変換:/base_link --> /laser
    tf::Quaternion laserQ;
    laserQ.setRPY(0.0, 0.0, 0.0);
    tf::Transform txLaser =  tf::Transform(
                        laserQ,
                        tf::Point(0.034, 0.0, 0.250)
                        );
    tf.sendTransform(
            tf::StampedTransform(
                        txLaser,
                        ros::Time::now(),
                        "base_link",
                        "laser"
                        )
            );
   
//○変換:/base_footprint --> /base_link
    tf::Transform txIdentity(
                tf::createIdentityQuaternion(),
                tf::Point(0.0, 0.0, 0.0)
                );
    tf.sendTransform(
            tf::StampedTransform(
                        txIdentity,
                        ros::Time::now(),
                        "base_footprint",
                        "base_link")
                        );
   
//○変換:/odom --> /base_footprint
    tf::Quaternion odomQ;
    tf::quaternionMsgToTF(
                position.pose.pose.orientation,
                odomQ
                );<b>map_saver</b>
    tf::Transform txOdom(
                odomQ, tf::Point(
                        (double) pos.getX()/1000.0,
                        (double) pos.getY()/1000.0,
                        pos.getTh()
                        )
                );
    tf.sendTransform(
            tf::StampedTransform(
                        txOdom,
                        ros::Time::now() ,
                        "odom",
                        "base_footprint")
                        );


※Quatarnionについて
http://www.bulletphysics.com/Bullet/BulletFull/classbtQuaternion.html
仕様が変わってるらしい


○また、上記の変換は以下のようにして端末上で変換することも出来る
$ rosrun tf static_transform_publisher 0.034 0.0 0.250 0.0 0.0 0.0 /base_link /laser 100
$ rosrun tf static_transform_publisher 0.0 0.0 0.0 0.0 0.0 0.0 /base_footprint /base_link 100


○これでいけるかやってみた
$ roslaunch openni_launch openni.launch
$ rosrun depthimage_to_laserscan depthimage_to_laserscan image:=/camera/depth/image_raw
$ rosrun rviz rviz
でlaserscanデータを取得
$ rosrun ROSARIA RosAria
$ rosrun tf static_transform_publisher 0.034 0.0 0.250 0.0 0.0 0.0 /base_link /laser 100
$ rosrun tf static_transform_publisher 0.0 0.0 0.0 0.0 0.0 0.0 /base_footprint /base_link 100
$ rosrun ROSARIA theo.key

で、あとはデータを取得

$ rosbag record -a
$ rosparam set use_sim_time true
$ rosrun gmapping slam_gmapping
$ rosbag play .....................bag
$ rosrun map_server map_saver

ちなみに$ rosrun gmapping slam_gmappingした端末では、以下のような警告が
ここに書いてる
http://www.ros.org/wiki/navigation/Troubleshooting


[ WARN] [1371981822.770704891]: TF_OLD_DATA ignoring data from the past for frame /base_link at time 1.37198e+09 according to authority /play_1371981806796107282
Possible reasons are listed at
[ WARN] [1371981822.770915036]: TF_OLD_DATA ignoring data from the past for frame /camera_depth_frame at time 1.37198e+09 according to authority /play_1371981806796107282
Possible reasons are listed at
[ WARN] [1371981822.771151442]: TF_OLD_DATA ignoring data from the past for frame /camera_rgb_optical_frame at time 1.37198e+09 according to authority /play_1371981806796107282
Possible reasons are listed at

うーん

マップ出来ない
上手く行ったらmy_lab_map.yamlmy_lab_map.pgmが生成されるらしいけど
できていない 
rosbagでgmappingに必要なデータが取得できていないのだろう
後一歩のところで届いてないみたいな

今回のリンクはとても参考になった
グラフ






2013年6月21日金曜日

ROSARIAを使ってオドメトリを取る(1)

●MobileRobot社のpioneerロボットを使うため、
 ROSARIAからオドメトリ情報を取得する

 http://www.ros.org/wiki/ROSARIA/Tutorials/How%20to%20use%20ROSARIA
※p2osのlanuchファイルがどうしても使えなかったので、ROSARIAを使ってみる

おそらく出来る
しかも、あまりいじらないで出来ると思う

なぜなら、nav_msgs/Odometoryを使っているから。
それを出力するだけでも十分いけるように思う


○ROSARIA odomでググったら

http://www.ist.tugraz.at/robotics/bin/view/Main/Poineer_mapping

また、git-hubで

https://github.com/giorgosera/HCR-project/blob/master/src/KeyBoardController.cpp


○拡張できそうなソースコードが揃った

ROSARIAのパッケージの、RosAriaがあるフォルダに、

theo_key.cpp(キーボード操作)
https://github.com/giorgosera/HCR-project/blob/master/src/KeyBoardController.cpp
reb_teleop.cpp(キーボード操作?)
http://www.ist.tugraz.at/robotics/bin/viewfile/Main/Poineer_mapping?rev=1;filename=rob_teleop.cpp
transform.cpp(odom出力?)
http://www.ist.tugraz.at/robotics/bin/viewfile/Main/Poineer_mapping?rev=1;filename=transform.cpp

を追加


○CMakeLists.txtを開いて、追加

だいたい44行めあたりに(見たらなんとなくわかる)

add_executable(theo_key theo_key.cpp)#
add_dependencies(theo_key ROSARIA_gencfg)#
add_executable(rob_teleop rob_teleop.cpp)#
add_dependencies(rob_teleop ROSARIA_gencfg)#
add_executable(transform transform.cpp)#
add_dependencies(transform ROSARIA_gencfg)#

target_link_libraries(theo_key ${catkin_LIBRARIES} ${Boost_LIBRARIES} Aria pthread dl rt)#
set_target_properties(theo_key PROPERTIES COMPILE_FLAGS "-fPIC")#
target_link_libraries(rob_teleop ${catkin_LIBRARIES} ${Boost_LIBRARIES} Aria pthread dl rt)#
set_target_properties(rob_teleop PROPERTIES COMPILE_FLAGS "-fPIC")#
target_link_libraries(transform ${catkin_LIBRARIES} ${Boost_LIBRARIES} Aria pthread dl rt)#
set_target_properties(transform PROPERTIES COMPILE_FLAGS "-fPIC")#

を追加


○catkin_wsに戻って

$catkin_make

※rob_teleopをコンパイルするとエラーが出てくるので、エラーが出てる箇所を削除してみる
http://answers.ros.org/question/11980/teleop_base-compile-errors-from-boost/


※トピックが違うので変更してあげる(適切に指定しないと動かない)
rob_teleopだいたい82行め

pub_ = n_.advertise<geometry_msgs::Twist>("/cmd_vel",1);

pub_ = n_.advertise<geometry_msgs::Twist>("/RosAria/cmd_vel",1);


※データが古いので以下のような警告がでるかもしれない

警告: ‘tf::Quaternion::Quaternion(const tfScalar&, const tfScalar&, const tfScalar&)’ は廃止されました (宣言位置 /opt/ros/groovy/include/tf/LinearMath/Quaternion.h:51) [-Wdeprecated-declarations]

tf::Quaternion(0, 0, 0)

tf::Quaternion(0, 0, 0, 1)
にしたら直った


○実行してみる

$ roscore
$ rosrun ROSARIA RosAria
$ rosrun ROSARIA reb_teleop

動かないときは、トピックの指定が違っているかも
/cmd_vel→/RosAria/cmd_vel

theo_keyでも動く

$ rosrun ROSARIA theo_key

矢印キーを押したら動く(加速するので注意)
で、次に自己位置データ

$ rosrun ROSARIA transform
[ INFO] [1371822464.617404922]: odometry frame sent
[ INFO] [1371822464.715979980]: odometry frame sent
[ INFO] [1371822464.816018004]: odometry frame sent
[ INFO] [1371822464.915978903]: odometry frame sent
[ INFO] [1371822465.015940424]: odometry frame sent
[ INFO] [1371822465.115958098]: odometry frame sent
[ INFO] [1371822465.215978116]: odometry frame sent
[ INFO] [1371822465.315948702]: odometry frame sent
[ INFO] [1371822465.416017841]: odometry frame sent
[ INFO] [1371822465.515966884]: odometry frame sent
[ INFO] [1371822465.615961342]: odometry frame sent
[ INFO] [1371822465.716013449]: odometry frame sent
[ INFO] [1371822465.815990326]: odometry frame sent
[ INFO] [1371822465.915962577]: odometry frame sent
...
...
...
何かいっぱい出た!
しかし、自己位置を取っているのかは不明

次は、キーボードでロボットを動かして、そのときの自己位置を出力するように改造してみる










オドメトリをパブリッシュする

slamするためには パッケージを探すよりも、必要なデータを出力することが必要
そこで、
Subscribed Topics
マップを作るために入力されるデータ
tf (tf/tfMessage)   
 レーザーと本体と推定された現在位置を変換するために必要

scan (sensor_msgs/LaserScan) 
マップを作るための赤外線データ

自己位置をパブリッシュするためには、 Odometryを取ってこないといけない。
navigationスタックを利用して、自己位置(オドメトリ)をパブリッシュするコードを書く。

http://www.ros.org/wiki/navigation/Tutorials/RobotSetup/Odom
上のリンク先にパブリッシャのコードが載っている
ただ、navigationのチュートリアルはgroovyに対応していないので、
多少書き換える必要がある

$ cd catkin_ws/src
$ catkin_create_pkg robot_odom_test roscpp tf geometry_msgs nav_msgs

パッケージ作成時にnav_msgsを追加する
パッケージ名は適当に、robot_odom_test

$ cd src
$ emacs odom_test.cpp &

でsrcフォルダ内にodom_test.cppを作成し、リンク先のコードをコピペ

$ cd  ..
$ emacs CMakeLists.txt &

でrobot_odom_test直下に戻り、CMakeList.txtの末尾に

add_executable(odom_test src/odom_test.cpp)
target_link_libraries(odom_test ${catkin_LIBRARIES})

を追加
catkin_wsに戻って、

$ catkin_make

パブリッシュされてるか確認

$ roscore
$ rosrun robot_odom_test odom_test
$ rostopic list
/odom
/rosout
/rosout_agg
/tf


今度はリスナーを書く(そっちの方が難しそう・・・)
参考にする
http://www.ros.org/wiki/ja/navigation/Tutorials/RobotSetup/TF

2013年6月19日水曜日

depthimage_to_laserscanを使って赤外線検出

○環境
Xtion PRO LIVE

○使用するパッケージ
openni_launch
depthimage_to_laserscanパッケージ
http://www.ros.org/wiki/depthimage_to_laserscan

○手順
$ roslaunch openni_launch openni.launch
$ rosrun depthimage_to_laserscan depthimage_to_lasecan image:=/camera/depth/image_raw
$ rosrun rviz rviz

rvizを開いて、Fixed Frameをcamera_depth_frameに設定する。
LaserScanをAddし、Topicを/scanに設定する。

レーザースキャンデータが取得できる。


2013年6月17日月曜日

ccny_rgbdについて

http://www.ros.org/wiki/ccny_rgbd
https://github.com/ccny-ros-pkg/ccny_rgbd_tools

上記を参照して、3DSLAMのようなことができた

$ git clone https://github.com/ccny-ros-pkg/ccny_rgbd_tools.git

$ rosdep install ccny_rgbd_tools

$ sudo apt-get install libsuitesparse-dev

$ rosmake ccny_rgbd_tools

結構時間がかかる

$ roslaunch ccny_openni_launch openni.launch

$ roslaunch ccny_rgbd vo+mapping.launch

$ rosrun rviz rviz

rvizが現れるとUbuntuの画面の左上にfileなどの項目が表示されるので、
fileを選択してfile openを選択(Ctrl+o)
ccny_rgbd_tools
→ ccny_rgbd
→launch
ディレクトリ内にあるファイルを選択する




Xtionが映し出す風景がrviz上に表示される

しかし、使い方は不明
もうちょっと詳しく調べる必要あり
また、PC環境によっては。rosmakeの時点でエラーを吐くこともある