Ask Your Question
0

Some help regarding displaying ros results

asked 2012-11-19 22:34:59 -0500

Astronaut gravatar image

updated 2014-01-28 17:14:18 -0500

ngrennan gravatar image

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();
            }
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2012-11-20 20:36:44 -0500

Stephan gravatar image
total_min_distance = 100000.0 // some high value
while (node.ok())
{
  ... // calculate your current mindistance
  if (mindistance < total_min_distance)
    total_min_distance = mindistance;
}
std::cout << "Minimum distance in whole run: " << total_min_distance << std::endl;

This gives you the minimum distance of the time the node was running when the node is shutting down.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-11-19 22:34:59 -0500

Seen: 114 times

Last updated: Nov 20 '12