ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to convert Float 64 to Double?

asked 2020-09-30 23:23:34 -0600

loguna gravatar image

updated 2020-10-01 02:22:50 -0600

gvdhoorn gravatar image

Hi I have the following plugin: I like to subscribe to a ROS node which gives me the reset_frequency data (in Float 64) which by default has a value of 2.0. However when compiling, I receive this error:

Error:

invalid use of member ‘gazebo::ParticleShooterPlugin::reset_frequency’ in static member function
 reset_frequency= msg->data/1.0
/home/ntu-saab_uwr/uuvsim_ws/src/particle_shooter/particle_shooter/src/particle_shooter_plugin_modify.cpp:323:28: note: declared here
   double reset_frequency = 2.0;

Code:

......

void particle_callback(const std_msgs::Float64::ConstPtr& msg)
{
    reset_frequency= msg->data;
}

......

double reset_frequency = 2.0;

May I Know how to solve this Problem?

edit retag flag offensive close merge delete

Comments

Mh you are asking something like:

reset_frequency= static_cast<double>(msg->data);

???

Solrac3589 gravatar image Solrac3589  ( 2020-10-01 00:07:21 -0600 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2020-10-01 00:30:06 -0600

The compiler error that you are getting doesn't seem to refer to a float64/double conversion.

It seems to refer to an invalid use of reset_frequency, we would need more context to help you. Where is ‘gazebo::ParticleShooterPlugin::reset_frequency’ defined? Is it defined as static?

I think the compiler is trying to tell you that you can not assign msg->data to reset_frequency, not because of type incompatibility but because you are actually not allowed to modify the value of reset_frequency.

edit flag offensive delete link more

Comments

It's likely the problem is that reset_frequency is not in scope in the body of the callback.

gvdhoorn gravatar image gvdhoorn  ( 2020-10-01 02:23:29 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2020-09-30 23:23:34 -0600

Seen: 2,188 times

Last updated: Oct 01 '20