s-nakaoka / choreonoid

An integrated graphical robotics application framework
http://choreonoid.org
Other
94 stars 58 forks source link

配布されているコントローラを編集して自作のモデルを制御したい #133

Closed 51ozaki closed 7 years ago

51ozaki commented 7 years ago

クローラのwrlモデルを作りました。 このモデルをOpenRTMで制御したいと考えております.

そこでchoreonoidのソースに含まれているSamleCrawlerJoystickControllerRTC.cppを編集して使いたいのですが

http://www.jvrc.org/tutorials/html-ja/basics/rt-controller.html http://choreonoid.org/ja/manuals/1.5/simulation/crawler-simulation.html

を見ながら作業していたのですが,うまくいきません.

配布されているコントローラのソースコードを編集して使える方法または,それについての情報を教えていただけないでしょうか. よろしくお願いします.

OSはlinux ubuntuです

s-nakaoka commented 7 years ago

配布されているコントローラのソースコードを編集して使える方法または,それについての情報を教えていただけないでしょうか.

ごめんなさい、まだこの件に直接対応するドキュメントはありません。

一般的には、ソースのext以下にsamplesの各フォルダと同様にCMakeLists.txtやソースファイルを配置して、Choreonoid本体といっしょにコンパイルしてしまうのが楽ではあります。

fkanehiro commented 7 years ago

「うまくいきません」がどのようにうまくいかないのか、説明して頂けると答えやすいと思います。

51ozaki commented 7 years ago

choreonoid-1.5.0/sample/OpenRTMにある SampleCrawlerJoystickControllerRTC.cpp SampleCrawlerJoystick.conf SampleCrawlerJoystickControllerRTC.h CMakeLists.txt を入れたディレクトリを/choreonoid-1.5.0/ext/に置き http://choreonoid.org/ja/manuals/1.5/install/build-ubuntu.html のcmake .でエラーが出ます何か足りないでしょうか?

また、SampleCrawlerJoystickControllerRTC.cppのどこを編集すれば良いのかがわかりません idやlinkの名前を入れるところがあるのでしょうか?

fkanehiro commented 7 years ago

cmake . するとどのようなエラーがでるでしょうか?

また何を変えたいのでしょうか?

s-nakaoka commented 7 years ago

すみませんが質問の仕方について以下のページも参考にしてください。 http://www.hyuki.com/writing/techask.html

51ozaki commented 7 years ago

「cmake .するとどのようなエラーがでるでしょうか?」

choreonoid-1.5.0/sample/OpenRTMに入っている

SampleCrawlerJoystickControllerRTC.cpp SampleCrawlerJoystick.conf SampleCrawlerJoystickControllerRTC.h CMakeLists.txt

を入れたディレクトリを/choreonoid-1.5.0/ext/に置き

choreonoidのソースディレクトリ(/choreonoid-1.5.0)上でcmake .したところ

mechatropc-10@mechatropc10-Z97-S01:~$ cd choreonoid-1.5.0/ mechatropc-10@mechatropc10-Z97-S01:~/choreonoid-1.5.0$ cmake . -- Boost version: 1.54.0 -- Found the following Boost libraries: -- system -- filesystem -- program_options -- regex -- thread -- iostreams -- date_time -- python -- Boost version: 1.54.0 -- Found the following Boost libraries: -- chrono -- OPENRTM VERSION 1.1.0 -- OPENRTM_DIR=/opt/ros/indigo -- OpenRTMConfig.cmake found. -- Configrued by configuration mode. -- OpenRTM-aist configuration done -- OPENRTM VERSION 1.1.0 CMake Error at ext/UMRS/CMakeLists.txt:27 (add_library): add_library cannot create target "SampleCrawlerJoystickControllerRTC" because another target with the same name already exists. The existing target is a shared library created in source directory "/home/mechatropc-10/choreonoid-1.5.0/sample/OpenRTM". See documentation for policy CMP0002 for more details. Call Stack (most recent call first): ext/UMRS/CMakeLists.txt:47 (add_cnoid_sample_rtc)

CMake Error: File /home/mechatropc-10/choreonoid-1.5.0/ext/UMRS/OpenRTM-SampleCrawlerJoystick.cnoid does not exist. CMake Error at ext/UMRS/CMakeLists.txt:48 (configure_file): configure_file Problem configuring file

