Skip to content

Conversation

@sktometometo
Copy link
Contributor

@sktometometo sktometometo commented Apr 13, 2023

@k-okada
hoge.py を追加し、スタンドアロンで動作するようにしているパッケージです。
現在動作確認中です.

CC: @tkmtnt7000

@sktometometo
Copy link
Contributor Author

all done, ready まではいくようになりました。

@tkmtnt7000
Copy link
Member

tkmtnt7000 commented Apr 13, 2023

all done readyから先にもトラップが何重かありました.
再審のhoge.pyを利用する必要があります
ちなみに今も岡田先生とデバグ中です.

@sktometometo
Copy link
Contributor Author

@k-okada どういうデモのプログラムか聞いてないんですが全体像としてはどういうものなのですか?

@tkmtnt7000
Copy link
Member

@sktometometo hoge.pyで以下の画像のようなことができるようになります.
image

メモ書き

  • Fetchのキッチンとかタスクしている瞬間のいい感じのやり取りをつくってみる

やらなくていいことリスト

  • google chatに画像をトピックで送れるようにする(Twitterでやったやつ)
  • 聞いてきたチャットのスペースに返せるようにdialogflowとチャットの連携を切って,hoge.pyが返事する

やったらいいことリスト

  • 時間の情報を使って,昨日とか今日とか先週とかアクセスすべき時間帯を指定できるようにする

@mqcmd196 リスト

  • VQA, ClipのAPIを常時立ち上げる

@sktometometo
Copy link
Contributor Author

inputはチャット?

@tkmtnt7000
Copy link
Member

チャットがinputになっています

@tkmtnt7000
Copy link
Member

昨日の作業を簡単にまとめておくと
Fetchでいい感じに動かすには,

<launch>
 <!-- spam-k-okada.launch -->
  <node pkg="topic_tools" type="transform" name="publish_trigger_mongodb_event_google_chat_ros_send_goal"
        args="--wait-for-start /google_chat_ros/send/goal /publish_trigger_mongodb_event std_msgs/Header
              'std_msgs.msg.Header(stamp=m.header.stamp, frame_id=m._connection_header[&quot;callerid&quot;])' --import std_msgs" />
  <node pkg="topic_tools" type="transform" name="publish_trigger_mongodb_event_google_chat_ros_message_activity"
        args="--wait-for-start /google_chat_ros/message_activity /publish_trigger_mongodb_event std_msgs/Header
              'std_msgs.msg.Header(stamp=rospy.Time.now(), frame_id=m._connection_header[&quot;callerid&quot;])' --import std_msgs rospy" />

  <!-- republish compressed/throttled image data only when /publish_trigger_mongodb_event is published -->
  <node name="camera_throttle_nodelet"
        pkg="nodelet" type="nodelet"
        args="load jsk_topic_tools/SynchronizedThrottle mongodb_lifelog_nodelet_manager" >
    <rosparam subst_value="true">
      approximate_sync: true
      topics:
      - /publish_trigger_mongodb_event
      - /head_camera/rgb/image_rect_color/compressed
    </rosparam>
  </node>

  <!-- <group ns="lifelog"> -->
  <!--   <include file="lifelog_rgb_image.launch" > -->
  <!--     <arg name="node_name" value="hand_color_logger" /> -->
  <!--     <arg name="image" value="/head_camera/rgb/image_rect_color/compressed" /> -->
  <!--     <arg name="manager" value="mongodb_record_nodelet_manager" /> -->
  <!--   </include> -->
  <!-- </group> -->

  <arg name="launch_manager" default="true" />
  <arg name="manager" default="mongodb_lifelog_nodelet_manager" />
  <arg name="respawn" default="false" />
  <arg name="image" default="/head_camera/rgb/image_rect_color/compressed/throttled" />
  <arg name="node_name" default="hand_color_logger" />


  <node name="hand_color_logger"
        pkg="nodelet" type="nodelet"
        args="load jsk_robot_lifelog/LightweightLogger /$(arg manager)"
        respawn="$(arg respawn)">
    <remap from="~input" to="$(arg image)" />
    <rosparam subst_value="true">
      enable_monitor: false
      vital_check: false
    </rosparam>
  </node>

