Just getting rosserial setup after a few days of issues. When trying to run the Hello World example (code below) I error out (also below). Any help would be great!
*
* rosserial Publisher Example
* Prints "hello world!"
*/
// Use the following line if you have a Leonardo or MKR1000
//#define USE_USBCON
#include <ros.h>
#include <std_msgs/String.h>
ros::NodeHandle nh;
std_msgs::String str_msg;
ros::Publisher chatter("chatter", &str_msg);
char hello[13] = "hello world!";
void setup()
{
nh.initNode();
nh.advertise(chatter);
}
void loop()
{
str_msg.data = hello;
chatter.publish( &str_msg );
nh.spinOnce();
delay(1000);
}
Error code
Arduino: 1.8.15 (Linux), Board: "Arduino Uno"
Hello_world:2:14: error: expected constructor, destructor, or type conversion before 'Publisher'
* rosserial Publisher Example
^~~~~~~~~
exit status 1
expected constructor, destructor, or type conversion before 'Publisher'
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Originally posted by matthewfwork on ROS Answers with karma: 15 on 2021-08-24
Post score: 0
Original comments
Comment by gvdhoorn on 2021-08-24:\
When trying to run the Hello World example
please, always link to whatever you are referring to.
We cannot see what you are seeing, so without a link, we have to spend time finding it ourselves, which means less time to help you solve your problem.