How to Ask Question質問の仕方

著者:Kei Okada

How to Ask Question質問の仕方


メール,掲示板での質問の仕方のTipsです.初心者の方は何を質問しても,「それだけだと分からない.もっと情報をください」と言われることが多いかと思います.どのように質問したらいいか?一番の目安は「困っている人のトラブルを再現できるかどうか」です.以下に例を見てみましょう.

もし,他の人も使っている汎用のプログラムだったら,

  $ rviz
  と打ち込み,rvizを実行しました

または,

  $ roslaunch urdf_tutorial xacrodisplay.launch model:=`rospack find pr2_description`/robots/pr2.urdf.xacro
  と打ち込みました.

など,相手も同じ問題を再現する方法が質問に含まれているか確認しましょう.

もし,自分しか使っていないプログラムの場合は,そのプログラム一式を圧縮ファイルにして質問に添付するのが簡単です.圧縮ファイルの作り方は,catkinワークスペースで

  $ tar -cvzf my_package.tgz ./src

としましょう.これで生成されたmy_package.tgzを添付すればOKです.

また,添付ファイルを使えないようなメール,掲示板の場合は,ソースコード一式をGitHubにアップロードする方法もよく使われます.GitHubが初めての場合は,http://qiita.com/dev-neko/items/28ac253ea295ad6c2b73 などが参考になるでしょう.

もし,開発しているソースコードに秘密情報が入っておりアップロードすることが困難な場合は,秘密情報を抜いて一般的な問題として再定義し,そのプログラムを作ってアップロードするとと良いかと思います.また,私達のようなROS専門のコンサルタント業者にお問い合わせいただくことも可能です.

また,困っている人と同じ状況を再現するまでもなく,プログラムの出力ログを見ると原因がわかる場合も有ります.プログラムの出力ログを貼り付ける時は,自分でここは重要な箇所ではない等と判断せずに,プログラムの全ての出力を添付するのが重要です.

ROSプログラムのログの取得方法はいくつか有ります.
roslaunchを使ってプログラムを立ち上げた場合,以下のようにlogging to..というメッセージが紹介されます.

  $ roslaunch urdf_tutorial xacrodisplay.launch model:=`rospack find pr2_description`/robots/pr2.urdf.xacro
  ... logging to /home/tork-a/.ros/log/abfd7cb2-b476-11e6-907c-e4a7a00bd84e/roslaunch-ubuntu-14449.log

このとき,/home/tork-a/.ros/log/abfd7cb2-b476-11e6-907c-e4a7a00bd84e/ にあるファイルを全て提出すれば,質問された人も何が起こっているか理解することができます.
また,最新のログファイルは常に~/.los/log/latest/ から参照できるようになっています.
上記の様にtarコマンドで圧縮ファイルを生成してもよいですし,最近はテキストファイルのアップロード場所として gist.github.com もよく利用されます.
gist が初めての場合は http://tyoshikawa1106.hatenablog.com/entry/2013/04/10/000026 などが参考になるでしょう.

他には

  $ rviz 2&>1 > rviz.log

として標準出力とエラー出力の両方をリダイレクトしてファイルに書き出す方法もよく利用されます.この場合,全ての出力がファイルに書きだされ画面では見ることができないですね.teeコマンドを使うと入力を標準出力に書き出しながらファイルにも書き出します.

  $ unbuffer rviz 2&>1 | tee rviz.log

unbufferを付けないと,rvizの出力がバッファされてなかなか表示されません.unbufferがインストールされていない場合は,`sudo apt-get install expect-dev` として下さい.

roslaunchはデフォルトでは各ノードの出力を標準出力には表示しません.表示したい場合は,

  $ roslaunch --screen urdf_tutorial xacrodisplay.launch model:=`rospack find pr2_description`/robots/pr2.urdf.xacro

と,screenオプションをつけると良いでしょう.ログファイルを作るのは

  $ roslaunch --screen urdf_tutorial xacrodisplay.launch model:=`rospack find pr2_description`/robots/pr2.urdf.xacro 2>&1 urdf.log

または,

  $ unbuffer roslaunch --screen urdf_tutorial xacrodisplay.launch model:=`rospack find pr2_description`/robots/pr2.urdf.xacro 2>&1 | tee urdf.log