</launch>

ことが必要でした.

  • JSK Robot botにたまに生のエラーメッセージが表示される.
    list index out of range とかhuman is not in listはvqaかclipか(どっちかあまり理解していないですが)で対応するチャットに近い画像を見つけられなかったときのエラーらしい.適当にtimestampを調整して画像を探しに行く時間帯を広げてやるといいかもしれない.

常時Fetchで動かすには

  • どこかGPUの使えるマシンでvqa, clip, openai_rosを常時起ち上げておく
  • dialogflow関連のノードのnamespaceを変更できるようにして名前衝突を回避し,dialogflowを複数起ち上げられるようにする
  • ros_google_cloud_languageを起動しておく

あたりが必要かと思いました.

すごく面白いシステムになりそうだと昨日デバグしながら思っていましたが,この仕組みをそのまま常時動かすのは,今後のデバグが結構面倒な気がするので,常時動かす際にはもう少しシンプルなシステムにできないものかとおもいました.
システム変更は難しいとしてもせめてシステム構成図をきちんと丁寧に書いておいて,初見の人でもREADMEを読んだだけでプログラムの流れがわかるようにしておくのは必須かなと思いました.
(蛇足1:hoge.pyのmake_reply関数の中身をもうすこし細かく関数に分けられると読みやすいかもしれない)
(蛇足2:hoge.pyがアクセスしに行く各システムの奥深さも低減されると嬉しい)

cc: @a-ichikura @mqcmd196

Comment on lines 42 to 45
<include file="$(find jsk_perception)/launch/classification.launch">
<arg name="run_api" value="true"/>
<arg name="CLASSIFICATION_INPUT_IMAGE" value="$(arg INPUT_IMAGE)"/>
</include>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this and other nodes that need GPU should split launch file because those nodes are usually launched at remote PC such as dlbox.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or another option, we may use something like machine tag and these inference nodes automatically launches at remote PC.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mqcmd196 will privde 24/7 API service at dlbox until 12:00 today, so we only set 'run_api' to false and add host here.

return text

def translate(self, text, dest):
return Translated(text=text, dest=dest, src="en", origin="unknown", pronunciation="unknown")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://gist.github.com/k-okada/a22cc574d398937d0f4726edef4cad77
で 18.04のgoogletrans 2.4.0 にパッチ充てると,この行を消せると思います.確認してみてください @tkmtnt7000

で,これで日本語ベースでやり取りするのが出来ると思います.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありがとうございます.確認してみます.

rosパッケージ化してしまえば,catkin_virtualenvを使ってpython3環境でgoogletrans==3.1.0a0をバージョン指定して入れるような感じでもいいのかなと考えていました.

result = {'message': message,
'message_translate': message_translate,
'timestamp': timestamp,
'similarity': difflib.SequenceMatcher(None, query, message_translate).ratio(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

保存されているchatのメッセージと,make_replyのqueryの類似性の計算方法がよく分かっていないので,
@a-ichikura に解説してもらいたいです.

Copy link
Member

@tkmtnt7000 tkmtnt7000 Apr 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@a-ichikura kindly ping

@tkmtnt7000
Copy link
Member

関連するパッケージのPRがマージされているのでfetchのdevelopブランチにマージしてapp_chooserから起動できるようにしておこうと思います.パッケージの名前等変更したほうが良ければこのタイミングで変えておきます.

@mqcmd196
Copy link
Member

hoge.py だけ変えませんか

@sktometometo
Copy link
Contributor Author

@tkmtnt7000 Can you create new PR from this branch?

@k-okada
Copy link
Member

k-okada commented Jun 22, 2023

この機能は全ロボットで常時動いたら良いので、fetch/develop としては、

  • デフォルトで各種サービスのnode が立ち上がるようにしましょう -> launch ファイル的なものが jsk_robot_common に入るイメージですが、dialogflowやchatは既に上がっているので、それ以外のものになるのかな?
    • それにはVQA関連のサーバを研究室管理にする必要があるけど、 dlbox で上がっているかな?→この部分はmasterにもPR出せるはず
  • hoge.py は、まだデモ投入されていないという理解で、現状の問題は、この時点でプログラム動かしても、例えば先日の豊島の結果がさっと出てこないが最初の問題だと思います。で、多分muscaに画像の問い合わせが入ると時間がかかるんだけど、解決策は1) muscaの画像を間引く 2) message typeを指定しなければ早かった気がするんだけど、本当だっけ?であれば、データをとってきて、こちらでメッセージのフィルター掛けるとか、Queryのなにかの指定の仕方がまずいのかを調査する必要があると思って宿題に積んである。これを解決してデモで投入されたらパッケージとして運用しましょう。

