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

How can I get hokuyo published information?

asked 2011-06-05 03:00:51 -0600

snoworld gravatar image

updated 2014-01-28 17:09:47 -0600

ngrennan gravatar image

I need help. When I run hokuyo_node I suppose that it publish information about laser data, like intensity or range. I need to get that information in another node to do object detection but I dont know how to do. I tryed this:

ros::Subscriber hokuyoSubscriber = n_2.subscribe("scan", 1, scanValues);

void scanValues(const sensor_msgs::LaserScan laser)
{
    ROS_INFO("size[%d]: ", laser.intensities.size());
    for (unsigned int i=0; i<laser.intensities.size();i++)
    {
        intensities[i] = laser.intensities[i];
        ROS_INFO("intens[%f]: ", intensities[i]);

    }
}

But receives nothing...

edit retag flag offensive close merge delete

6 Answers

Sort by ยป oldest newest most voted
2

answered 2011-06-09 10:32:54 -0600

Wim gravatar image

The rostopic and rosnode tools should help you debug this.

First you can check if the Hokuyo node is publishing anything, by using 'rosnode info <nodename>'. You can find the nodename by running 'rosnode list'. This should show you the topics that are published by the Hokuyo node. Check if 'scan' is one of the published topics.

Then see if there is actual data on the 'scan' topic, by running 'rosnode hz scan'. This will show you how many messages are published on the 'scan' topic.

Now see which nodes are using the 'scan' topic by running 'rostopic info scan'. You should see the Hokuyo node as a publisher, and your own node as a subscriber. If your node is not listed as a subscriber, it can't receive any scan messages.

edit flag offensive delete link more
0

answered 2011-12-15 13:37:44 -0600

searchrescue gravatar image

updated 2011-12-15 13:38:05 -0600

i think rostopic hz /scan can be tried.

edit flag offensive delete link more
0

answered 2011-06-05 03:36:45 -0600

dornhege gravatar image

You can use rxgraph to see if the topics are published, subscribed and connected.

edit flag offensive delete link more
0

answered 2011-06-05 03:37:39 -0600

snoworld gravatar image

Yes I chech it on rviz and I can see a white line that indicates where are an objects. I changed "scan" topic to "/scan" but nothing changes, I get the same response...

edit flag offensive delete link more

Comments

Please add the output of rostopic list -v or rxgraph.
dornhege gravatar image dornhege  ( 2011-06-05 03:46:46 -0600 )edit
Please post your complete code
KoenBuys gravatar image KoenBuys  ( 2011-06-05 18:01:58 -0600 )edit
0

answered 2011-06-05 03:07:14 -0600

dkst gravatar image

Could you check it on rviz? rosrun rviz rviz. If it works there, then its not the problem with the laser.

I suspect that you may not be subscribing to the right topic title. From my experience with hokuyo, I think that the correct topic title is "/scan" not "scan".

edit flag offensive delete link more
0

answered 2011-12-15 16:54:36 -0600

searchrescue gravatar image

I am trying to subscribe to the Hoyuko Laser Finder's laser sensor messages. I want to go through the code published above.

#include "ros/ros.h"
#include "std_msgs/String.h"
#include "sensor_msgs/LaserScan.h"

void scanValues(const sensor_msgs::LaserScan laser)
{
    ROS_INFO("size[%d]: ", laser.intensities.size());
    for (unsigned int i=0; i<laser.intensities.size();i++)
    {
        intensities[i] = laser.intensities[i];
        ROS_INFO("intens[%f]: ", intensities[i]);

    }
}

int main(int argc, char **argv)
{
  ros::init(argc, argv, "hLaserReader");
  ros::NodeHandle n;
  ros::Subscriber hokuyoSubscriber = n.subscribe("/scan", 1, scanValues);
  ros::spin();
  return 0;
}

what should i add more. Thanks!

edit flag offensive delete link more

Comments

Looks, like it should work. If you have a new question, open a new one and add what does not work.
dornhege gravatar image dornhege  ( 2011-12-15 21:29:50 -0600 )edit

Can anyone teach me how to launch a .cpp file in the terminal? Thanks

Edward Ramsay gravatar image Edward Ramsay  ( 2013-05-03 06:20:06 -0600 )edit

Question Tools

Stats

Asked: 2011-06-05 03:00:51 -0600

Seen: 3,451 times

Last updated: Dec 15 '11