-- Configuring incomplete, errors occurred! See also "/home/mechatropc-10/choreonoid-1.5.0/CMakeFiles/CMakeOutput.log". See also "/home/mechatropc-10/choreonoid-1.5.0/CMakeFiles/CMakeError.log". mechatropc-10@mechatropc10-Z97-S01:~/choreonoid-1.5.0$

と出たのでSampleCrawlerと書かれているところを全部UMRSSampleCrawlerに変えてもう一度やると

mechatropc-10@mechatropc10-Z97-S01:~$ cd choreonoid-1.5.0/ mechatropc-10@mechatropc10-Z97-S01:~/choreonoid-1.5.0$ cmake . -- Boost version: 1.54.0 -- Found the following Boost libraries: -- system -- filesystem -- program_options -- regex -- thread -- iostreams -- date_time -- python -- Boost version: 1.54.0 -- Found the following Boost libraries: -- chrono -- OPENRTM VERSION 1.1.0 -- OPENRTM_DIR=/opt/ros/indigo -- OpenRTMConfig.cmake found. -- Configrued by configuration mode. -- OpenRTM-aist configuration done -- OPENRTM VERSION 1.1.0 CMake Error: File /home/mechatropc-10/choreonoid-1.5.0/ext/UMRS/OpenRTM-UMRSSampleCrawlerJoystick.cnoid does not exist. CMake Error at ext/UMRS/CMakeLists.txt:48 (configure_file): configure_file Problem configuring file

CMake Error: File /home/mechatropc-10/choreonoid-1.5.0/ext/UMRS/UMRSSampleCrawlerJoystick.conf does not exist. CMake Error at ext/UMRS/CMakeLists.txt:49 (configure_file): configure_file Problem configuring file

-- Configuring incomplete, errors occurred! See also "/home/mechatropc-10/choreonoid-1.5.0/CMakeFiles/CMakeOutput.log". See also "/home/mechatropc-10/choreonoid-1.5.0/CMakeFiles/CMakeError.log". mechatropc-10@mechatropc10-Z97-S01:~/choreonoid-1.5.0$

となりました。

「また何を変えたいのでしょうか?」 配布されているSampleCrawlerJoystickControllerRTC.cppでは同じく配布されているcrawler.wrlしか制御できないのではと考え、自分で作ったクローラモデルを制御するために 例えば

51ozaki commented 7 years ago

「また何を変えたいのでしょうか?」

配布されているSampleCrawlerJoystickControllerRTC.cppでは同じく配布されているcrawler.wrlしか制御できないのではと考えました。 自分で作ったクローラモデルを制御するためにSampleCrawlerJoystickControllerRTC.cppのどこかを変えたいと思っています。

例えば SampleCrawlerJoystickControllerRTC.cppのどこかにcrawler_L Jointまたは jointId 2と書き加えるなど

以下、自作したモデルの左クローラ部