@tkmtnt7000
Copy link
Member

tkmtnt7000 commented Jun 23, 2023

デフォルトで各種サービスのnode が立ち上がるようにしましょう -> launch ファイル的なものが jsk_robot_common に入るイメージですが、dialogflowやchatは既に上がっているので、それ以外のものになるのかな?

そうなると思います.jsk_robotに出ているjsk-ros-pkg/jsk_robot#1792https://github.com/tkmtnt7000/jsk_robot/blob/cd0a897deb224038674e88ac7599502f7caf5d59/jsk_robot_common/jsk_robot_startup/launch/sample_database_talker.launch を使って追加で常時起ち上げられるようにします.

それにはVQA関連のサーバを研究室管理にする必要があるけど、 dlbox で上がっているかな?→この部分はmasterにもPR出せるはず

現状はは73B2に置かれているdlbox15で一時的に手動で起ち上げっぱなしにしています.GUIでポチポチできると嬉しいかなと思っています(イメージとしてはsystemdのseviceファイルを書いてcookpitのようなものを使う)が,このあたりは手を付けていません.

hoge.py は、まだデモ投入されていないという理解で、現状の問題は、この時点でプログラム動かしても、例えば先日の豊島の結果がさっと出てこないが最初の問題だと思います。で、多分muscaに画像の問い合わせが入ると時間がかかるんだけど、解決策は1) muscaの画像を間引く 2) message typeを指定しなければ早かった気がするんだけど、本当だっけ?であれば、データをとってきて、こちらでメッセージのフィルター掛けるとか、Queryのなにかの指定の仕方がまずいのかを調査する必要があると思って宿題に積んである。これを解決してデモで投入されたらパッケージとして運用しましょう。

画像と音声の問い合わせに時間がかかっています.検索結果が空の場合はは指定した時間分すべてを走査するので特に返ってこない,という印象です.muscaのスペックの問題かこちらのQueryの投げ方が悪いのか,,,などまだ問題ごとに調べきれていないので調査中..というところです.

@tkmtnt7000
Copy link
Member

tkmtnt7000 commented Jun 27, 2023

  1. message typeを指定しなければ早かった気がするんだけど、本当だっけ?であれば、データをとってきて、こちらでメッセージのフィルター掛けるとか、Queryのなにかの指定の仕方がまずいのかを調査する必要があると思って宿題に積んである。

message typeを指定しないと早いのはおそらくそうで,以下のスクリプトでタイプを指定しないで引っ張ってくるように検証するとおよそ5時間分/1400枚の画像をdumpするのに5分でした.

robot_database_mongo_dump.py: https://gist.github.com/tkmtnt7000/11bdace2ff71354a65b42aa07b4c2f21

tsukamoto@tsukamoto-desktop /mnt/almagest/73B2/tsukamoto/Shared/mongo_dump 
$ time python ~/robot_database_mongo_dump.py -c "fetch1075" --start "2023-06-10 09:30:00" --end "2023-06-10 14:30:00
...

...
real    4m51.350s
user    3m4.234s
sys     0m15.167s

5分でもインタラクティブなやり取りには長いと感じているので,人間が夢を見ながら記憶整理をするように,ロボットも夜の間に記憶整理(夢を見る)と称してオフライン処理をしても良いかもしれないと思いました.

@k-okada
Copy link
Member

