Problems to analyse laser data [closed]

asked 2017-04-05 07:22:44 -0500

shenki gravatar image


I am using kinetic ROS with GAZEBO 7 and I have a problem, here is my code :

    void SetVelocity(const double &_vel)

        this->nomModel3 = this->nomModel;
        this->nomModel3 = this->nomModel3 + "/map";         

        if (this->nomModel3==nomModel2){

            this->model->GetJointController()->SetVelocityTarget(this->joint->GetScopedName(), _vel);


    void scanCallback(const sensor_msgs::LaserScan::ConstPtr& scan){

        tailleTableau = (sizeof(scan->ranges)/sizeof(scan->ranges[0])) - 1;

        if (tailleTableau >= 0){

            for (i=0; i < tailleTableau ; i++){

                if ((scan->ranges[i]>=scan->range_min)&&(scan->ranges[i]<=scan->range_max)){

                    this->nomModel2 = scan->header.frame_id.c_str();


my scanCallBack() is called everytimes I get information from hokuyo laser, and I want to loop into the array it gives me, so I am using a for loop, however, sometimes I can see the data in scan->range is correct and is supposed to get into my if condition but it's not getting in, it's just writting "inf" even if the command rostopic echo /hokuyo_laser shows me that it's wrong.

What am i doing wrong ? thank in advance

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by DavidN
close date 2017-04-10 02:23:54.183459


Have you tried something simpler like tailleTableau = scan->ranges.size();?

DavidN gravatar image DavidN  ( 2017-04-09 22:08:07 -0500 )edit

Oh, hello, I forget to say I found the problem and indeed that was the problem, thank you anyway !

shenki gravatar image shenki  ( 2017-04-10 02:05:41 -0500 )edit