Re: [ros-users] Ros version checking in python scripting

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: User discussions
Date:  
To: User discussions
Subject: Re: [ros-users] Ros version checking in python scripting
2011/2/2 Ken Conley <>:
> 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.

Steven

>
>  - Ken
>
> On Tue, Feb 1, 2011 at 12:45 PM, Steven Bellens
> <> wrote:
>> Hi,
>>
>> Due to the moving of the Header.h file from roslib to std_msgs we need
>> to check the ROS version involved to include the right header in our
>> rtt_ros_integration package.
>> How can we check the ROS version in a python script?
>> When exactly did this move happen, e.g. what's the version to check for?
>>
>> regards,
>>
>> Steven
>> _______________________________________________
>> ros-users mailing list
>>
>> https://code.ros.org/mailman/listinfo/ros-users
>>
> _______________________________________________
> ros-users mailing list
>
> https://code.ros.org/mailman/listinfo/ros-users
>