Using ROS message classes outside of ROS
<p>I have a ROS node written in Python that captures messages and writes them to disk (e.g. using <code>pickle</code>). I want to use these files later, in another Python script, outside of ROS, but I need to import the message classes.</p>

<p>Is that possible?</p>

<p>Thanks!</p>

<p>Unfortunately I don't think it's possible to just import the message files outside of any ROS dependencies. For example, if you look inside one of the generated message class files:</p>

<pre><code>---/your_catkin_ws/devel/lib/python2.7/dist-packages/your_package/msg/_Message.py
</code></pre>

<p>You will see that it depends <strong>at least</strong> on genpy and other message types contained in your message. Base messages are the same (in <code>/opt/ros/indigo/lib/python2.7/dist-packages/std_msgs/msg</code>).</p>

<p>While you could try to copy the minimum amount of dependencies until It Finally Works(!), it's a little un-elegant and probably going to be a brittle solution.</p>

<p>I believe the best solution is to convert your message to a generic non-ROS type, then store it in your pickle (so essentially what you've been doing already).</p>

python ros