DEF crawler_body_to_crawler_L Joint { jointType "pseudoContinuousTrack" jointAxis 0.0 1.0 0.0 jointId 2 translation 0.0 0.175 0.06 rotation 0 1 0 0 ulimit 1e+16 llimit -1e+16 uvlimit inf lvlimit -inf children [ DEF crawler_L Segment { mass 1.0 centerOfMass 0.0 0.0 0.0 momentsOfInertia [1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0] children [ Transform { scale 1.0 1.0 1.0 translation 0.0 0.0 0.0 rotation 0 1 0 0 children [ Inline { url "crawler-crawler_L-craw

fkanehiro commented 7 years ago

エラーメッセージをよく読みましょう。 「CMake Error: File /home/mechatropc-10/choreonoid-1.5.0/ext/UMRS/OpenRTM-UMRSSampleCrawlerJoystick.cnoid does not exist.」 や 「CMake Error: File /home/mechatropc-10/choreonoid-1.5.0/ext/UMRS/UMRSSampleCrawlerJoystick.conf does not exist.」 と出ていますので、これらのディレクトリやファイルがちゃんと存在するか確認する必要があります。 そもそもこれらのファイルが必要ないのであれば、CMakeLists.txtから削除する必要があります。

サンプルでは、JointIdが0と1がクローラであることが前提になっています。 https://github.com/s-nakaoka/choreonoid/blob/master/sample/OpenRTM/SampleCrawlerJoystickControllerRTC.cpp#L70-L71 クローラのJointIdが2であれば、履帯の速度(velocities)を設定する際の添字を2にしたり、velocitiesの長さを適切に設定したりする必要があると思います。 https://github.com/s-nakaoka/choreonoid/blob/master/sample/OpenRTM/SampleCrawlerJoystickControllerRTC.cpp#L52

51ozaki commented 7 years ago

SampleCrawlerJoystickControllerRTC.cpp SampleCrawlerJoystick.conf SampleCrawlerJoystickControllerRTC.h のコンパイルには成功しました.

EclipseのSystem Diagramで,作成したBodyRTCをSampleCrawlerJoystickControllerRTCと接続したいのですが私が作成したBodyRTCには「dq」ポートがありません. BodyRTCのポートの増やし方,又はその情報の場所を教えていただけませんでしょうか?

eclipse

hattorishizuko commented 7 years ago

SampleCrawlerJoystickControllerで説明いたします。

BodyRTCItemのプロパティで、”設定モード”を”設定ファイルを使用”にします。 設定ファイル名に、SampleCrawlerJoystick.confを指定します。 このファイルには、 in-port = dq:JOINT_VELOCITY connection = dq:SampleCrawlerJoystickControllerRTC0:dq connection = JoystickRTC0:axes:SampleCrawlerJoystickControllerRTC0:axes と書かれています。 一番上の行が、dqポートの作成を指定している行です。 connectionはポート接続の指定なので、System Diagramを使用する場合は不要です。

fkanehiro commented 7 years ago

これってマニュアルのどこに書かれていますでしょうか。 どこにあったっけな、と思って探すのが結構大変なので、マニュアルに検索機能があるとよいと思うのですが如何でしょうか。

51ozaki commented 7 years ago

写真1に示すようにアドバイス通り行いうまくいったと思ったのですがクローラは動きませんでした. 写真2に示すようにコントローラからの入力は来ているようです。

おそらくモデルがおかしいと思うのですが, "pseudoContinuousTrack"の場所はあっているのでしょうか? また他の場所を編集しなければいけないのでしょうか?

写真1 screenshot from 2017-02-15 13_43_53

写真2 screenshot from 2017-02-15 17_30_09

VRML V2.0 utf8

PROTO Joint [ exposedField SFVec3f center 0 0 0 exposedField MFNode children [] exposedField MFFloat llimit [] exposedField MFFloat lvlimit [] exposedField SFRotation limitOrientation 0 0 1 0 exposedField SFString name "" exposedField SFRotation rotation 0 0 1 0 exposedField SFVec3f scale 1 1 1 exposedField SFRotation scaleOrientation 0 0 1 0 exposedField MFFloat stiffness [ 0 0 0 ] exposedField SFVec3f translation 0 0 0 exposedField MFFloat ulimit [] exposedField MFFloat uvlimit [] exposedField SFString jointType "" exposedField SFInt32 jointId -1 exposedField SFVec3f jointAxis 0 0 1

exposedField SFFloat gearRatio 1 exposedField SFFloat rotorInertia 0 exposedField SFFloat rotorResistor 0 exposedField SFFloat torqueConst 1 exposedField SFFloat encoderPulse 1 ] { Transform { center IS center children IS children rotation IS rotation scale IS scale scaleOrientation IS scaleOrientation translation IS translation } }

PROTO Segment [ field SFVec3f bboxCenter 0 0 0 field SFVec3f bboxSize -1 -1 -1 exposedField SFVec3f centerOfMass 0 0 0 exposedField MFNode children [ ] exposedField SFNode coord NULL exposedField MFNode displacers [ ] exposedField SFFloat mass 0 exposedField MFFloat momentsOfInertia [ 0 0 0 0 0 0 0 0 0 ] exposedField SFString name "" eventIn MFNode addChildren eventIn MFNode removeChildren ] { Group { addChildren IS addChildren bboxCenter IS bboxCenter bboxSize IS bboxSize children IS children removeChildren IS removeChildren } }

PROTO Surface [ field SFVec3f bboxCenter 0 0 0 field SFVec3f bboxSize -1 -1 -1 field MFNode visual [ ] field MFNode collision [ ] eventIn MFNode addChildren eventIn MFNode removeChildren ] { Group { addChildren IS addChildren bboxCenter IS bboxCenter bboxSize IS bboxSize children IS visual removeChildren IS removeChildren } }"pseudoContinuousTrack"

PROTO Humanoid [ field SFVec3f bboxCenter 0 0 0 field SFVec3f bboxSize -1 -1 -1 exposedField SFVec3f center 0 0 0 exposedField MFNode humanoidBody [ ] exposedField MFString info [ ] exposedField MFNode joints [ ] exposedField SFString name "" exposedField SFRotation rotation 0 0 1 0 exposedField SFVec3f scale 1 1 1 exposedField SFRotation scaleOrientation 0 0 1 0 exposedField MFNode segments [ ] exposedField MFNode sites [ ] exposedField SFVec3f translation 0 0 0 exposedField SFString version "1.1" exposedField MFNode viewpoints [ ] ] { Transform { bboxCenter IS bboxCenter bboxSize IS bboxSize center IS center rotation IS rotation scale IS scale scaleOrientation IS scaleOrientation translation IS translation children [ Group { children IS viewpoints } ] } }

PROTO ExtraJoint [ exposedField SFString link1Name "" exposedField SFString link2Name "" exposedField SFVec3f link1LocalPos 0 0 0 exposedField SFVec3f link2LocalPos 0 0 0 exposedField SFString jointType "xyz" exposedField SFVec3f jointAxis 1 0 0 ] { }

DEF crawler_body Humanoid { humanoidBody [ DEF crawler_body_Joint Joint { jointType "free" translation 0.0 0.0 0.0 rotation 0 1 0 0 children [ DEF crawler_body_Segment Segment { mass 17.0 centerOfMass 0.0 0.0 0.06 momentsOfInertia [1.0 0.0 0.0 0.0 1.0 -1.0 0.0 -1.0 1.0] children [ Transform { scale 1.0 1.0 1.0 translation 0.0 0.0 0.06 rotation 0 1 0 0 children [ Inline { url "crawler-crawler_body-crawler-crawler_body_visual.wrl" } ] } ] }

    DEF crawler_body_to_crawler_L Joint {
      jointType "pseudoContinuousTrack"
      jointAxis 0.0 1.0 0.0
      jointId 2
      translation 0.0 0.175 0.06
      rotation 0 1 0 0
      ulimit 1e+16
      llimit -1e+16
      uvlimit inf
      lvlimit -inf
      children [
        DEF crawler_L Segment {
          mass 1.0
          centerOfMass 0.0 0.0 0.0
          momentsOfInertia [1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0]
          children [
            Transform {
              scale 1.0 1.0 1.0
              translation 0.0 0.0 0.0
              rotation 0 1 0 0
              children [
                Inline {
                  url "crawler-crawler_L-crawler-crawler_L_visual.wrl"
                }
              ]
            }
          ]
        }

        DEF crawler_Ltoflipper_L1 Joint {
          jointType "rotate"
          jointAxis 0.0 1.0 0.0
          jointId 0
          translation 0.23 0.04 1.2490009027e-16
          rotation 0 1 0 0
          ulimit 1e+16
          llimit -1e+16
          uvlimit inf
          lvlimit -inf
          childrecrawler.wrln [
            DEF flipper_L1 Segment {
              mass 1.0
              centerOfMass 0.0 0.0 0.09
              momentsOfInertia [1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0]
              children [
                Transform {
                  scale 1.0 1.0 1.0
                  translation 0.0 0.0 0.09
                  rotation -0.0 -0.0 1.0 1.57
                  children [
                    Inline {
                      url "crawler-flipper_L1-crawler-flipper_L1_visual.wrl"
                    }
                  ]
                }
              ]
            }

          ]![screenshot from 2017-02-15 17_30_09](https://cloud.githubusercontent.com/assets/23718477/22921907/e5b58c00-f2de-11e6-93b0-422466e54969.png)
        }
        DEF crawler_Ltoflipper_L2 Joint {
          jointType "rotate"
          jointAxis 0.0 1.0 0.0
          jointId 1
          translation -0.23 0.04 1.2490009027e-16
          rotation 0 1 0 0
          ulimit 1e+16
          llimit -1e+16
          uvlimit inf
          lvlimit -inf
          children [
            DEF flipper_L2 Segment {
              mass 1.0
              centerOfMass 0.0 0.0 0.09
              momentsOfInertia [1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0]
              children [
                Transform {
                 crawler.wrl scale 1.0 1.0 1.0
                  translation 0.0 0.0 0.09
                  rotation -0.0 -0.0 1.0 1.57
                  children [
                    Inline {
                      url "crawler-flipper_L2-crawler-flipper_L2_visual.wrl"
                    }
                  ]
                }
              ]
            }

          ]
        }
      ]
    }
    DEF crawler_body_to_crawler_R Joint {
      jointType "pseudoContinuousTrack"
      jointAxis 0.0 1.0 0.0
      jointId 5
      translation 0.0 -0.175 0.06
      rotation 0 1 0 0
      ulimit 1e+16
      llimit -1e+16
      uvlimit inf
      lvlimit -inf
      children [
        DEF crawler_R Segment {
          mass 1.0
          centerOfMass 0.0 0.0 0.0
          momentsOfInertia [1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0]
          children [
            Transform {
              scale 1.0 1.0 1.0
              translation 0.0 0.0 0.0
              rotation 0 1 0 0
              children [
                Inline {
                  url "crawler-crawler_R-crawler-crawler_R_visual.wrl"
                }
              ]
            }
          ]
        }

        DEF crawler_Rtoflipper_R1 Joint {
          jointType "rotate"
          jointAxis 0.0 1.0 0.0
          jointId 3
          translation 0.23 -0.04 1.2490009027e-16
          rotation 0 1 0 0
          ulimit 1e+16
          llimit -1e+16
          uvlimit inf
          lvlimit -inf
          children [
            DEF flipper_R1 Segment {
              mass 1.0
              centerOfMass 0.0 0.0 0.09
              momentsOfInertia [1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0]
              children [
                Transform {
                  scale 1.0 1.0 1.0
                  translation 0.0 0.0 0.09
                  rotation -0.0 -0.0 1.0 1.57
                  children [
                    Inline {
                      url "crawler-flipper_R1-crawler-flipper_R1_visual.wrl"
                    }
                  ]
                }
              ]
            }

          ]
        }
        DEF crawler_Rtoflipper_R2 Joint {
          jointType "rotate"
          jointAxis 0.0 1.0 0.0
          jointId 4
          translation -0.23 -0.04 1.2![screenshot from 2017-02-15 17_30_09](https://cloud.githubusercontent.com/assets/23718477/22921907/e5b58c00-f2de-11e6-93b0-422466e54969.png)490009027e-16
          rotation 0 1 0 0
          ulimit 1e+16
          llimit -1e+16
          uvlimit inf
          lvlimit -inf
          children [
            DEF flipper_R2 Segment {
              mass 1.0
              centerOfMass 0.0 0.0 0.09
              momentsOfInertia [1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0]
              children [
                Transform {
                  scale 1.0 1.0 1.0
                  translation 0.0 0.0 0.09
                  rotation -0.0 -0.0 1.0 1.57
                  children [
                    Inline {
                      url "crawler-flipper_R2-crawler-flipper_R2_visual.wrl"
                    }
                  ]
                }
              ]
            }

          ]
        }
      ]
    }
  ]
}

]

List up all the joints' name you use

joints [
USE crawler_body_Joint,
USE crawler_Ltoflipper_L1,
USE crawler_Ltoflipper_L2,
USE crawler_body_to_crawler_L,
USE crawler_Rtoflipper_R1,
USE crawler_Rtoflipper_R2,
USE crawler_body_to_crawler_R

]

List up all the segments' name you use

segments [ USE crawler_body_Segment, USE crawler_L, USE flipper_L1, USE flipper_L2, USE crawler_R, USE flipper_R1, USE flipper_R2 ] name "crawler_body" version "1.0" }

https://gist.github.com/51ozaki/e10608e79a8534462fae7bbe2a4d08b1.js