Problems to analyse laser data [closed]

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

shenki gravatar image

Hello,

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)){

                    ROS_INFO("hello");
                    this->nomModel2 = scan->header.frame_id.c_str();
                    this->SetVelocity(-30);
                }
            }
        }

    }

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

Comments

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

DavidN gravatar imageDavidN ( 2017-04-09 22:08:07 -0600 )edit
1

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

shenki gravatar imageshenki ( 2017-04-10 02:05:41 -0600 )edit