Robotics StackExchange | Archived questions

Problem with subscriber on Chipkit

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 rosserialpython serialnode.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.

Asked by cjusto on 2015-08-05 14:50:01 UTC

Comments

Is it valid to create a subscriber before you've called ros.initNode() on platforms running rosserial?

Asked by gvdhoorn on 2015-08-05 14:52:09 UTC

well, i've seen that on some projects. And it worked.

Asked by cjusto on 2015-08-05 15:43:21 UTC

Answers

The problem was on bad defined custom package.

Problem solved.

Asked by cjusto on 2015-11-19 08:00:17 UTC

Comments