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

data.data does not name a type

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

samo gravatar image

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

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

Comments

Hi! I ran into the same problem, so how did you solve this problem?

Lamfurst gravatar image Lamfurst  ( 2021-05-15 22:17:59 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

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

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 image samo  ( 2018-06-27 10:08:27 -0600 )edit
1

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

VictorLamoine gravatar image VictorLamoine  ( 2018-06-27 10:10:46 -0600 )edit

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

TifferPelode gravatar image TifferPelode  ( 2018-06-27 21:47:30 -0600 )edit

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

samo gravatar image samo  ( 2018-07-06 04:06:18 -0600 )edit

I have the same problem did you solve it?

Basma gravatar image Basma  ( 2022-09-05 03:58:03 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-06-27 07:33:31 -0600

Seen: 2,532 times

Last updated: Jun 27 '18