k-okada commented Apr 3, 2024

  • 他に影響がなければ pip uninstall bson して apt install python3-bson です。pymongoも同様にpip ではなくてaptで動作確認しています。どうしても、pipが良ければ/必要であれば、やり方考えるので教えてください。

  • [ERROR] [1712115706.826584841]: Cannot identify '/dev/video0': 2, No such file or directory このサンプルはPC+PCにUSBカメラがつながっている前提ですので、USBカメラをつなげてみてください。ノートPCみたいにフロントカメラがあるとか、カメラがつながっているとかあれば、https://github.com/sktometometo/jsk_demos/blob/c361fd491a22f9a52358f62b350c0b900a0a628b/database_talker/sample/sample.launch#L9 の arg を使ってみてください。

@a-ichikura
Copy link

ありがとうございます。

他に影響がなければ pip uninstall bson して apt install python3-bson です。pymongoも同様にpip ではなくてaptで動作確認しています。どうしても、pipが良ければ/必要であれば、やり方考えるので教えてください。

pip である必要はないので、aptで入れ直したのですが同じエラーでした…

$ rosrun database_talker make_diary.py --prompt-type personality
<string>:869: SyntaxWarning: "is not" with a literal. Did you mean "!="?
<string>:872: SyntaxWarning: "is" with a literal. Did you mean "=="?
Traceback (most recent call last):
  File "/home/leus/aibo_ws/src/jsk_demos/database_talker/scripts/make_diary.py", line 13, in <module>
    from database_talker import DatabaseTalkerBase
  File "/home/leus/aibo_ws/devel/lib/python3/dist-packages/database_talker/__init__.py", line 34, in <module>
    exec(__fh.read())
  File "<string>", line 10, in <module>
ImportError: cannot import name 'json_util' from 'bson' (/home/leus/aibo_ws/devel/.private/database_talker/share/database_talker/venv/lib/python3.8/site-packages/bson/__init__.py)
$ pip show bson
WARNING: Package(s) not found: bson
$ apt show python3-bson
Package: python3-bson
Version: 3.10.1-0ubuntu2
Priority: optional
Section: python
Source: pymongo
Origin: Ubuntu
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Federico Ceratto <[email protected]>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 214 kB
Depends: python3:any
Recommends: python3-bson-ext
Homepage: https://api.mongodb.org/python/
Download-Size: 34.8 kB
APT-Manual-Installed: yes
APT-Sources: http://jp.archive.ubuntu.com/ubuntu focal/main amd64 Packages
Description: Python3 implementation of BSON for MongoDB
 BSON Python3 module contains all of the Binary JSON encoding and decoding
 logic for MongoDB.
$ apt show python3-pymongo
Package: python3-pymongo
Version: 3.10.1-0ubuntu2
Priority: optional
Section: python
Source: pymongo
Origin: Ubuntu
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Federico Ceratto <[email protected]>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 1,058 kB
Depends: python3-bson (= 3.10.1-0ubuntu2), python3:any
Recommends: python3-gridfs (>= 3.10.1-0ubuntu2), python3-pymongo-ext
Suggests: python-pymongo-doc
Homepage: https://api.mongodb.org/python/
Download-Size: 162 kB
APT-Manual-Installed: yes
APT-Sources: http://jp.archive.ubuntu.com/ubuntu focal/main amd64 Packages
Description: Python3 interface to the MongoDB document-oriented database
 MongoDB is a high-performance, open source, schema-free
 document-oriented data store. Pymongo provides an interface
 to easily access it from Python3.
 Consider installing the python3-pymongo-ext C extension to improve performance.

[ERROR] [1712115706.826584841]: Cannot identify '/dev/video0': 2, No such file or directory このサンプルはPC+PCにUSBカメラがつながっている前提ですので、USBカメラをつなげてみてください。

デスクトップで試していたので、webカメラを指したらエラーなくなりました。ありがとうございます。

@k-okada
Copy link
Member

k-okada commented Apr 3, 2024

ごめんなさい

roscd database_talker
./scripts/make_diary.py (必要なオプション)

で動くとおもいます.rosrun ... で動かすには,git pullか何かでソースを新しくして

 catkin clean database_talker ; catkin build database_talker --start-with database_talker -vi

