[ros-users] Ros version checking in python scripting
Steven Bellens
steven.bellens at mech.kuleuven.be
Wed Feb 2 00:08:14 UTC 2011
2011/2/2 Ken Conley <kwc at willowgarage.com>:
> On Tue, Feb 1, 2011 at 3:58 PM, Steven Bellens
> <steven.bellens at mech.kuleuven.be> wrote:
>> 2011/2/2 Ken Conley <kwc at willowgarage.com>:
>>> Hi Steven,
>>>
>>> There's no fast way to check the version from a Python script -- you
>>> can shell to bin/rosversion (or re-use its code, as it is Python).
>>>
>>> However, there are two alternatives that achieve your goal:
>>>
>>> 1) (recommended)
>>> from rospy import Header
>>>
>>> 2) The Pythonic way of doing multi-version compatibility:
>>>
>>> try:
>>> from std_msgs.msg import Header
>>> except ImportError:
>>> from roslib.msg import Header
>>
>> That's not really what we need. The python script involved is used to
>> generate C++ typekit code. It used to have one line writing out a
>> '#include <roslib/Header.h>'. This now needs replacing with the
>> std_msg header depending on the ROS version. So, either way, the
>> python code itself will never complain about it.
>
> Then I recommend using the bin/rosversion solution. The
> std_msgs/Header is part of ROS 1.3.1+ (unstable), though realistically
> you only need to check ROS 1.4+ as the stable version.
ok, thanks!
Steven
>
> - Ken
> _______________________________________________
> ros-users mailing list
> ros-users at code.ros.org
> https://code.ros.org/mailman/listinfo/ros-users
>
More information about the ros-users
mailing list