0
$\begingroup$

Rosanswers logo

hi, I want to use the variable which I subscribe on my code program. what can i do please?


Originally posted by Emilien on ROS Answers with karma: 167 on 2016-04-28

Post score: 0


Original comments

Comment by Javier V. Gómez on 2016-04-28:
What do you mean exactly? From what you say, it seems that you must read again the tutorials

Comment by Emilien on 2016-04-28:
i subscribe to a std_msgs/Float64 variable all is ok. now, i want to use this variable on my code like x = this variable, but i don't know how to convert it. have you any solution?

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

x = variable.data

For more details about the type itself check this

In your case, variable has the type std_msgs::Float64 . variable.data would be just a double. declare x as double.


Originally posted by Mehdi. with karma: 3339 on 2016-04-28

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Emilien on 2016-04-28:
yes but which type i use for x?

Comment by Mehdi. on 2016-04-28:
If you ask this question I guess you are using C++?

Comment by Emilien on 2016-04-28:
yes, i use C++. I try to use std_msgs::Float64 x; x=variable.data; but it doesn't work

Comment by Mehdi. on 2016-04-28:
variable has the type std_msgs::Float64 . variable.data would be just a double. declare x as double. And put a code example in your question, including the declaration of the subscriber and of the callback function, that would help.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.