0
$\begingroup$

Rosanswers logo

Hi Everyone, I am trying to publish the data of the laser scans of Hokuyo node.

#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;
}

this is the code, but i am getting this error

In function ‘void scanValues(sensor_msgs::LaserScan)’: x.cpp:10:9: error: ‘intensities’ was not declared in this scope


Originally posted by searchrescue on ROS Answers with karma: 50 on 2011-12-16

Post score: 0

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

It should be laser.intensities instead of intensities...


Originally posted by dornhege with karma: 31395 on 2011-12-16

This answer was ACCEPTED on the original site

Post score: 2

$\endgroup$
0
$\begingroup$

Rosanswers logo

This code works correctly. My mistake was in CMakeLists.txt file. I put rosbuild_add_executable(hLaser_node src/hLaserReader.cpp) very top of the file. Now that i moved this line to the bottom. Now it works. thanks.


Originally posted by searchrescue with karma: 50 on 2011-12-16

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.