Ask Your Question

alexjs's profile - activity

2015-04-21 17:58:59 -0500 received badge  Famous Question (source)
2015-04-21 17:58:59 -0500 received badge  Notable Question (source)
2015-01-23 05:54:18 -0500 received badge  Popular Question (source)
2014-11-20 09:23:13 -0500 received badge  Scholar (source)
2014-11-20 09:21:54 -0500 commented answer Callback from subscriber does not work

Thank yo so much, that was the problem!

2014-11-18 15:28:30 -0500 asked a question Callback from subscriber does not work

Hi. This is probably an insignificant problem, but I just can't see it.

I used the publisher/subscriber tutorial to make communication in my own program. The publisher publish well in a topic, and the subscriber is subscribe to it, or 'rostopic info' says so, but the callback function does not even start. Whatever I have inside (a variable change, a ROS_INFO, etc.), nothing seems to happen.

This is my code (without the lines of my own program, which are not important):

Publisher:

#include <ros/ros.h>
#include "std_msgs/String.h"
#include <sstream>
#include <iostream>

int main(int argc, char** argv){
  ros::init(argc, argv, "gesture");

  ros::NodeHandle nh;

  std_msgs::String msg;

  ros::Publisher chatter_pub = nh.advertise<std_msgs::String>("chatter", 10);


  ros::Rate rate(10.0);

  while (nh.ok()){

    msg.data = "hello world";
    chatter_pub.publish(msg);


    ros::spinOnce();

    rate.sleep();
  }
  return 0;
};

Subscriber:

#include <ros/ros.h>
#include <ros/console.h>
#include <std_msgs/String.h>
#include <iostream>
#include <sstream>

int message=0;

void cb(const std_msgs::String::ConstPtr& msg)
{
  ROS_INFO_STREAM("callback");
  message=1;

}


int main(int argc, char** argv){
  ros::init(argc, argv, "turtle_tf_listener");

ros::NodeHandle n;

  ros::Rate rate(10.0);
  while (node.ok()){

 ros::Subscriber sub = n.subscribe ("/chatter", 10, cb);

 ROS_INFO_STREAM(message);
    rate.sleep();
  }

  ros::spinOnce();
  return 0;
};

Everything else from the program works, and it executes well, it is just the callback function wich seems not to run.

Thanks in advance for the answers.

2014-11-08 09:49:35 -0500 received badge  Famous Question (source)
2014-11-07 10:14:08 -0500 received badge  Notable Question (source)
2014-10-31 04:45:21 -0500 received badge  Enthusiast
2014-10-29 18:44:38 -0500 received badge  Popular Question (source)
2014-10-27 07:15:01 -0500 asked a question Position recognition with Kinect

Hi, I’m working on body position recognition using Kinect and openni_tracker, specifically the origin points (x, y and z) of the transformations (head, torso, elbow, hand…) given by the tracker. I have the points and now I pretend to work with them to recognize some specific positions of the body previously memorized.

I was told that Mahalanobis distance should work fine with this variables but I want to know if there is some other way to do it, some algorithm or a program already done.

I’m using ROS Groovy, so the MIT package is not an option, since I couldn’t make it work.

Thanks in advance.