Problems to analyse laser data
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
Asked by shenki on 2017-04-05 07:22:44 UTC
Comments
Have you tried something simpler like
tailleTableau = scan->ranges.size();
?Asked by DavidN on 2017-04-09 22:08:07 UTC
Oh, hello, I forget to say I found the problem and indeed that was the problem, thank you anyway !
Asked by shenki on 2017-04-10 02:05:41 UTC