はじめに
V-REPとROSを連携させることについては以下の記事にまとめられてます。
https://qiita.com/RyuYamamoto/items/8ffc5c4f854b90083590
V-REPでオリジナルのROSメッセージを使う方法は調べてもなかなかまとめられてないので忘れないようにまとめます。
やり方
まず、ワークスペース(今回はcatkin_ws)のsrcに移動して以下を実行。
git clone --recursive https://github.com/CoppeliaRobotics/v_repExtRosInterface.git vrep_ros_interface
更に、v_repExtRosIterface/meta/messages.txtの一番下にオリジナルメッセージ名を追加。
次にCMakeLists.txtの一部にオリジナルメッセージを定義しているパッケージ名(ORIGINAL_MAGS)を以下のように追加。
CMakeLists.txtの一部
find_package(catkin REQUIRED COMPONENTS
roscpp rosmsg image_transport tf cv_bridge message_generation ORIGINAL_MSGS
)
CMakeLists.txtの一部
catkin_package(
CATKIN_DEPENDS roscpp rosconsole cv_bridge image_transport tf brics_actuator roslib actionlib_msgs control_msgs diagnostic_msgs geometry_msgs map_msgs nav_msgs pcl_msgs sensor_msgs shape_msgs std_msgs tf2_geometry_msgs tf2_msgs tf2_sensor_msgs trajectory_msgs visualization_msgs message_runtime ORIGINAL_MSGS
)
次にpacage.xmlにも追加。
pacage.xml
<package>
<name>vrep_ros_interface</name>
<description>V-REP plugin for ROS interface</description>
<maintainer email="marc@coppeliarobotics.com">Marc</maintainer>
<version>3.3.0</version>
<author>Federico Ferri</author>
<license>BSD2</license>
<url>http://www.coppeliarobotics.com</url>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rosmsg</build_depend>
<build_depend>libopencv-dev</build_depend>
<build_depend>cv_bridge</build_depend>
<build_depend>image_transport</build_depend>
<build_depend>tf</build_depend>
<build_depend>actionlib_msgs</build_depend>
<build_depend>control_msgs</build_depend>
<build_depend>diagnostic_msgs</build_depend>
<build_depend>geometry_msgs</build_depend>
<build_depend>map_msgs</build_depend>
<build_depend>nav_msgs</build_depend>
<build_depend>pcl_msgs</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>shape_msgs</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>tf2_geometry_msgs</build_depend>
<build_depend>tf2_msgs</build_depend>
<build_depend>tf2_sensor_msgs</build_depend>
<build_depend>trajectory_msgs</build_depend>
<build_depend>visualization_msgs</build_depend>
<build_depend>message_generation</build_depend>
<build_depend>ORIGINAL_MSGS</build_depend>
<run_depend>roscpp</run_depend>
<run_depend>libopencv-dev</run_depend>
<run_depend>image_transport</run_depend>
<run_depend>tf</run_depend>
<run_depend>brics_actuator</run_depend>
<run_depend>cv_bridge</run_depend>
<run_depend>perception_pcl</run_depend>
<run_depend>rosconsole</run_depend>
<run_depend>roslib</run_depend>
<run_depend>actionlib_msgs</run_depend>
<run_depend>control_msgs</run_depend>
<run_depend>diagnostic_msgs</run_depend>
<run_depend>geometry_msgs</run_depend>
<run_depend>map_msgs</run_depend>
<run_depend>nav_msgs</run_depend>
<run_depend>pcl_msgs</run_depend>
<run_depend>sensor_msgs</run_depend>
<run_depend>shape_msgs</run_depend>
<run_depend>std_msgs</run_depend>
<run_depend>tf2_geometry_msgs</run_depend>
<run_depend>tf2_msgs</run_depend>
<run_depend>tf2_sensor_msgs</run_depend>
<run_depend>trajectory_msgs</run_depend>
<run_depend>visualization_msgs</run_depend>
<run_depend>message_runtime</run_depend>
<run_depend>ORIGINAL_MSGS</run_depend>
</package>
これでやっとcatkin buildして、catkin_ws/devel/lib内のlibv_repExtRosInterface.soをV-REPのフォルダにコピーして完了です。これでオリジナルのメッセージもV-REP内で普通に使えます。
まとめ
なんか色々さまよって調べてできた割には、まとめてみると簡単だったっていうよくあるやつでした。