Ask Your Question
0

use topic's variable

asked 2016-04-28 02:44:09 -0500

Emilien gravatar image

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

edit retag flag offensive close merge delete

Comments

1

What do you mean exactly? From what you say, it seems that you must read again the tutorials

Javier V. Gómez gravatar imageJavier V. Gómez ( 2016-04-28 02:47:49 -0500 )edit

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?

Emilien gravatar imageEmilien ( 2016-04-28 02:59:37 -0500 )edit

2 Answers

Sort by » oldest newest most voted
1

answered 2016-04-28 03:02:15 -0500

Mehdi. gravatar image

updated 2016-04-28 08:32:09 -0500

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.

edit flag offensive delete link more

Comments

yes but which type i use for x?

Emilien gravatar imageEmilien ( 2016-04-28 03:04:09 -0500 )edit

If you ask this question I guess you are using C++?

Mehdi. gravatar imageMehdi. ( 2016-04-28 03:15:41 -0500 )edit

yes, i use C++. I try to use std_msgs::Float64 x; x=variable.data; but it doesn't work

Emilien gravatar imageEmilien ( 2016-04-28 03:55:20 -0500 )edit
2

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.

Mehdi. gravatar imageMehdi. ( 2016-04-28 06:10:41 -0500 )edit
0

answered 2016-04-29 09:49:29 -0500

Airuno2L gravatar image

This page has the info you're looking for.

So it would be

double x = variable.data
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-04-28 02:44:09 -0500

Seen: 57 times

Last updated: Apr 29 '16