1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Visual Studio C++を使って、Vrep上のモデルを動かす

Posted at

やりたいこと

3DmodelをVisualStudio community 2017を使って操作したい。

この要求を満たすものとして、Vrepを選びました。
Vrepを選んだ理由

  1. 新規Robotの順運動学計算の確認をするため
  2. メカ屋が作った3Dモデルを使って、簡単に動作確認ができる
  3. 無料で使用できる ※商用使用ではないという条件下で無料

キーワード:Vrep,remoteApi,Visual Studio
このキーワード検索で、ヒットした過去の記事として、以下があります。
(http://moryu-io-studio.hatenablog.com/entry/2017/12/16/221623)
但し、2年前の記事とは言え、その通りに実施しても、コンパイルエラー、Linkエラーなど動かせないという状況だったので、動作できるようにしました。

準備

・Visual Studio community 2017のインストール
・Copellia Sim Vrepのインストール (CoppeliaSim Edu V4.0.0 rev1)
(http://www.coppeliarobotics.com/downloads)
・サンプルに必要となるモデルの取り込み
(https://gallery.autodesk.com/fusion360/projects/1-dof-arm-for-v-rep)
 ※記事の内容を実現するには、1-DoF Arm for V-REPモデルが必要です。また、Fusion360をインストールし、モデルをVrepで読み込めるSTL、またはOBJに変更する必要があります。

結果

Vrepのシミュレーション実行ボタンを押し、Visual Studioでデバッグ実行すると、画面上のアームが、垂直姿勢を中心にして左右に揺れます。
Vrep_SimpleArm.png
本当は、映像を出したかったのですが、分かったら、再度編集予定。

手順

Vrep側の設定

本設定は、モデルをインストールでき、こちらの方の作業を実施した後の話になります。(http://moryu-io-studio.hatenablog.com/entry/2017/12/16/221623)
モデルは、BaseとArmに変更しました。BaseとArmの間にJointを追加するとともに、名前をJoint1としています。
image.png
Baseの横には、Child Scriptを埋め込んでいます。
これは、下のように、Baseで右クリックし、>Add>Associated Child Script>Non Threadedを選択します。
image.png
Child Scriptには、以下のみを記述します。
image.png
これは、remoteAPIを使って、Visual StudioからVrepを動かすための設定(Port番号)です。

Visual Studio側の設定

C++のコードは、以下です。
image.png
プロジェクトの構成は、以下です。
image.png
ソースファイル、及びヘッダーファイルにextApi.、expApiPlatform.、expApiApiInternal.hをソリューションに追加しています。

その他(Visual Studioのプロジェクトのプロパティの設定)

構成プロパティ>全般
この中で、
共通言語ランタイムサポート:共通言語ランタイムサポートを使用しないを選択
image.png

C/C++>全般
CoppeliaRobotics\CoppeliaSimEdu\Programming\の下のremoteApiフォルダと
includeフォルダを追加します。※インストールした場所の確認をお願いします。
image.png

C/C++>プリプロセッサ
image.png

以上。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?