how to call a service in the programme
hi all
i have service which i giving me an integer when its being called , i want to add a condition in my program that only if that service is called i should start analyzing, else not.
if(m.point.x > startx -3 && m.point.x < startx + h && m.point.y < starty && m.point.y > starty - npallets * h )
{
for (int i=0; i<palletdrop.size();i++)
{
if(palletdrop[i].isInside(m.point.x,m.point.y))
{
palletdrop[i].setOccupied();
}
}
}
else
{
newScan.ranges[i] = 0;
}
}
}
fake_scan_pub.publish(newScan);
freeSpace = getFreeSpace();
if(freeSpace == -1){
std::cout<<"NO FREE SPACES "<<std::endl;
}else{
std::cout<<"The first free Area is: "<<freeSpace<<std::endl;
}
so, this above program should initiate only if service is called .. please help how can i do that .
ros::ServiceServer service = nh.advertiseService("get_free_space", empty_place);
this is my service name