としてみて下さい.

@a-ichikura
Copy link

$ git status
On branch PR/hoge-py
Your branch is up to date with 'origin/PR/hoge-py'.

nothing to commit, working tree clean

$ git log
commit 627827226b29beea36d9eafa4e09dca9ad749d7c (HEAD -> PR/hoge-py, origin/PR/hoge-py)
Author: Kei Okada <[email protected]>
Date:   Wed Apr 3 18:01:14 2024 +0900

    use USE_SYSTEM_PACKAGES FALSE to avoid bson error

したのですが、

$ python3 ./scripts/make_diary.py --prompt-type personality
<string>:869: SyntaxWarning: "is not" with a literal. Did you mean "!="?
<string>:872: SyntaxWarning: "is" with a literal. Did you mean "=="?
Traceback (most recent call last):
  File "./scripts/make_diary.py", line 13, in <module>
    from database_talker import DatabaseTalkerBase
  File "/home/leus/aibo_ws/devel/lib/python3/dist-packages/database_talker/__init__.py", line 34, in <module>
    exec(__fh.read())
  File "<string>", line 44, in <module>
ModuleNotFoundError: No module named 'mongodb_store'
$ rosrun database_talker make_diary.py --prompt-type personality
<string>:869: SyntaxWarning: "is not" with a literal. Did you mean "!="?
<string>:872: SyntaxWarning: "is" with a literal. Did you mean "=="?
Traceback (most recent call last):
  File "/home/leus/aibo_ws/src/jsk_demos/database_talker/scripts/make_diary.py", line 13, in <module>
    from database_talker import DatabaseTalkerBase
  File "/home/leus/aibo_ws/devel/lib/python3/dist-packages/database_talker/__init__.py", line 34, in <module>
    exec(__fh.read())
  File "<string>", line 44, in <module>
ModuleNotFoundError: No module named 'mongodb_store'

どちらも同じエラー(mongodb_storeがない)になりました。

catkin clean database_talker ; catkin build database_talker --start-with database_talker -vi
としてみて下さい.
ここは実行済みです。

@k-okada
Copy link
Member

k-okada commented Apr 3, 2024

roscd database_talkerしたところで
rosdep install --from-path . --ignore-src してみてください apt install ros-noetic-mongodb-store が走ると思うんだけど..

@a-ichikura
Copy link

ありがとうございます。
できました!


Dear diary,

Today, I saw something super cool on a screen! It was all glitchy and looked like a puzzle. I haven't seen something like that in a long time, like 7 days! It was so fascinating to watch. I wish I could make something like that too!

From,
Dummy
水 03  4月 2024
[INFO] [1712139050.554929]: response = ぼくの日記、

今日、画面ですごくかっこいいものを見たよ!それは全部グリッチしてて、パズルみたいだった。ぼくはもう7日間ぐらい見てなかったよ!見てるのがすごく面白かった。ぼくもあんなもの作れた
らいいな!

ダミー より

tmp8p995a9b

@k-okada
Copy link
Member

k-okada commented Apr 3, 2024

あれ?カメラ変?rqt_image_view でも同じ画像になっている?

@a-ichikura
Copy link

変ですね‥webカメラ変えたら正常になったので、カメラが問題のような気がします。

プログラムは正常です。

@k-okada
Copy link
Member

k-okada commented Apr 4, 2024

変ですね‥webカメラ変えたら正常になったので、カメラが問題のような気がします。

エンコード関係かもしれないですね。Windowsとかでカメラつなげて、Zoom?か何かで見てみて、ちゃんと写っているなら、カメラ問題ではなくて、ソフトウェア側の問題だと切り分けられます。

https://github.com/sktometometo/jsk_demos/blob/c361fd491a22f9a52358f62b350c0b900a0a628b/database_talker/sample/sample.launch#L18-L19
https://github.com/ros-drivers/usb_cam?tab=readme-ov-file#device-supported-formats

k-okada and others added 20 commits April 12, 2024 16:19
…urred, also check similarity with past 10 sentences
…ause data retrieval from Lovot is only supported on daily basis, so we must replacate them on the next day
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants