[ros-users] Unable to get double parameters

Christian Verbeek verbeek at servicerobotics.eu
Fri Oct 29 08:25:39 UTC 2010


Josh,

I found out what the problem is. But I do not have a solution to it
right now.

#include <ros/ros.h>
#include <QtGui>

int main(int argc, char** argv)
{
    QApplication app( argc, argv, false );

    ros::init(argc, argv, "params_test");

    ros::NodeHandle n;

    double a = 1.5;
    n.setParam( "a", a );

    double a_get;
    n.getParam( "a", a_get );

    ROS_INFO_STREAM( "a=" << a << "  a_get=" << a_get );

    return 0;
}

Gives me
[ INFO] [1288340780.906072159]: a=1.5  a_get=1

Without QApplication it gives me
[ INFO] [1288340754.462816012]: a=1.5  a_get=1.5

So the problem is QApplication. I am using Ubuntu 9.04 with QT 4.5.0. I
will now upgrade to Qt 4.6 hoping that this changes something.

Regards
Christian
> Do you have a small test-case that fails that I could try?  We have a
> test-case for exactly this:
>
>   double double_param = 0.0;
>   EXPECT_TRUE( param::get( "double", double_param ) );
>   EXPECT_DOUBLE_EQ( double_param, 10.5 );
>
> Does the params test in test_roscpp also fail?
>
> Josh
>
> On Thu, Oct 28, 2010 at 5:09 AM, Christian Verbeek
> <verbeek at servicerobotics.eu <mailto:verbeek at servicerobotics.eu>> wrote:
>
>     getParam(const std::string &key, double &d)
>
>     returns only the integer part of the parameter.
>
>     ros::NodeHandle nh( "~" );
>     double dvalue;
>     nh.getParam( "key", dvalue );
>
>     dvalue=0 // in the launch file 0.2
>     dvalue=1 // in the launch file 1.5
>     ...
>
>     in /opt/ros/cturtle/ros/core/roscpp/src/libros/param.cpp
>     I printed the XmlRpcValue and this gives me
>
>     <value><double>0</double></value>
>     <value><double>1</double></value>
>
>     Whats going wrong? Any ideas?
>
>     rosparam get key
>     returns 0.200000000000000001 or 1.5
>
>     so the values in the parameter server are correct.
>
>     _______________________________________________
>     ros-users mailing list
>     ros-users at code.ros.org <mailto:ros-users at code.ros.org>
>     https://code.ros.org/mailman/listinfo/ros-users
>
>
>
> _______________________________________________
> ros-users mailing list
> ros-users at code.ros.org
> https://code.ros.org/mailman/listinfo/ros-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ros.org/pipermail/ros-users/attachments/20101029/669a6e6b/attachment-0007.html>


More information about the ros-users mailing list