Some help regarding displaying ros results
Hello
I need some help regarding displaying the results on the node I have created. I have use some transformation tf to calculate some distances from the robot to some labeled objects on the map. The code is compiling and working. I programmed code that gives me a minimum distance from the robot to the door frame while robot is moving in the map of the environment. The parameter mindistance is the minimum distance from the 4 line segments of the robot ( I assume that my robot is a rectangle with 4 corners, that defined the 4 line segments) to a door frame. So I want to have at the end one value , minimum distance. But the code gives me the minimum distance en each time step. So it give me the current minimum distance.So how to make it to display the minimum distance from the whole robot run, not the mindistance in each time step. This is the short version of the code
ros::init(argc, argv, "my_tf_listener");
ros::NodeHandle node;
.
.
.
tf::TransformListener listener;
ros::Rate rate(10.0);
ros::Duration wait(5); wait.sleep();
while (node.ok())
{
.
.
.
//Find the minimum distance of all 8 line to segment distances
double distarray [8]= {distanceSegment11, distanceSegment12, distanceSegment21, distanceSegment22, distanceSegment31,distanceSegment32, distanceSegment41, distanceSegment42};
int count=1;
double mindistance = distarray [0];
for (int i = 1; i < 8; i++){
if (distarray[i] < mindistance){
mindistance = distarray[i];
count=i+1;
}
}
.
.
.
if (mindistance < 1) {
ROS_INFO("Min distance to Door = %f", mindistance);
}
rate.sleep();
}