Problem with subscriber on Chipkit [closed]
Hi. I'm working on a project using a Chipkit Max32. I made all the tutorials on the arduino ros serial and it works fine.
Now the problem is that i have a publisher on my computer (running Kubuntu 14.04) and i program my chipkit. After doing this:
rosrun rosserial_python serial_node.py /dev/ttyUSB1
I get the error:
[ERROR] [WallTime: 1438803266.042381] Creation of subscriber failed: agv_ipleiria ROS path [0]=/opt/ros/indigo/share/ros ROS path [1]=/opt/ros/indigo/share ROS path [2]=/opt/ros/indigo/stacks
my code is:
#include <ros.h>
#include <std_msgs/String.h>
#include <agv_ipleiria/AgvGeneral.h>
ros::NodeHandle nh;
std_msgs::String str_msg;
ros::Publisher chatter("chatter", &str_msg);
void messageCb( const agv_ipleiria::AgvGeneral& msg){
digitalWrite(PIN_LED2, LOW); // set the LED off
delay(5000);
}
ros::Subscriber<agv_ipleiria::AgvGeneral> sub("AGVipleiriaChatter", &messageCb );
char hello[13] = "hello world!";
void setup()
{
pinMode(PIN_LED2, OUTPUT);
digitalWrite(PIN_LED2, LOW); // set the LED off
delay(5000);
nh.initNode();
nh.advertise(chatter);
nh.subscribe(sub);
digitalWrite(PIN_LED2, HIGH); // set the LED on
delay(700); // wait for a second
}
void loop()
{
str_msg.data = hello;
chatter.publish( &str_msg );
nh.spinOnce();
delay(1000);
}
Where is the problem on this code?
Thank You.
Is it valid to create a subscriber before you've called
ros.initNode()
on platforms runningrosserial
?well, i've seen that on some projects. And it worked.