Ask Your Question
0

data.data does not name a type

asked 2018-06-27 07:33:31 -0500

samo gravatar image

updated 2018-06-27 08:24:37 -0500

gvdhoorn gravatar image

i create a node in order to publish topic, so i choose std_msgs::Float64 as a type of message sent by my publisher. then i wrote those lines to publish a random message :

std_msgs::Float64 test;
test.data=0.500785;
pub.publish(test);

and that gives me an error : 'test' does not name a type

and : pub.publish(test) does not name a type.

any ideas to solve that? PS: i'm coding in c++ can anyone help me?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-06-27 10:00:31 -0500

VictorLamoine gravatar image

You need the relevant include to be able to use this message:

#include <std_msgs/Float32.h>

You need to setupstd_msgs as a dependency of your package if you want that to work: http://wiki.ros.org/catkin/Tutorials/...

edit flag offensive delete link more

Comments

i already have std_msgs as a dependency, but it didn't work for me.

samo gravatar imagesamo ( 2018-06-27 10:08:27 -0500 )edit
1

Please provide a simple, full example ROS package demonstrating your problem if you want more help (edit your first message)

VictorLamoine gravatar imageVictorLamoine ( 2018-06-27 10:10:46 -0500 )edit

I think you may put this in your .h file, try put them at ,cpp file and compile again.

TifferPelode gravatar imageTifferPelode ( 2018-06-27 21:47:30 -0500 )edit

they are already in the same .cpp file. but it gives me this error

samo gravatar imagesamo ( 2018-07-06 04:06:18 -0500 )edit

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: 2018-06-27 07:33:31 -0500

Seen: 237 times

Last updated: Jun 27 '18