ですね.

大量の添付ファイルや情報を添付することに躊躇する方も多いかもしれませんが,それらの情報がなければ問題を解決できないので嫌がれることはありません.

質問する際には,相手が自分と同じ問題を再現できるか,あるいは再現しなくても状況が理解できるような十分なログを提供しているかをぜひ再確認して,質問には十分すぎる情報を添付してみましょう.


Today, we’ll show some tips on how to ask question on mailing list or message board. If you are beginner and asked question, sometimes you’re required to provide more information. So most of cases, we believe people have trouble because they do know to know how to ask question. One criteria is “Do you provide enough information that others can RE-PRODUCE your problem”. Let’s see some examples.

If you’re using general program, which someone may using. Information such as

  I executed rviz program by
  $ rviz

Or,

  I typed as follows
  $ roslaunch urdf_tutorial xacrodisplay.launch model:=`rospack find pr2_description`/robots/pr2.urdf.xacro

enable others reproduce your situation.

If you’re using a program that no other people is using, you can create compressed files as running following command at catkin workspace and attach your question e-mails.

  $ tar -cvzf my_package.tgz ./src

If you’re asking to the mailing list or board which can not use attached file, a common way is to upload a entire source code to GitHub, if you are not familiar with GitHub, http://qiita.com/dev-neko/items/28ac253ea295ad6c2b73 may help.

If your code contains non-disclosed information and does not allow to upload on public place, you can re-define the problem without private information and upload that pgram. Or, you may ask for professional consultants as us.

Sometimes, the problem can be solved by looking at output log of the program, without re-produce the situation. In this case, it is very important not to edit your self by judging this part is important and this part is not, but to put entire log information.

To get output log of ROS program has several ways.

If you started your programs with roslaunch, you can find `logging to..` message as follows

  $ roslaunch urdf_tutorial xacrodisplay.launch model:=`rospack find pr2_description`/robots/pr2.urdf.xacro
  ... logging to /home/tork-a/.ros/log/abfd7cb2-b476-11e6-907c-e4a7a00bd84e/roslaunch-ubuntu-14449.log

Then, if you provide all files under /home/tork-a/.ros/log/abfd7cb2-b476-11e6-907c-e4a7a00bd84e/ directory, people who questions also understand what exactly going one. You may find latest logfile from ~/.los/log/latest/
You may use tar command as we described earlier or gist.github.com is widely used recent days as a public textfile upload service.
If you haven’t used gist, you can refer http://tyoshikawa1106.hatenablog.com/entry/2013/04/10/000026

Other way is to run command like

  $ rviz 2&>1 > rviz.log

to output both standard output and error to files. In this command all information is redirected to the file and no message appeared to the file. tee command will split input information into both standard output and file

  $ unbuffer rviz 2&>1 | tee rviz.log

without unbuffer command, rviz output is buffered and there is delay in the message. If you do not have unbuffer command, try`sudo apt-get install expect-dev`.

sometimes roslaunch do not outputs standard output information of each node, to enable this,use –screen option as follows.

  $ roslaunch --screen urdf_tutorial xacrodisplay.launch model:=`rospack find pr2_description`/robots/pr2.urdf.xacro

To create log file, you can use

  $ roslaunch --screen urdf_tutorial xacrodisplay.launch model:=`rospack find pr2_description`/robots/pr2.urdf.xacro 2>&1 urdf.log

or

  $ unbuffer roslaunch --screen urdf_tutorial xacrodisplay.launch model:=`rospack find pr2_description`/robots/pr2.urdf.xacro 2>&1 | tee urdf.log

Sometimes people hesitate to attach large text files or information, but without that information, we can not solve your problem. So everyone need huge information.

Whenever you ask someting, please keep in your mind that “Does other people can reproduce your program?” “Did you provide enough information that equivalent to reproduce your program” and attach enough information with your question.

ROS Workshop Schedule, from October to December 20162016年10月-12月のROSワークショップ日程
TORK to co-host Toyota HSR workshop for usersトヨタ HSR ユーザ向けセミナを行いました

著者について

Kei Okada administrator